Skip to content
Go back

ANTLR 速记

Updated:
Edit page

结合性和左、右递归

grammar Expr;

expr: expr '^' expr
| INT
;

INT: [0-9]+;
WS: [ \t\r\n]+ -> skip;

使用 assoc

grammar Expr;

expr: <assoc=right> expr '^' expr
| INT
;

INT: [0-9]+;
WS: [ \t\r\n]+ -> skip;
image

左递归

*( *a) [] []

grammar PC;

decl: decl '[' ']'
| '*' decl
| '(' decl ')'
| ID
;

ID: [a-zA-Z]+;
WS: [ \t\r\n]+ -> skip;
image

Edit page
Share this post on:

Previous Post
Why Changing nearest power of two in HashMap?
Next Post
Java generics with overloading