Skip to content

Commit 45c9be5

Browse files
committed
Add a human friendly grammar.
1 parent 8d5baa9 commit 45c9be5

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

g4/Ds.g4

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
grammar Ds;
2+
3+
rule_pool
4+
: rule* EOF
5+
;
6+
7+
rule
8+
: term
9+
| (term (',' term)*)? '->' term
10+
;
11+
12+
term
13+
: SYMBOL
14+
| term '(' (term (',' term)*)? ')'
15+
| '(' term ')'
16+
| <assoc=right> ('~' | '!' | '-' | '+' | '&' | '*') term
17+
| term ('*' | '/' | '%') term
18+
| term ('+' | '-') term
19+
| term ('<<' | '>>') term
20+
| term ('<' | '>' | '<=' | '>=') term
21+
| term ('==' | '!=') term
22+
| term '&' term
23+
| term '^' term
24+
| term '|' term
25+
| term '&&' term
26+
| term '||' term
27+
;
28+
29+
WHITESPACE
30+
: [ \t\r\n]+ -> skip
31+
;
32+
33+
COMMENT
34+
: '//' ~[\r\n]* -> skip
35+
;
36+
37+
SYMBOL
38+
: ~[ \t\r\n,()]+
39+
;

0 commit comments

Comments
 (0)