-
Notifications
You must be signed in to change notification settings - Fork 0
/
parser.rkt
25 lines (19 loc) · 961 Bytes
/
parser.rkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#lang brag
;; A parser for R-Expressions
rex : implicit-expression [ ":" explicit-expression ]
implicit-expression : [STAR] (limited-expression [STAR])*
explicit-expression : node-line ("," node-line)*
limited-expression : transition | loop | sub-expression
sub-expression : "(" ( branch | limited-expression )+ ")"
loop : "{" ( limited-expression )+ "}"
branch : "|"
node-line : ["="] node-identifier (transition "-" ">" node-identifier)*
node-identifier : (NUMBER | ALPHA | PUNCTUATION)+
transition : character | range | GLOB | except
range : "[" span ("," span)* "]"
span : character ["-" character]
except : "!" character
;; In addition to the regular ascii escape sequences
;; the following characters are reserved and have to be escaped with \:
;; space;:*.,{}[]|\-=!
character : NUMBER | ALPHA | PUNCTUATION | ESCAPED-CHAR