summaryrefslogtreecommitdiff
path: root/query/Query.g4
diff options
context:
space:
mode:
authorromangraef <roman.graef@gmail.com>2018-05-15 20:02:18 +0200
committerromangraef <roman.graef@gmail.com>2018-05-15 20:02:18 +0200
commit9187528a1e4d96aee5381138547c62ed7e281aa8 (patch)
tree5aaea27d46ba55d54866cacb130425cbcd560896 /query/Query.g4
parent50787a7a3c14b8cbe1890cfdc62bc1d27171209c (diff)
downloadfuckingselfbot-9187528a1e4d96aee5381138547c62ed7e281aa8.tar.gz
fuckingselfbot-9187528a1e4d96aee5381138547c62ed7e281aa8.tar.bz2
fuckingselfbot-9187528a1e4d96aee5381138547c62ed7e281aa8.zip
~stream languageHEADmaster
Diffstat (limited to 'query/Query.g4')
-rw-r--r--query/Query.g433
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