-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCordSAS.g4
More file actions
43 lines (30 loc) · 1010 Bytes
/
CordSAS.g4
File metadata and controls
43 lines (30 loc) · 1010 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* Define a grammar called CordSAS
*/
grammar CordSAS;
calculation : expr ;
expr : method #methodCall
| expr ( '*' | '/' ) expr #multiDiv
| expr ( '+' | '-' ) expr #addSub
| leaf #leafCall
| '(' expr ')' #blockExpr
;
// define a methods signature
method : ID '(' methodArguments ')' ;
// methodArguments to be a list of expressions separated by commas.
methodArguments : | expr (',' expr)* ;
// leaf represents terminal nodes in the parse tree
leaf : ID | NUM | PERIOD | dataref;
// defines a time series identifier with colon separators
dataref : (ID | QID) (':' (ID | QID) )+ ;
// define our lexer elements
// Time Period identifier
PERIOD : [0-9]+[QJFMASOND][1-4] | [0-9]+[JFMASOND][a-z]+ ;
// Any number
NUM : [-]?[0-9]+[.0-9]? ;
// Identifier
ID : [a-zA-Z][a-zA-Z0-9_.]* ;
// Quoted Identifier (allows '-' in identifier)
QID : ['][-a-zA-Z0-9_:.]+['] ;
// Ignore whitespace
WS : [ \t\u000C\r\n]+ -> skip ;