From a9782118acd6c03377c530b14edd9a6d424c6c97 Mon Sep 17 00:00:00 2001 From: parrt Date: Thu, 4 Aug 2011 08:56:08 -0800 Subject: [PATCH] add [git-p4: depot-paths = "//depot/code/antlr4/main/": change = 8985] --- tool/playground/Scannerless.g | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tool/playground/Scannerless.g diff --git a/tool/playground/Scannerless.g b/tool/playground/Scannerless.g new file mode 100644 index 000000000..67e059d8c --- /dev/null +++ b/tool/playground/Scannerless.g @@ -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;}:.)* '*'/ ; +