diff options
author | romangraef <roman.graef@gmail.com> | 2018-05-15 20:02:18 +0200 |
---|---|---|
committer | romangraef <roman.graef@gmail.com> | 2018-05-15 20:02:18 +0200 |
commit | 9187528a1e4d96aee5381138547c62ed7e281aa8 (patch) | |
tree | 5aaea27d46ba55d54866cacb130425cbcd560896 /query/Query.g4 | |
parent | 50787a7a3c14b8cbe1890cfdc62bc1d27171209c (diff) | |
download | fuckingselfbot-9187528a1e4d96aee5381138547c62ed7e281aa8.tar.gz fuckingselfbot-9187528a1e4d96aee5381138547c62ed7e281aa8.tar.bz2 fuckingselfbot-9187528a1e4d96aee5381138547c62ed7e281aa8.zip |
Diffstat (limited to 'query/Query.g4')
-rw-r--r-- | query/Query.g4 | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/query/Query.g4 b/query/Query.g4 new file mode 100644 index 0000000..a13a80f --- /dev/null +++ b/query/Query.g4 @@ -0,0 +1,33 @@ + +grammar Query; + +prog: stat+ EOF? ; + +stat: expr # rawExpr + | ID '=' expr # assign + ; + +expr: expr '.' ID # access + | expr '(' (args=expr*) ')' # call + | expr op=('*'|'/') expr # MulDiv + | expr op=('+'|'-') expr # AddSub + | INT # int + | STRINGLITERAL # string + | ID # id + | '(' expr ')' # parens + | '{' (args=arguments)? prog '}' # func + ; + +arguments: ID (',' ID)* '->'; + +STRINGLITERAL : '"' ( StringEscapeSeq | ~( '\\' | '"' | '\r' | '\n' ) )* '"' ; +StringEscapeSeq : '\\' ( 't' | 'n' | 'r' | '"' | '\\' | '$' | ('0'..'9')) ; + +MUL : '*' ; // assigns token name to '*' used above in grammar +DIV : '/' ; +ADD : '+' ; +SUB : '-' ; +ID : [a-zA-Z]+ ; // match identifiers +INT : [0-9]+ ; // match integers +NEWLINE:'\r'? '\n' -> skip ; // return newlines to parser (is end-statement signal) +WS : [ \t]+ -> skip ; // toss out whitespace
\ No newline at end of file |