-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbbnf.bbnf
42 lines (29 loc) · 902 Bytes
/
bbnf.bbnf
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
identifier = /[_a-zA-Z][_a-zA-Z0-9-]*/ ;
literal = "\"" , /(\\.|[^"\\])*/ , "\""
| "'" , /(\\.|[^'\\])*/ , "'"
| "`" , /(\\.|[^`\\])*/ , "`" ;
big_comment = ( "/*" , /[^\*]*/ , "*/" ) ?w ;
comment = ( "//" , /.*/ ) ?w ;
regex = "/" , /(\\.|[^\/])+/ , "/" ;
lhs = identifier ;
term = "ε"
| identifier
| literal
| regex
| "(" , rhs ?w , ")"
| "[" , rhs ?w , "]"
| "{" , rhs ?w , "}" ;
factor = big_comment ? , (
term ?w , "?w"
| term ?w , "?"
| term ?w , "*"
| term ?w , "+"
| term
) , big_comment ? ;
binary_operators = "<<" | ">>" | "-" ;
binary_factor = factor , ( binary_operators ?w , factor ) * ;
concatenation = ( binary_factor ?w , "," ? ) + ;
alternation = ( concatenation ?w , "|" ? ) + ;
rhs = alternation ;
rule = lhs, "=" ?w, rhs ?w, ( ";" | "." ) ;
grammar = ( comment ? , rule ?w , comment ? ) * ;