[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 8985]
This commit is contained in:
parrt 2011-08-04 08:56:08 -08:00
parent d926ec9661
commit a9782118ac
1 changed files with 31 additions and 0 deletions

View File

@ -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;}:.)* '*'/ ;