forked from jasder/antlr
add
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 8985]
This commit is contained in:
parent
d926ec9661
commit
a9782118ac
|
@ -0,0 +1,31 @@
|
|||
scannerless grammar T;
|
||||
|
||||
method : 'fun' name=ID '(' a+=arg (',' a+=arg)* ')' body ;
|
||||
|
||||
body : '{' (body|CMT|.)* '}' ; // nongreedy
|
||||
|
||||
stat: 'return' INT
|
||||
| ID '=' expr
|
||||
;
|
||||
|
||||
expr: atom ('*' atom)* ;
|
||||
|
||||
atom: INT
|
||||
| sql
|
||||
;
|
||||
|
||||
sql : 'select' '*' 'from' ID ;
|
||||
|
||||
// literals like 'select' become 'select' WS rules? hmm..nope
|
||||
// might not want WS. or might need &!id-letter or something
|
||||
|
||||
always call WS implicitly after any token match; if don't want, then make WS undefined.
|
||||
|
||||
RETURN : 'return' {!Character.isJavaId(input.LA(1))}? WS ;
|
||||
|
||||
ID : 'a'..'z'+ ;
|
||||
|
||||
WS : (' '|'\n')* ;
|
||||
|
||||
CMT : '/*' (options {greedy=false;}:.)* '*'/ ;
|
||||
|
Loading…
Reference in New Issue