diff --git a/grammar/Expr.g4 b/grammar/Expr.g4 index 286ab08a..ae32fe3d 100644 --- a/grammar/Expr.g4 +++ b/grammar/Expr.g4 @@ -17,33 +17,35 @@ grammar Expr; /* To match the whole input */ fullexpr: expr EOF; +expr + : atom # unsignedAtom + | IDENTIFIER '.' IDENTIFIER # portField + | '-' expr # negation + | '(' expr ')' # expression + | expr op=('/' | '*') expr # muldiv + | expr op=('+' | '-') expr # addsub + | expr COMPARISON expr # comparison + | IDENTIFIER '(' expr ')' # function + | IDENTIFIER '[' shift (',' shift)* ']' # timeShift + | IDENTIFIER '[' expr (',' expr )* ']' # timeIndex + | IDENTIFIER '[' shift1=shift '..' shift2=shift ']' # timeShiftRange + | IDENTIFIER '[' expr '..' expr ']' # timeRange + ; + +atom + : NUMBER # number + | IDENTIFIER # identifier + ; + shift: TIME shift_expr?; shift_expr - : op=('+' | '-') NUMBER # signedNumber - | op=('+' | '-') IDENTIFIER # signedIdentifier + : op=('+' | '-') atom # signedAtom | op=('+' | '-') '(' expr ')' # signedExpression - | op=('+' | '-') IDENTIFIER '(' expr ')' # signedFunction - | shift_expr op=('/' | '*') NUMBER # shiftMuldivNumber - | shift_expr op=('/' | '*') IDENTIFIER # shiftMuldivIdentifier + | shift_expr op=('/' | '*') atom # shiftMuldivAtom | shift_expr op=('/' | '*') '(' expr ')' # shiftMuldiv - | shift_expr op=('+' | '-') expr # shiftAddsub - ; - -expr - : '-' expr # negation - | expr op=('/' | '*') expr # muldiv - | expr op=('+' | '-') expr # addsub - | expr COMPARISON expr # comparison - | IDENTIFIER # identifier - | IDENTIFIER '.' IDENTIFIER # portField - | NUMBER # number - | '(' expr ')' # expression - | IDENTIFIER '(' expr ')' # function - | IDENTIFIER '[' shift (',' shift)* ']' # timeShift - | IDENTIFIER '[' expr (',' expr )* ']' # timeIndex - | IDENTIFIER '[' shift1=shift '..' shift2=shift ']' # timeShiftRange - | IDENTIFIER '[' expr '..' expr ']' # timeRange + | shift_expr op=('+' | '-') atom # shiftAddsubAtom + | shift_expr op=('+' | '-') '(' expr ')' # shiftAddsub ; fragment DIGIT : [0-9] ; diff --git a/src/andromede/expression/parsing/antlr/Expr.interp b/src/andromede/expression/parsing/antlr/Expr.interp index 22ba3b79..d62bd7fc 100644 --- a/src/andromede/expression/parsing/antlr/Expr.interp +++ b/src/andromede/expression/parsing/antlr/Expr.interp @@ -1,12 +1,12 @@ token literal names: null -'+' +'.' '-' '(' ')' '/' '*' -'.' +'+' ',' '..' null @@ -42,10 +42,11 @@ WS rule names: fullexpr +expr +atom shift shift_expr -expr atn: -[4, 1, 18, 125, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 3, 1, 14, 8, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 3, 2, 32, 8, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 5, 2, 49, 8, 2, 10, 2, 12, 2, 52, 9, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 5, 3, 76, 8, 3, 10, 3, 12, 3, 79, 9, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 5, 3, 88, 8, 3, 10, 3, 12, 3, 91, 9, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 3, 3, 109, 8, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 5, 3, 120, 8, 3, 10, 3, 12, 3, 123, 9, 3, 1, 3, 0, 2, 4, 6, 4, 0, 2, 4, 6, 0, 2, 1, 0, 1, 2, 1, 0, 5, 6, 142, 0, 8, 1, 0, 0, 0, 2, 11, 1, 0, 0, 0, 4, 31, 1, 0, 0, 0, 6, 108, 1, 0, 0, 0, 8, 9, 3, 6, 3, 0, 9, 10, 5, 0, 0, 1, 10, 1, 1, 0, 0, 0, 11, 13, 5, 11, 0, 0, 12, 14, 3, 4, 2, 0, 13, 12, 1, 0, 0, 0, 13, 14, 1, 0, 0, 0, 14, 3, 1, 0, 0, 0, 15, 16, 6, 2, -1, 0, 16, 17, 7, 0, 0, 0, 17, 32, 5, 10, 0, 0, 18, 19, 7, 0, 0, 0, 19, 32, 5, 12, 0, 0, 20, 21, 7, 0, 0, 0, 21, 22, 5, 3, 0, 0, 22, 23, 3, 6, 3, 0, 23, 24, 5, 4, 0, 0, 24, 32, 1, 0, 0, 0, 25, 26, 7, 0, 0, 0, 26, 27, 5, 12, 0, 0, 27, 28, 5, 3, 0, 0, 28, 29, 3, 6, 3, 0, 29, 30, 5, 4, 0, 0, 30, 32, 1, 0, 0, 0, 31, 15, 1, 0, 0, 0, 31, 18, 1, 0, 0, 0, 31, 20, 1, 0, 0, 0, 31, 25, 1, 0, 0, 0, 32, 50, 1, 0, 0, 0, 33, 34, 10, 4, 0, 0, 34, 35, 7, 1, 0, 0, 35, 49, 5, 10, 0, 0, 36, 37, 10, 3, 0, 0, 37, 38, 7, 1, 0, 0, 38, 49, 5, 12, 0, 0, 39, 40, 10, 2, 0, 0, 40, 41, 7, 1, 0, 0, 41, 42, 5, 3, 0, 0, 42, 43, 3, 6, 3, 0, 43, 44, 5, 4, 0, 0, 44, 49, 1, 0, 0, 0, 45, 46, 10, 1, 0, 0, 46, 47, 7, 0, 0, 0, 47, 49, 3, 6, 3, 0, 48, 33, 1, 0, 0, 0, 48, 36, 1, 0, 0, 0, 48, 39, 1, 0, 0, 0, 48, 45, 1, 0, 0, 0, 49, 52, 1, 0, 0, 0, 50, 48, 1, 0, 0, 0, 50, 51, 1, 0, 0, 0, 51, 5, 1, 0, 0, 0, 52, 50, 1, 0, 0, 0, 53, 54, 6, 3, -1, 0, 54, 55, 5, 2, 0, 0, 55, 109, 3, 6, 3, 13, 56, 109, 5, 12, 0, 0, 57, 58, 5, 12, 0, 0, 58, 59, 5, 7, 0, 0, 59, 109, 5, 12, 0, 0, 60, 109, 5, 10, 0, 0, 61, 62, 5, 3, 0, 0, 62, 63, 3, 6, 3, 0, 63, 64, 5, 4, 0, 0, 64, 109, 1, 0, 0, 0, 65, 66, 5, 12, 0, 0, 66, 67, 5, 3, 0, 0, 67, 68, 3, 6, 3, 0, 68, 69, 5, 4, 0, 0, 69, 109, 1, 0, 0, 0, 70, 71, 5, 12, 0, 0, 71, 72, 5, 16, 0, 0, 72, 77, 3, 2, 1, 0, 73, 74, 5, 8, 0, 0, 74, 76, 3, 2, 1, 0, 75, 73, 1, 0, 0, 0, 76, 79, 1, 0, 0, 0, 77, 75, 1, 0, 0, 0, 77, 78, 1, 0, 0, 0, 78, 80, 1, 0, 0, 0, 79, 77, 1, 0, 0, 0, 80, 81, 5, 17, 0, 0, 81, 109, 1, 0, 0, 0, 82, 83, 5, 12, 0, 0, 83, 84, 5, 16, 0, 0, 84, 89, 3, 6, 3, 0, 85, 86, 5, 8, 0, 0, 86, 88, 3, 6, 3, 0, 87, 85, 1, 0, 0, 0, 88, 91, 1, 0, 0, 0, 89, 87, 1, 0, 0, 0, 89, 90, 1, 0, 0, 0, 90, 92, 1, 0, 0, 0, 91, 89, 1, 0, 0, 0, 92, 93, 5, 17, 0, 0, 93, 109, 1, 0, 0, 0, 94, 95, 5, 12, 0, 0, 95, 96, 5, 16, 0, 0, 96, 97, 3, 2, 1, 0, 97, 98, 5, 9, 0, 0, 98, 99, 3, 2, 1, 0, 99, 100, 5, 17, 0, 0, 100, 109, 1, 0, 0, 0, 101, 102, 5, 12, 0, 0, 102, 103, 5, 16, 0, 0, 103, 104, 3, 6, 3, 0, 104, 105, 5, 9, 0, 0, 105, 106, 3, 6, 3, 0, 106, 107, 5, 17, 0, 0, 107, 109, 1, 0, 0, 0, 108, 53, 1, 0, 0, 0, 108, 56, 1, 0, 0, 0, 108, 57, 1, 0, 0, 0, 108, 60, 1, 0, 0, 0, 108, 61, 1, 0, 0, 0, 108, 65, 1, 0, 0, 0, 108, 70, 1, 0, 0, 0, 108, 82, 1, 0, 0, 0, 108, 94, 1, 0, 0, 0, 108, 101, 1, 0, 0, 0, 109, 121, 1, 0, 0, 0, 110, 111, 10, 12, 0, 0, 111, 112, 7, 1, 0, 0, 112, 120, 3, 6, 3, 13, 113, 114, 10, 11, 0, 0, 114, 115, 7, 0, 0, 0, 115, 120, 3, 6, 3, 12, 116, 117, 10, 10, 0, 0, 117, 118, 5, 13, 0, 0, 118, 120, 3, 6, 3, 11, 119, 110, 1, 0, 0, 0, 119, 113, 1, 0, 0, 0, 119, 116, 1, 0, 0, 0, 120, 123, 1, 0, 0, 0, 121, 119, 1, 0, 0, 0, 121, 122, 1, 0, 0, 0, 122, 7, 1, 0, 0, 0, 123, 121, 1, 0, 0, 0, 9, 13, 31, 48, 50, 77, 89, 108, 119, 121] \ No newline at end of file +[4, 1, 18, 125, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 35, 8, 1, 10, 1, 12, 1, 38, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 47, 8, 1, 10, 1, 12, 1, 50, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 68, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 79, 8, 1, 10, 1, 12, 1, 82, 9, 1, 1, 2, 1, 2, 3, 2, 86, 8, 2, 1, 3, 1, 3, 3, 3, 90, 8, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 3, 4, 100, 8, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 5, 4, 120, 8, 4, 10, 4, 12, 4, 123, 9, 4, 1, 4, 0, 2, 2, 8, 5, 0, 2, 4, 6, 8, 0, 2, 1, 0, 5, 6, 2, 0, 2, 2, 7, 7, 139, 0, 10, 1, 0, 0, 0, 2, 67, 1, 0, 0, 0, 4, 85, 1, 0, 0, 0, 6, 87, 1, 0, 0, 0, 8, 99, 1, 0, 0, 0, 10, 11, 3, 2, 1, 0, 11, 12, 5, 0, 0, 1, 12, 1, 1, 0, 0, 0, 13, 14, 6, 1, -1, 0, 14, 68, 3, 4, 2, 0, 15, 16, 5, 12, 0, 0, 16, 17, 5, 1, 0, 0, 17, 68, 5, 12, 0, 0, 18, 19, 5, 2, 0, 0, 19, 68, 3, 2, 1, 10, 20, 21, 5, 3, 0, 0, 21, 22, 3, 2, 1, 0, 22, 23, 5, 4, 0, 0, 23, 68, 1, 0, 0, 0, 24, 25, 5, 12, 0, 0, 25, 26, 5, 3, 0, 0, 26, 27, 3, 2, 1, 0, 27, 28, 5, 4, 0, 0, 28, 68, 1, 0, 0, 0, 29, 30, 5, 12, 0, 0, 30, 31, 5, 16, 0, 0, 31, 36, 3, 6, 3, 0, 32, 33, 5, 8, 0, 0, 33, 35, 3, 6, 3, 0, 34, 32, 1, 0, 0, 0, 35, 38, 1, 0, 0, 0, 36, 34, 1, 0, 0, 0, 36, 37, 1, 0, 0, 0, 37, 39, 1, 0, 0, 0, 38, 36, 1, 0, 0, 0, 39, 40, 5, 17, 0, 0, 40, 68, 1, 0, 0, 0, 41, 42, 5, 12, 0, 0, 42, 43, 5, 16, 0, 0, 43, 48, 3, 2, 1, 0, 44, 45, 5, 8, 0, 0, 45, 47, 3, 2, 1, 0, 46, 44, 1, 0, 0, 0, 47, 50, 1, 0, 0, 0, 48, 46, 1, 0, 0, 0, 48, 49, 1, 0, 0, 0, 49, 51, 1, 0, 0, 0, 50, 48, 1, 0, 0, 0, 51, 52, 5, 17, 0, 0, 52, 68, 1, 0, 0, 0, 53, 54, 5, 12, 0, 0, 54, 55, 5, 16, 0, 0, 55, 56, 3, 6, 3, 0, 56, 57, 5, 9, 0, 0, 57, 58, 3, 6, 3, 0, 58, 59, 5, 17, 0, 0, 59, 68, 1, 0, 0, 0, 60, 61, 5, 12, 0, 0, 61, 62, 5, 16, 0, 0, 62, 63, 3, 2, 1, 0, 63, 64, 5, 9, 0, 0, 64, 65, 3, 2, 1, 0, 65, 66, 5, 17, 0, 0, 66, 68, 1, 0, 0, 0, 67, 13, 1, 0, 0, 0, 67, 15, 1, 0, 0, 0, 67, 18, 1, 0, 0, 0, 67, 20, 1, 0, 0, 0, 67, 24, 1, 0, 0, 0, 67, 29, 1, 0, 0, 0, 67, 41, 1, 0, 0, 0, 67, 53, 1, 0, 0, 0, 67, 60, 1, 0, 0, 0, 68, 80, 1, 0, 0, 0, 69, 70, 10, 8, 0, 0, 70, 71, 7, 0, 0, 0, 71, 79, 3, 2, 1, 9, 72, 73, 10, 7, 0, 0, 73, 74, 7, 1, 0, 0, 74, 79, 3, 2, 1, 8, 75, 76, 10, 6, 0, 0, 76, 77, 5, 13, 0, 0, 77, 79, 3, 2, 1, 7, 78, 69, 1, 0, 0, 0, 78, 72, 1, 0, 0, 0, 78, 75, 1, 0, 0, 0, 79, 82, 1, 0, 0, 0, 80, 78, 1, 0, 0, 0, 80, 81, 1, 0, 0, 0, 81, 3, 1, 0, 0, 0, 82, 80, 1, 0, 0, 0, 83, 86, 5, 10, 0, 0, 84, 86, 5, 12, 0, 0, 85, 83, 1, 0, 0, 0, 85, 84, 1, 0, 0, 0, 86, 5, 1, 0, 0, 0, 87, 89, 5, 11, 0, 0, 88, 90, 3, 8, 4, 0, 89, 88, 1, 0, 0, 0, 89, 90, 1, 0, 0, 0, 90, 7, 1, 0, 0, 0, 91, 92, 6, 4, -1, 0, 92, 93, 7, 1, 0, 0, 93, 100, 3, 4, 2, 0, 94, 95, 7, 1, 0, 0, 95, 96, 5, 3, 0, 0, 96, 97, 3, 2, 1, 0, 97, 98, 5, 4, 0, 0, 98, 100, 1, 0, 0, 0, 99, 91, 1, 0, 0, 0, 99, 94, 1, 0, 0, 0, 100, 121, 1, 0, 0, 0, 101, 102, 10, 4, 0, 0, 102, 103, 7, 0, 0, 0, 103, 120, 3, 4, 2, 0, 104, 105, 10, 3, 0, 0, 105, 106, 7, 0, 0, 0, 106, 107, 5, 3, 0, 0, 107, 108, 3, 2, 1, 0, 108, 109, 5, 4, 0, 0, 109, 120, 1, 0, 0, 0, 110, 111, 10, 2, 0, 0, 111, 112, 7, 1, 0, 0, 112, 120, 3, 4, 2, 0, 113, 114, 10, 1, 0, 0, 114, 115, 7, 1, 0, 0, 115, 116, 5, 3, 0, 0, 116, 117, 3, 2, 1, 0, 117, 118, 5, 4, 0, 0, 118, 120, 1, 0, 0, 0, 119, 101, 1, 0, 0, 0, 119, 104, 1, 0, 0, 0, 119, 110, 1, 0, 0, 0, 119, 113, 1, 0, 0, 0, 120, 123, 1, 0, 0, 0, 121, 119, 1, 0, 0, 0, 121, 122, 1, 0, 0, 0, 122, 9, 1, 0, 0, 0, 123, 121, 1, 0, 0, 0, 10, 36, 48, 67, 78, 80, 85, 89, 99, 119, 121] \ No newline at end of file diff --git a/src/andromede/expression/parsing/antlr/Expr.tokens b/src/andromede/expression/parsing/antlr/Expr.tokens index a7df6308..b74895b7 100644 --- a/src/andromede/expression/parsing/antlr/Expr.tokens +++ b/src/andromede/expression/parsing/antlr/Expr.tokens @@ -16,13 +16,13 @@ MULDIV=15 LBRACKET=16 RBRACKET=17 WS=18 -'+'=1 +'.'=1 '-'=2 '('=3 ')'=4 '/'=5 '*'=6 -'.'=7 +'+'=7 ','=8 '..'=9 't'=11 diff --git a/src/andromede/expression/parsing/antlr/ExprLexer.interp b/src/andromede/expression/parsing/antlr/ExprLexer.interp index 8d45a225..1b29bde3 100644 --- a/src/andromede/expression/parsing/antlr/ExprLexer.interp +++ b/src/andromede/expression/parsing/antlr/ExprLexer.interp @@ -1,12 +1,12 @@ token literal names: null -'+' +'.' '-' '(' ')' '/' '*' -'.' +'+' ',' '..' null @@ -71,4 +71,4 @@ mode names: DEFAULT_MODE atn: -[4, 0, 18, 111, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 1, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 10, 1, 10, 1, 11, 1, 11, 3, 11, 69, 8, 11, 1, 12, 4, 12, 72, 8, 12, 11, 12, 12, 12, 73, 1, 12, 1, 12, 4, 12, 78, 8, 12, 11, 12, 12, 12, 79, 3, 12, 82, 8, 12, 1, 13, 1, 13, 1, 14, 1, 14, 5, 14, 88, 8, 14, 10, 14, 12, 14, 91, 9, 14, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 3, 15, 98, 8, 15, 1, 16, 1, 16, 1, 17, 1, 17, 1, 18, 1, 18, 1, 19, 1, 19, 1, 20, 1, 20, 1, 20, 1, 20, 0, 0, 21, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 0, 21, 0, 23, 0, 25, 10, 27, 11, 29, 12, 31, 13, 33, 14, 35, 15, 37, 16, 39, 17, 41, 18, 1, 0, 5, 1, 0, 48, 57, 3, 0, 65, 90, 95, 95, 97, 122, 2, 0, 43, 43, 45, 45, 2, 0, 42, 42, 47, 47, 3, 0, 9, 10, 13, 13, 32, 32, 114, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0, 0, 41, 1, 0, 0, 0, 1, 43, 1, 0, 0, 0, 3, 45, 1, 0, 0, 0, 5, 47, 1, 0, 0, 0, 7, 49, 1, 0, 0, 0, 9, 51, 1, 0, 0, 0, 11, 53, 1, 0, 0, 0, 13, 55, 1, 0, 0, 0, 15, 57, 1, 0, 0, 0, 17, 59, 1, 0, 0, 0, 19, 62, 1, 0, 0, 0, 21, 64, 1, 0, 0, 0, 23, 68, 1, 0, 0, 0, 25, 71, 1, 0, 0, 0, 27, 83, 1, 0, 0, 0, 29, 85, 1, 0, 0, 0, 31, 97, 1, 0, 0, 0, 33, 99, 1, 0, 0, 0, 35, 101, 1, 0, 0, 0, 37, 103, 1, 0, 0, 0, 39, 105, 1, 0, 0, 0, 41, 107, 1, 0, 0, 0, 43, 44, 5, 43, 0, 0, 44, 2, 1, 0, 0, 0, 45, 46, 5, 45, 0, 0, 46, 4, 1, 0, 0, 0, 47, 48, 5, 40, 0, 0, 48, 6, 1, 0, 0, 0, 49, 50, 5, 41, 0, 0, 50, 8, 1, 0, 0, 0, 51, 52, 5, 47, 0, 0, 52, 10, 1, 0, 0, 0, 53, 54, 5, 42, 0, 0, 54, 12, 1, 0, 0, 0, 55, 56, 5, 46, 0, 0, 56, 14, 1, 0, 0, 0, 57, 58, 5, 44, 0, 0, 58, 16, 1, 0, 0, 0, 59, 60, 5, 46, 0, 0, 60, 61, 5, 46, 0, 0, 61, 18, 1, 0, 0, 0, 62, 63, 7, 0, 0, 0, 63, 20, 1, 0, 0, 0, 64, 65, 7, 1, 0, 0, 65, 22, 1, 0, 0, 0, 66, 69, 3, 21, 10, 0, 67, 69, 3, 19, 9, 0, 68, 66, 1, 0, 0, 0, 68, 67, 1, 0, 0, 0, 69, 24, 1, 0, 0, 0, 70, 72, 3, 19, 9, 0, 71, 70, 1, 0, 0, 0, 72, 73, 1, 0, 0, 0, 73, 71, 1, 0, 0, 0, 73, 74, 1, 0, 0, 0, 74, 81, 1, 0, 0, 0, 75, 77, 5, 46, 0, 0, 76, 78, 3, 19, 9, 0, 77, 76, 1, 0, 0, 0, 78, 79, 1, 0, 0, 0, 79, 77, 1, 0, 0, 0, 79, 80, 1, 0, 0, 0, 80, 82, 1, 0, 0, 0, 81, 75, 1, 0, 0, 0, 81, 82, 1, 0, 0, 0, 82, 26, 1, 0, 0, 0, 83, 84, 5, 116, 0, 0, 84, 28, 1, 0, 0, 0, 85, 89, 3, 21, 10, 0, 86, 88, 3, 23, 11, 0, 87, 86, 1, 0, 0, 0, 88, 91, 1, 0, 0, 0, 89, 87, 1, 0, 0, 0, 89, 90, 1, 0, 0, 0, 90, 30, 1, 0, 0, 0, 91, 89, 1, 0, 0, 0, 92, 98, 5, 61, 0, 0, 93, 94, 5, 62, 0, 0, 94, 98, 5, 61, 0, 0, 95, 96, 5, 60, 0, 0, 96, 98, 5, 61, 0, 0, 97, 92, 1, 0, 0, 0, 97, 93, 1, 0, 0, 0, 97, 95, 1, 0, 0, 0, 98, 32, 1, 0, 0, 0, 99, 100, 7, 2, 0, 0, 100, 34, 1, 0, 0, 0, 101, 102, 7, 3, 0, 0, 102, 36, 1, 0, 0, 0, 103, 104, 5, 91, 0, 0, 104, 38, 1, 0, 0, 0, 105, 106, 5, 93, 0, 0, 106, 40, 1, 0, 0, 0, 107, 108, 7, 4, 0, 0, 108, 109, 1, 0, 0, 0, 109, 110, 6, 20, 0, 0, 110, 42, 1, 0, 0, 0, 7, 0, 68, 73, 79, 81, 89, 97, 1, 6, 0, 0] \ No newline at end of file +[4, 0, 18, 111, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 1, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 10, 1, 10, 1, 11, 1, 11, 3, 11, 69, 8, 11, 1, 12, 4, 12, 72, 8, 12, 11, 12, 12, 12, 73, 1, 12, 1, 12, 4, 12, 78, 8, 12, 11, 12, 12, 12, 79, 3, 12, 82, 8, 12, 1, 13, 1, 13, 1, 14, 1, 14, 5, 14, 88, 8, 14, 10, 14, 12, 14, 91, 9, 14, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 3, 15, 98, 8, 15, 1, 16, 1, 16, 1, 17, 1, 17, 1, 18, 1, 18, 1, 19, 1, 19, 1, 20, 1, 20, 1, 20, 1, 20, 0, 0, 21, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 0, 21, 0, 23, 0, 25, 10, 27, 11, 29, 12, 31, 13, 33, 14, 35, 15, 37, 16, 39, 17, 41, 18, 1, 0, 5, 1, 0, 48, 57, 3, 0, 65, 90, 95, 95, 97, 122, 2, 0, 43, 43, 45, 45, 2, 0, 42, 42, 47, 47, 3, 0, 9, 10, 13, 13, 32, 32, 114, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0, 0, 41, 1, 0, 0, 0, 1, 43, 1, 0, 0, 0, 3, 45, 1, 0, 0, 0, 5, 47, 1, 0, 0, 0, 7, 49, 1, 0, 0, 0, 9, 51, 1, 0, 0, 0, 11, 53, 1, 0, 0, 0, 13, 55, 1, 0, 0, 0, 15, 57, 1, 0, 0, 0, 17, 59, 1, 0, 0, 0, 19, 62, 1, 0, 0, 0, 21, 64, 1, 0, 0, 0, 23, 68, 1, 0, 0, 0, 25, 71, 1, 0, 0, 0, 27, 83, 1, 0, 0, 0, 29, 85, 1, 0, 0, 0, 31, 97, 1, 0, 0, 0, 33, 99, 1, 0, 0, 0, 35, 101, 1, 0, 0, 0, 37, 103, 1, 0, 0, 0, 39, 105, 1, 0, 0, 0, 41, 107, 1, 0, 0, 0, 43, 44, 5, 46, 0, 0, 44, 2, 1, 0, 0, 0, 45, 46, 5, 45, 0, 0, 46, 4, 1, 0, 0, 0, 47, 48, 5, 40, 0, 0, 48, 6, 1, 0, 0, 0, 49, 50, 5, 41, 0, 0, 50, 8, 1, 0, 0, 0, 51, 52, 5, 47, 0, 0, 52, 10, 1, 0, 0, 0, 53, 54, 5, 42, 0, 0, 54, 12, 1, 0, 0, 0, 55, 56, 5, 43, 0, 0, 56, 14, 1, 0, 0, 0, 57, 58, 5, 44, 0, 0, 58, 16, 1, 0, 0, 0, 59, 60, 5, 46, 0, 0, 60, 61, 5, 46, 0, 0, 61, 18, 1, 0, 0, 0, 62, 63, 7, 0, 0, 0, 63, 20, 1, 0, 0, 0, 64, 65, 7, 1, 0, 0, 65, 22, 1, 0, 0, 0, 66, 69, 3, 21, 10, 0, 67, 69, 3, 19, 9, 0, 68, 66, 1, 0, 0, 0, 68, 67, 1, 0, 0, 0, 69, 24, 1, 0, 0, 0, 70, 72, 3, 19, 9, 0, 71, 70, 1, 0, 0, 0, 72, 73, 1, 0, 0, 0, 73, 71, 1, 0, 0, 0, 73, 74, 1, 0, 0, 0, 74, 81, 1, 0, 0, 0, 75, 77, 5, 46, 0, 0, 76, 78, 3, 19, 9, 0, 77, 76, 1, 0, 0, 0, 78, 79, 1, 0, 0, 0, 79, 77, 1, 0, 0, 0, 79, 80, 1, 0, 0, 0, 80, 82, 1, 0, 0, 0, 81, 75, 1, 0, 0, 0, 81, 82, 1, 0, 0, 0, 82, 26, 1, 0, 0, 0, 83, 84, 5, 116, 0, 0, 84, 28, 1, 0, 0, 0, 85, 89, 3, 21, 10, 0, 86, 88, 3, 23, 11, 0, 87, 86, 1, 0, 0, 0, 88, 91, 1, 0, 0, 0, 89, 87, 1, 0, 0, 0, 89, 90, 1, 0, 0, 0, 90, 30, 1, 0, 0, 0, 91, 89, 1, 0, 0, 0, 92, 98, 5, 61, 0, 0, 93, 94, 5, 62, 0, 0, 94, 98, 5, 61, 0, 0, 95, 96, 5, 60, 0, 0, 96, 98, 5, 61, 0, 0, 97, 92, 1, 0, 0, 0, 97, 93, 1, 0, 0, 0, 97, 95, 1, 0, 0, 0, 98, 32, 1, 0, 0, 0, 99, 100, 7, 2, 0, 0, 100, 34, 1, 0, 0, 0, 101, 102, 7, 3, 0, 0, 102, 36, 1, 0, 0, 0, 103, 104, 5, 91, 0, 0, 104, 38, 1, 0, 0, 0, 105, 106, 5, 93, 0, 0, 106, 40, 1, 0, 0, 0, 107, 108, 7, 4, 0, 0, 108, 109, 1, 0, 0, 0, 109, 110, 6, 20, 0, 0, 110, 42, 1, 0, 0, 0, 7, 0, 68, 73, 79, 81, 89, 97, 1, 6, 0, 0] \ No newline at end of file diff --git a/src/andromede/expression/parsing/antlr/ExprLexer.py b/src/andromede/expression/parsing/antlr/ExprLexer.py index 4fd7b553..1ac100a1 100644 --- a/src/andromede/expression/parsing/antlr/ExprLexer.py +++ b/src/andromede/expression/parsing/antlr/ExprLexer.py @@ -565,7 +565,7 @@ def serializedATN(): 43, 44, 5, - 43, + 46, 0, 0, 44, @@ -637,7 +637,7 @@ def serializedATN(): 55, 56, 5, - 46, + 43, 0, 0, 56, @@ -1057,13 +1057,13 @@ class ExprLexer(Lexer): literalNames = [ "", - "'+'", + "'.'", "'-'", "'('", "')'", "'/'", "'*'", - "'.'", + "'+'", "','", "'..'", "'t'", diff --git a/src/andromede/expression/parsing/antlr/ExprLexer.tokens b/src/andromede/expression/parsing/antlr/ExprLexer.tokens index a7df6308..b74895b7 100644 --- a/src/andromede/expression/parsing/antlr/ExprLexer.tokens +++ b/src/andromede/expression/parsing/antlr/ExprLexer.tokens @@ -16,13 +16,13 @@ MULDIV=15 LBRACKET=16 RBRACKET=17 WS=18 -'+'=1 +'.'=1 '-'=2 '('=3 ')'=4 '/'=5 '*'=6 -'.'=7 +'+'=7 ','=8 '..'=9 't'=11 diff --git a/src/andromede/expression/parsing/antlr/ExprParser.py b/src/andromede/expression/parsing/antlr/ExprParser.py index c6f2b6a4..1d879619 100644 --- a/src/andromede/expression/parsing/antlr/ExprParser.py +++ b/src/andromede/expression/parsing/antlr/ExprParser.py @@ -33,6 +33,10 @@ def serializedATN(): 3, 7, 3, + 2, + 4, + 7, + 4, 1, 0, 1, @@ -43,575 +47,539 @@ def serializedATN(): 1, 1, 1, - 3, 1, - 14, - 8, 1, 1, - 2, 1, - 2, 1, - 2, 1, - 2, 1, - 2, 1, - 2, 1, - 2, 1, - 2, 1, - 2, 1, - 2, 1, - 2, 1, - 2, 1, - 2, 1, - 2, 1, - 2, 1, - 2, - 3, - 2, - 32, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 5, + 1, + 35, 8, - 2, 1, - 2, + 10, + 1, + 12, + 1, + 38, + 9, + 1, 1, - 2, 1, - 2, 1, - 2, 1, - 2, 1, - 2, 1, - 2, 1, - 2, 1, - 2, 1, - 2, 1, - 2, 1, - 2, 1, - 2, 1, - 2, 1, - 2, 5, - 2, - 49, + 1, + 47, 8, - 2, + 1, 10, - 2, + 1, 12, - 2, - 52, + 1, + 50, 9, - 2, 1, - 3, 1, - 3, 1, - 3, 1, - 3, 1, - 3, 1, - 3, 1, - 3, 1, - 3, 1, - 3, 1, - 3, 1, - 3, 1, - 3, 1, - 3, 1, - 3, 1, - 3, 1, - 3, 1, - 3, 1, - 3, 1, - 3, 1, - 3, 1, - 3, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, 1, 3, - 5, - 3, - 76, + 1, + 68, 8, - 3, - 10, - 3, - 12, - 3, - 79, - 9, - 3, 1, - 3, 1, - 3, 1, - 3, 1, - 3, 1, - 3, 1, - 3, 1, - 3, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, 5, - 3, - 88, + 1, + 79, 8, - 3, + 1, 10, - 3, + 1, 12, - 3, - 91, + 1, + 82, 9, - 3, 1, - 3, 1, - 3, + 2, 1, + 2, 3, + 2, + 86, + 8, + 2, 1, 3, 1, 3, - 1, 3, - 1, 3, - 1, + 90, + 8, 3, 1, - 3, + 4, 1, - 3, + 4, 1, - 3, + 4, 1, - 3, + 4, 1, - 3, + 4, 1, - 3, + 4, 1, - 3, + 4, 1, + 4, 3, - 3, - 3, - 109, + 4, + 100, 8, - 3, + 4, 1, - 3, + 4, 1, - 3, + 4, 1, - 3, + 4, 1, - 3, + 4, 1, - 3, + 4, 1, - 3, + 4, 1, - 3, + 4, 1, - 3, + 4, 1, - 3, + 4, + 1, + 4, + 1, + 4, + 1, + 4, + 1, + 4, + 1, + 4, + 1, + 4, + 1, + 4, + 1, + 4, + 1, + 4, 5, - 3, + 4, 120, 8, - 3, + 4, 10, - 3, + 4, 12, - 3, + 4, 123, 9, - 3, + 4, 1, - 3, + 4, 0, 2, - 4, - 6, - 4, + 2, + 8, + 5, 0, 2, 4, 6, + 8, 0, 2, 1, 0, - 1, - 2, - 1, - 0, 5, 6, - 142, + 2, 0, - 8, + 2, + 2, + 7, + 7, + 139, + 0, + 10, 1, 0, 0, 0, 2, - 11, + 67, 1, 0, 0, 0, 4, - 31, + 85, 1, 0, 0, 0, 6, - 108, + 87, 1, 0, 0, 0, 8, - 9, - 3, - 6, - 3, + 99, + 1, 0, - 9, - 10, - 5, 0, 0, - 1, 10, - 1, + 11, + 3, + 2, 1, 0, - 0, - 0, 11, - 13, + 12, 5, - 11, - 0, 0, - 12, - 14, - 3, - 4, - 2, 0, - 13, + 1, 12, 1, + 1, 0, 0, 0, 13, 14, + 6, 1, - 0, - 0, + -1, 0, 14, + 68, 3, - 1, - 0, - 0, + 4, + 2, 0, 15, 16, - 6, - 2, - -1, + 5, + 12, + 0, 0, 16, 17, - 7, - 0, + 5, + 1, 0, 0, 17, - 32, + 68, 5, - 10, + 12, 0, 0, 18, 19, - 7, - 0, - 0, - 0, - 19, - 32, 5, - 12, + 2, 0, 0, + 19, + 68, + 3, + 2, + 1, + 10, 20, 21, - 7, - 0, - 0, - 0, - 21, - 22, 5, 3, 0, 0, + 21, 22, - 23, - 3, - 6, 3, + 2, + 1, 0, + 22, 23, - 24, 5, 4, 0, 0, - 24, - 32, + 23, + 68, 1, 0, 0, 0, + 24, 25, - 26, - 7, - 0, - 0, - 0, - 26, - 27, 5, 12, 0, 0, - 27, - 28, + 25, + 26, 5, 3, 0, 0, - 28, - 29, - 3, - 6, + 26, + 27, 3, + 2, + 1, 0, - 29, - 30, + 27, + 28, 5, 4, 0, 0, - 30, - 32, + 28, + 68, 1, 0, 0, 0, - 31, - 15, - 1, - 0, + 29, + 30, + 5, + 12, 0, 0, + 30, 31, - 18, - 1, - 0, + 5, + 16, 0, 0, 31, - 20, - 1, - 0, - 0, + 36, + 3, + 6, + 3, 0, - 31, - 25, - 1, + 32, + 33, + 5, + 8, 0, 0, + 33, + 35, + 3, + 6, + 3, 0, + 34, 32, - 50, 1, 0, 0, 0, - 33, - 34, - 10, - 4, + 35, + 38, + 1, + 0, 0, 0, + 36, 34, - 35, - 7, 1, 0, 0, - 35, - 49, - 5, - 10, - 0, 0, 36, 37, - 10, - 3, + 1, + 0, 0, 0, 37, - 38, - 7, + 39, 1, 0, 0, + 0, 38, - 49, - 5, - 12, + 36, + 1, + 0, 0, 0, 39, 40, - 10, - 2, + 5, + 17, 0, 0, 40, - 41, - 7, + 68, 1, 0, 0, + 0, 41, 42, 5, - 3, + 12, 0, 0, 42, 43, - 3, - 6, - 3, - 0, - 43, - 44, 5, - 4, + 16, 0, 0, - 44, - 49, + 43, + 48, + 3, + 2, 1, 0, - 0, - 0, + 44, 45, - 46, - 10, - 1, - 0, - 0, - 46, - 47, - 7, - 0, + 5, + 8, 0, 0, + 45, 47, - 49, - 3, - 6, 3, + 2, + 1, 0, - 48, - 33, + 46, + 44, 1, 0, 0, 0, - 48, - 36, + 47, + 50, 1, 0, 0, 0, 48, - 39, + 46, 1, 0, 0, 0, 48, - 45, + 49, 1, 0, 0, 0, 49, - 52, + 51, 1, 0, 0, @@ -622,292 +590,352 @@ def serializedATN(): 0, 0, 0, - 50, 51, - 1, - 0, - 0, - 0, - 51, - 5, - 1, - 0, + 52, + 5, + 17, 0, 0, 52, - 50, + 68, 1, 0, 0, 0, 53, 54, - 6, - 3, - -1, + 5, + 12, + 0, 0, 54, 55, 5, - 2, + 16, 0, 0, 55, - 109, + 56, 3, 6, 3, - 13, + 0, 56, - 109, + 57, 5, - 12, + 9, 0, 0, 57, 58, - 5, - 12, - 0, + 3, + 6, + 3, 0, 58, 59, 5, - 7, + 17, 0, 0, 59, - 109, - 5, - 12, + 68, + 1, + 0, 0, 0, 60, - 109, + 61, 5, - 10, + 12, 0, 0, 61, 62, 5, - 3, + 16, 0, 0, 62, 63, 3, - 6, - 3, + 2, + 1, 0, 63, 64, 5, - 4, + 9, 0, 0, 64, - 109, + 65, + 3, + 2, 1, 0, - 0, - 0, 65, 66, 5, - 12, + 17, 0, 0, 66, + 68, + 1, + 0, + 0, + 0, 67, - 5, - 3, + 13, + 1, + 0, 0, 0, 67, - 68, - 3, - 6, - 3, + 15, + 1, 0, - 68, - 69, - 5, - 4, 0, 0, - 69, - 109, + 67, + 18, + 1, + 0, + 0, + 0, + 67, + 20, + 1, + 0, + 0, + 0, + 67, + 24, + 1, + 0, + 0, + 0, + 67, + 29, + 1, + 0, + 0, + 0, + 67, + 41, + 1, + 0, + 0, + 0, + 67, + 53, 1, 0, 0, 0, + 67, + 60, + 1, + 0, + 0, + 0, + 68, + 80, + 1, + 0, + 0, + 0, + 69, 70, - 71, - 5, - 12, + 10, + 8, 0, 0, + 70, 71, - 72, - 5, - 16, + 7, 0, 0, - 72, - 77, + 0, + 71, + 79, 3, 2, 1, + 9, + 72, + 73, + 10, + 7, + 0, 0, 73, 74, - 5, - 8, + 7, + 1, 0, 0, 74, - 76, + 79, 3, 2, 1, - 0, + 8, 75, - 73, - 1, - 0, + 76, + 10, + 6, 0, 0, 76, - 79, - 1, - 0, + 77, + 5, + 13, 0, 0, 77, - 75, + 79, + 3, + 2, + 1, + 7, + 78, + 69, 1, 0, 0, 0, - 77, 78, + 72, 1, 0, 0, 0, 78, - 80, + 75, 1, 0, 0, 0, 79, - 77, + 82, + 1, + 0, + 0, + 0, + 80, + 78, 1, 0, 0, 0, 80, 81, - 5, - 17, + 1, + 0, 0, 0, 81, - 109, + 3, 1, 0, 0, 0, 82, - 83, - 5, - 12, + 80, + 1, + 0, 0, 0, 83, - 84, + 86, 5, - 16, + 10, 0, 0, 84, - 89, - 3, - 6, - 3, - 0, - 85, 86, 5, - 8, - 0, + 12, 0, - 86, - 88, - 3, - 6, - 3, 0, - 87, 85, + 83, 1, 0, 0, 0, - 88, - 91, + 85, + 84, 1, 0, 0, 0, - 89, - 87, + 86, + 5, 1, 0, 0, 0, + 87, 89, + 5, + 11, + 0, + 0, + 88, 90, + 3, + 8, + 4, + 0, + 89, + 88, 1, 0, 0, 0, + 89, 90, - 92, 1, 0, 0, 0, - 91, - 89, + 90, + 7, 1, 0, 0, 0, + 91, 92, - 93, - 5, - 17, - 0, + 6, + 4, + -1, 0, + 92, 93, - 109, + 7, 1, 0, 0, - 0, + 93, + 100, + 3, + 4, + 2, + 0, 94, 95, - 5, - 12, + 7, + 1, 0, 0, 95, 96, 5, - 16, + 3, 0, 0, 96, @@ -919,131 +947,83 @@ def serializedATN(): 97, 98, 5, - 9, + 4, 0, 0, 98, + 100, + 1, + 0, + 0, + 0, 99, - 3, - 2, + 91, 1, 0, + 0, + 0, 99, - 100, - 5, - 17, + 94, + 1, + 0, 0, 0, 100, - 109, + 121, 1, 0, 0, 0, 101, 102, - 5, - 12, + 10, + 4, 0, 0, 102, 103, - 5, - 16, + 7, + 0, 0, 0, 103, - 104, - 3, - 6, + 120, 3, + 4, + 2, 0, 104, 105, - 5, - 9, + 10, + 3, 0, 0, 105, 106, - 3, - 6, - 3, + 7, + 0, + 0, 0, 106, 107, 5, - 17, + 3, 0, 0, 107, - 109, - 1, - 0, - 0, - 0, - 108, - 53, - 1, - 0, - 0, - 0, - 108, - 56, - 1, - 0, - 0, - 0, - 108, - 57, - 1, - 0, - 0, - 0, - 108, - 60, - 1, - 0, - 0, - 0, - 108, - 61, - 1, - 0, - 0, - 0, - 108, - 65, - 1, - 0, - 0, - 0, - 108, - 70, - 1, - 0, - 0, - 0, - 108, - 82, - 1, - 0, - 0, - 0, 108, - 94, + 3, + 2, 1, 0, - 0, - 0, 108, - 101, - 1, - 0, + 109, + 5, + 4, 0, 0, 109, - 121, + 120, 1, 0, 0, @@ -1051,7 +1031,7 @@ def serializedATN(): 110, 111, 10, - 12, + 2, 0, 0, 111, @@ -1063,59 +1043,65 @@ def serializedATN(): 112, 120, 3, - 6, - 3, - 13, + 4, + 2, + 0, 113, 114, 10, - 11, + 1, 0, 0, 114, 115, 7, - 0, + 1, 0, 0, 115, - 120, - 3, - 6, + 116, + 5, 3, - 12, + 0, + 0, 116, 117, - 10, - 10, - 0, + 3, + 2, + 1, 0, 117, 118, 5, - 13, + 4, 0, 0, 118, 120, - 3, - 6, - 3, - 11, + 1, + 0, + 0, + 0, 119, - 110, + 101, 1, 0, 0, 0, 119, - 113, + 104, 1, 0, 0, 0, 119, - 116, + 110, + 1, + 0, + 0, + 0, + 119, + 113, 1, 0, 0, @@ -1139,7 +1125,7 @@ def serializedATN(): 0, 0, 122, - 7, + 9, 1, 0, 0, @@ -1150,14 +1136,15 @@ def serializedATN(): 0, 0, 0, - 9, - 13, - 31, + 10, + 36, 48, - 50, - 77, + 67, + 78, + 80, + 85, 89, - 108, + 99, 119, 121, ] @@ -1174,13 +1161,13 @@ class ExprParser(Parser): literalNames = [ "", - "'+'", + "'.'", "'-'", "'('", "')'", "'/'", "'*'", - "'.'", + "'+'", "','", "'..'", "", @@ -1216,11 +1203,12 @@ class ExprParser(Parser): ] RULE_fullexpr = 0 - RULE_shift = 1 - RULE_shift_expr = 2 - RULE_expr = 3 + RULE_expr = 1 + RULE_atom = 2 + RULE_shift = 3 + RULE_shift_expr = 4 - ruleNames = ["fullexpr", "shift", "shift_expr", "expr"] + ruleNames = ["fullexpr", "expr", "atom", "shift", "shift_expr"] EOF = Token.EOF T__0 = 1 @@ -1279,57 +1267,10 @@ def fullexpr(self): self.enterRule(localctx, 0, self.RULE_fullexpr) try: self.enterOuterAlt(localctx, 1) - self.state = 8 + self.state = 10 self.expr(0) - self.state = 9 - self.match(ExprParser.EOF) - except RecognitionException as re: - localctx.exception = re - self._errHandler.reportError(self, re) - self._errHandler.recover(self, re) - finally: - self.exitRule() - return localctx - - class ShiftContext(ParserRuleContext): - __slots__ = "parser" - - def __init__( - self, parser, parent: ParserRuleContext = None, invokingState: int = -1 - ): - super().__init__(parent, invokingState) - self.parser = parser - - def TIME(self): - return self.getToken(ExprParser.TIME, 0) - - def shift_expr(self): - return self.getTypedRuleContext(ExprParser.Shift_exprContext, 0) - - def getRuleIndex(self): - return ExprParser.RULE_shift - - def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitShift"): - return visitor.visitShift(self) - else: - return visitor.visitChildren(self) - - def shift(self): - localctx = ExprParser.ShiftContext(self, self._ctx, self.state) - self.enterRule(localctx, 2, self.RULE_shift) - self._la = 0 # Token type - try: - self.enterOuterAlt(localctx, 1) self.state = 11 - self.match(ExprParser.TIME) - self.state = 13 - self._errHandler.sync(self) - _la = self._input.LA(1) - if _la == 1 or _la == 2: - self.state = 12 - self.shift_expr(0) - + self.match(ExprParser.EOF) except RecognitionException as re: localctx.exception = re self._errHandler.reportError(self, re) @@ -1338,7 +1279,7 @@ def shift(self): self.exitRule() return localctx - class Shift_exprContext(ParserRuleContext): + class ExprContext(ParserRuleContext): __slots__ = "parser" def __init__( @@ -1348,88 +1289,142 @@ def __init__( self.parser = parser def getRuleIndex(self): - return ExprParser.RULE_shift_expr + return ExprParser.RULE_expr def copyFrom(self, ctx: ParserRuleContext): super().copyFrom(ctx) - class ShiftMuldivIdentifierContext(Shift_exprContext): + class NegationContext(ExprContext): def __init__( self, parser, ctx: ParserRuleContext - ): # actually a ExprParser.Shift_exprContext + ): # actually a ExprParser.ExprContext super().__init__(parser) - self.op = None # Token self.copyFrom(ctx) - def shift_expr(self): - return self.getTypedRuleContext(ExprParser.Shift_exprContext, 0) - - def IDENTIFIER(self): - return self.getToken(ExprParser.IDENTIFIER, 0) + def expr(self): + return self.getTypedRuleContext(ExprParser.ExprContext, 0) def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitShiftMuldivIdentifier"): - return visitor.visitShiftMuldivIdentifier(self) + if hasattr(visitor, "visitNegation"): + return visitor.visitNegation(self) else: return visitor.visitChildren(self) - class SignedIdentifierContext(Shift_exprContext): + class UnsignedAtomContext(ExprContext): def __init__( self, parser, ctx: ParserRuleContext - ): # actually a ExprParser.Shift_exprContext + ): # actually a ExprParser.ExprContext super().__init__(parser) - self.op = None # Token self.copyFrom(ctx) - def IDENTIFIER(self): - return self.getToken(ExprParser.IDENTIFIER, 0) + def atom(self): + return self.getTypedRuleContext(ExprParser.AtomContext, 0) def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitSignedIdentifier"): - return visitor.visitSignedIdentifier(self) + if hasattr(visitor, "visitUnsignedAtom"): + return visitor.visitUnsignedAtom(self) else: return visitor.visitChildren(self) - class SignedExpressionContext(Shift_exprContext): + class ExpressionContext(ExprContext): def __init__( self, parser, ctx: ParserRuleContext - ): # actually a ExprParser.Shift_exprContext + ): # actually a ExprParser.ExprContext super().__init__(parser) - self.op = None # Token self.copyFrom(ctx) def expr(self): return self.getTypedRuleContext(ExprParser.ExprContext, 0) def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitSignedExpression"): - return visitor.visitSignedExpression(self) + if hasattr(visitor, "visitExpression"): + return visitor.visitExpression(self) else: return visitor.visitChildren(self) - class SignedNumberContext(Shift_exprContext): + class TimeIndexContext(ExprContext): def __init__( self, parser, ctx: ParserRuleContext - ): # actually a ExprParser.Shift_exprContext + ): # actually a ExprParser.ExprContext super().__init__(parser) - self.op = None # Token self.copyFrom(ctx) - def NUMBER(self): - return self.getToken(ExprParser.NUMBER, 0) + def IDENTIFIER(self): + return self.getToken(ExprParser.IDENTIFIER, 0) + + def LBRACKET(self): + return self.getToken(ExprParser.LBRACKET, 0) + + def expr(self, i: int = None): + if i is None: + return self.getTypedRuleContexts(ExprParser.ExprContext) + else: + return self.getTypedRuleContext(ExprParser.ExprContext, i) + + def RBRACKET(self): + return self.getToken(ExprParser.RBRACKET, 0) def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitSignedNumber"): - return visitor.visitSignedNumber(self) + if hasattr(visitor, "visitTimeIndex"): + return visitor.visitTimeIndex(self) else: return visitor.visitChildren(self) - class SignedFunctionContext(Shift_exprContext): + class ComparisonContext(ExprContext): def __init__( self, parser, ctx: ParserRuleContext - ): # actually a ExprParser.Shift_exprContext + ): # actually a ExprParser.ExprContext + super().__init__(parser) + self.copyFrom(ctx) + + def expr(self, i: int = None): + if i is None: + return self.getTypedRuleContexts(ExprParser.ExprContext) + else: + return self.getTypedRuleContext(ExprParser.ExprContext, i) + + def COMPARISON(self): + return self.getToken(ExprParser.COMPARISON, 0) + + def accept(self, visitor: ParseTreeVisitor): + if hasattr(visitor, "visitComparison"): + return visitor.visitComparison(self) + else: + return visitor.visitChildren(self) + + class TimeShiftContext(ExprContext): + def __init__( + self, parser, ctx: ParserRuleContext + ): # actually a ExprParser.ExprContext + super().__init__(parser) + self.copyFrom(ctx) + + def IDENTIFIER(self): + return self.getToken(ExprParser.IDENTIFIER, 0) + + def LBRACKET(self): + return self.getToken(ExprParser.LBRACKET, 0) + + def shift(self, i: int = None): + if i is None: + return self.getTypedRuleContexts(ExprParser.ShiftContext) + else: + return self.getTypedRuleContext(ExprParser.ShiftContext, i) + + def RBRACKET(self): + return self.getToken(ExprParser.RBRACKET, 0) + + def accept(self, visitor: ParseTreeVisitor): + if hasattr(visitor, "visitTimeShift"): + return visitor.visitTimeShift(self) + else: + return visitor.visitChildren(self) + + class FunctionContext(ExprContext): + def __init__( + self, parser, ctx: ParserRuleContext + ): # actually a ExprParser.ExprContext super().__init__(parser) - self.op = None # Token self.copyFrom(ctx) def IDENTIFIER(self): @@ -1439,189 +1434,313 @@ def expr(self): return self.getTypedRuleContext(ExprParser.ExprContext, 0) def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitSignedFunction"): - return visitor.visitSignedFunction(self) + if hasattr(visitor, "visitFunction"): + return visitor.visitFunction(self) else: return visitor.visitChildren(self) - class ShiftMuldivNumberContext(Shift_exprContext): + class AddsubContext(ExprContext): def __init__( self, parser, ctx: ParserRuleContext - ): # actually a ExprParser.Shift_exprContext + ): # actually a ExprParser.ExprContext super().__init__(parser) self.op = None # Token self.copyFrom(ctx) - def shift_expr(self): - return self.getTypedRuleContext(ExprParser.Shift_exprContext, 0) - - def NUMBER(self): - return self.getToken(ExprParser.NUMBER, 0) + def expr(self, i: int = None): + if i is None: + return self.getTypedRuleContexts(ExprParser.ExprContext) + else: + return self.getTypedRuleContext(ExprParser.ExprContext, i) def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitShiftMuldivNumber"): - return visitor.visitShiftMuldivNumber(self) + if hasattr(visitor, "visitAddsub"): + return visitor.visitAddsub(self) else: return visitor.visitChildren(self) - class ShiftMuldivContext(Shift_exprContext): + class TimeShiftRangeContext(ExprContext): def __init__( self, parser, ctx: ParserRuleContext - ): # actually a ExprParser.Shift_exprContext + ): # actually a ExprParser.ExprContext super().__init__(parser) - self.op = None # Token + self.shift1 = None # ShiftContext + self.shift2 = None # ShiftContext self.copyFrom(ctx) - def shift_expr(self): - return self.getTypedRuleContext(ExprParser.Shift_exprContext, 0) + def IDENTIFIER(self): + return self.getToken(ExprParser.IDENTIFIER, 0) - def expr(self): - return self.getTypedRuleContext(ExprParser.ExprContext, 0) + def LBRACKET(self): + return self.getToken(ExprParser.LBRACKET, 0) + + def RBRACKET(self): + return self.getToken(ExprParser.RBRACKET, 0) + + def shift(self, i: int = None): + if i is None: + return self.getTypedRuleContexts(ExprParser.ShiftContext) + else: + return self.getTypedRuleContext(ExprParser.ShiftContext, i) def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitShiftMuldiv"): - return visitor.visitShiftMuldiv(self) + if hasattr(visitor, "visitTimeShiftRange"): + return visitor.visitTimeShiftRange(self) else: return visitor.visitChildren(self) - class ShiftAddsubContext(Shift_exprContext): + class PortFieldContext(ExprContext): def __init__( self, parser, ctx: ParserRuleContext - ): # actually a ExprParser.Shift_exprContext + ): # actually a ExprParser.ExprContext + super().__init__(parser) + self.copyFrom(ctx) + + def IDENTIFIER(self, i: int = None): + if i is None: + return self.getTokens(ExprParser.IDENTIFIER) + else: + return self.getToken(ExprParser.IDENTIFIER, i) + + def accept(self, visitor: ParseTreeVisitor): + if hasattr(visitor, "visitPortField"): + return visitor.visitPortField(self) + else: + return visitor.visitChildren(self) + + class MuldivContext(ExprContext): + def __init__( + self, parser, ctx: ParserRuleContext + ): # actually a ExprParser.ExprContext super().__init__(parser) self.op = None # Token self.copyFrom(ctx) - def shift_expr(self): - return self.getTypedRuleContext(ExprParser.Shift_exprContext, 0) + def expr(self, i: int = None): + if i is None: + return self.getTypedRuleContexts(ExprParser.ExprContext) + else: + return self.getTypedRuleContext(ExprParser.ExprContext, i) - def expr(self): - return self.getTypedRuleContext(ExprParser.ExprContext, 0) + def accept(self, visitor: ParseTreeVisitor): + if hasattr(visitor, "visitMuldiv"): + return visitor.visitMuldiv(self) + else: + return visitor.visitChildren(self) + + class TimeRangeContext(ExprContext): + def __init__( + self, parser, ctx: ParserRuleContext + ): # actually a ExprParser.ExprContext + super().__init__(parser) + self.copyFrom(ctx) + + def IDENTIFIER(self): + return self.getToken(ExprParser.IDENTIFIER, 0) + + def LBRACKET(self): + return self.getToken(ExprParser.LBRACKET, 0) + + def expr(self, i: int = None): + if i is None: + return self.getTypedRuleContexts(ExprParser.ExprContext) + else: + return self.getTypedRuleContext(ExprParser.ExprContext, i) + + def RBRACKET(self): + return self.getToken(ExprParser.RBRACKET, 0) def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitShiftAddsub"): - return visitor.visitShiftAddsub(self) + if hasattr(visitor, "visitTimeRange"): + return visitor.visitTimeRange(self) else: return visitor.visitChildren(self) - def shift_expr(self, _p: int = 0): + def expr(self, _p: int = 0): _parentctx = self._ctx _parentState = self.state - localctx = ExprParser.Shift_exprContext(self, self._ctx, _parentState) + localctx = ExprParser.ExprContext(self, self._ctx, _parentState) _prevctx = localctx - _startState = 4 - self.enterRecursionRule(localctx, 4, self.RULE_shift_expr, _p) + _startState = 2 + self.enterRecursionRule(localctx, 2, self.RULE_expr, _p) self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 31 + self.state = 67 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input, 1, self._ctx) + la_ = self._interp.adaptivePredict(self._input, 2, self._ctx) if la_ == 1: - localctx = ExprParser.SignedNumberContext(self, localctx) + localctx = ExprParser.UnsignedAtomContext(self, localctx) self._ctx = localctx _prevctx = localctx + self.state = 14 + self.atom() + pass + + elif la_ == 2: + localctx = ExprParser.PortFieldContext(self, localctx) + self._ctx = localctx + _prevctx = localctx + self.state = 15 + self.match(ExprParser.IDENTIFIER) self.state = 16 - localctx.op = self._input.LT(1) - _la = self._input.LA(1) - if not (_la == 1 or _la == 2): - localctx.op = self._errHandler.recoverInline(self) - else: - self._errHandler.reportMatch(self) - self.consume() + self.match(ExprParser.T__0) self.state = 17 - self.match(ExprParser.NUMBER) + self.match(ExprParser.IDENTIFIER) pass - elif la_ == 2: - localctx = ExprParser.SignedIdentifierContext(self, localctx) + elif la_ == 3: + localctx = ExprParser.NegationContext(self, localctx) self._ctx = localctx _prevctx = localctx self.state = 18 - localctx.op = self._input.LT(1) - _la = self._input.LA(1) - if not (_la == 1 or _la == 2): - localctx.op = self._errHandler.recoverInline(self) - else: - self._errHandler.reportMatch(self) - self.consume() + self.match(ExprParser.T__1) self.state = 19 - self.match(ExprParser.IDENTIFIER) + self.expr(10) pass - elif la_ == 3: - localctx = ExprParser.SignedExpressionContext(self, localctx) + elif la_ == 4: + localctx = ExprParser.ExpressionContext(self, localctx) self._ctx = localctx _prevctx = localctx self.state = 20 - localctx.op = self._input.LT(1) - _la = self._input.LA(1) - if not (_la == 1 or _la == 2): - localctx.op = self._errHandler.recoverInline(self) - else: - self._errHandler.reportMatch(self) - self.consume() - self.state = 21 self.match(ExprParser.T__2) - self.state = 22 + self.state = 21 self.expr(0) - self.state = 23 + self.state = 22 self.match(ExprParser.T__3) pass - elif la_ == 4: - localctx = ExprParser.SignedFunctionContext(self, localctx) + elif la_ == 5: + localctx = ExprParser.FunctionContext(self, localctx) self._ctx = localctx _prevctx = localctx - self.state = 25 - localctx.op = self._input.LT(1) - _la = self._input.LA(1) - if not (_la == 1 or _la == 2): - localctx.op = self._errHandler.recoverInline(self) - else: - self._errHandler.reportMatch(self) - self.consume() - self.state = 26 + self.state = 24 self.match(ExprParser.IDENTIFIER) - self.state = 27 + self.state = 25 self.match(ExprParser.T__2) - self.state = 28 + self.state = 26 self.expr(0) - self.state = 29 + self.state = 27 self.match(ExprParser.T__3) pass + elif la_ == 6: + localctx = ExprParser.TimeShiftContext(self, localctx) + self._ctx = localctx + _prevctx = localctx + self.state = 29 + self.match(ExprParser.IDENTIFIER) + self.state = 30 + self.match(ExprParser.LBRACKET) + self.state = 31 + self.shift() + self.state = 36 + self._errHandler.sync(self) + _la = self._input.LA(1) + while _la == 8: + self.state = 32 + self.match(ExprParser.T__7) + self.state = 33 + self.shift() + self.state = 38 + self._errHandler.sync(self) + _la = self._input.LA(1) + + self.state = 39 + self.match(ExprParser.RBRACKET) + pass + + elif la_ == 7: + localctx = ExprParser.TimeIndexContext(self, localctx) + self._ctx = localctx + _prevctx = localctx + self.state = 41 + self.match(ExprParser.IDENTIFIER) + self.state = 42 + self.match(ExprParser.LBRACKET) + self.state = 43 + self.expr(0) + self.state = 48 + self._errHandler.sync(self) + _la = self._input.LA(1) + while _la == 8: + self.state = 44 + self.match(ExprParser.T__7) + self.state = 45 + self.expr(0) + self.state = 50 + self._errHandler.sync(self) + _la = self._input.LA(1) + + self.state = 51 + self.match(ExprParser.RBRACKET) + pass + + elif la_ == 8: + localctx = ExprParser.TimeShiftRangeContext(self, localctx) + self._ctx = localctx + _prevctx = localctx + self.state = 53 + self.match(ExprParser.IDENTIFIER) + self.state = 54 + self.match(ExprParser.LBRACKET) + self.state = 55 + localctx.shift1 = self.shift() + self.state = 56 + self.match(ExprParser.T__8) + self.state = 57 + localctx.shift2 = self.shift() + self.state = 58 + self.match(ExprParser.RBRACKET) + pass + + elif la_ == 9: + localctx = ExprParser.TimeRangeContext(self, localctx) + self._ctx = localctx + _prevctx = localctx + self.state = 60 + self.match(ExprParser.IDENTIFIER) + self.state = 61 + self.match(ExprParser.LBRACKET) + self.state = 62 + self.expr(0) + self.state = 63 + self.match(ExprParser.T__8) + self.state = 64 + self.expr(0) + self.state = 65 + self.match(ExprParser.RBRACKET) + pass + self._ctx.stop = self._input.LT(-1) - self.state = 50 + self.state = 80 self._errHandler.sync(self) - _alt = self._interp.adaptivePredict(self._input, 3, self._ctx) + _alt = self._interp.adaptivePredict(self._input, 4, self._ctx) while _alt != 2 and _alt != ATN.INVALID_ALT_NUMBER: if _alt == 1: if self._parseListeners is not None: self.triggerExitRuleEvent() _prevctx = localctx - self.state = 48 + self.state = 78 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input, 2, self._ctx) + la_ = self._interp.adaptivePredict(self._input, 3, self._ctx) if la_ == 1: - localctx = ExprParser.ShiftMuldivNumberContext( - self, - ExprParser.Shift_exprContext( - self, _parentctx, _parentState - ), + localctx = ExprParser.MuldivContext( + self, ExprParser.ExprContext(self, _parentctx, _parentState) ) self.pushNewRecursionContext( - localctx, _startState, self.RULE_shift_expr + localctx, _startState, self.RULE_expr ) - self.state = 33 - if not self.precpred(self._ctx, 4): + self.state = 69 + if not self.precpred(self._ctx, 8): from antlr4.error.Errors import FailedPredicateException raise FailedPredicateException( - self, "self.precpred(self._ctx, 4)" + self, "self.precpred(self._ctx, 8)" ) - self.state = 34 + self.state = 70 localctx.op = self._input.LT(1) _la = self._input.LA(1) if not (_la == 5 or _la == 6): @@ -1629,104 +1748,59 @@ def shift_expr(self, _p: int = 0): else: self._errHandler.reportMatch(self) self.consume() - self.state = 35 - self.match(ExprParser.NUMBER) + self.state = 71 + self.expr(9) pass elif la_ == 2: - localctx = ExprParser.ShiftMuldivIdentifierContext( - self, - ExprParser.Shift_exprContext( - self, _parentctx, _parentState - ), + localctx = ExprParser.AddsubContext( + self, ExprParser.ExprContext(self, _parentctx, _parentState) ) self.pushNewRecursionContext( - localctx, _startState, self.RULE_shift_expr + localctx, _startState, self.RULE_expr ) - self.state = 36 - if not self.precpred(self._ctx, 3): + self.state = 72 + if not self.precpred(self._ctx, 7): from antlr4.error.Errors import FailedPredicateException raise FailedPredicateException( - self, "self.precpred(self._ctx, 3)" + self, "self.precpred(self._ctx, 7)" ) - self.state = 37 + self.state = 73 localctx.op = self._input.LT(1) _la = self._input.LA(1) - if not (_la == 5 or _la == 6): + if not (_la == 2 or _la == 7): localctx.op = self._errHandler.recoverInline(self) else: self._errHandler.reportMatch(self) self.consume() - self.state = 38 - self.match(ExprParser.IDENTIFIER) + self.state = 74 + self.expr(8) pass elif la_ == 3: - localctx = ExprParser.ShiftMuldivContext( - self, - ExprParser.Shift_exprContext( - self, _parentctx, _parentState - ), - ) - self.pushNewRecursionContext( - localctx, _startState, self.RULE_shift_expr - ) - self.state = 39 - if not self.precpred(self._ctx, 2): - from antlr4.error.Errors import FailedPredicateException - - raise FailedPredicateException( - self, "self.precpred(self._ctx, 2)" - ) - self.state = 40 - localctx.op = self._input.LT(1) - _la = self._input.LA(1) - if not (_la == 5 or _la == 6): - localctx.op = self._errHandler.recoverInline(self) - else: - self._errHandler.reportMatch(self) - self.consume() - self.state = 41 - self.match(ExprParser.T__2) - self.state = 42 - self.expr(0) - self.state = 43 - self.match(ExprParser.T__3) - pass - - elif la_ == 4: - localctx = ExprParser.ShiftAddsubContext( - self, - ExprParser.Shift_exprContext( - self, _parentctx, _parentState - ), + localctx = ExprParser.ComparisonContext( + self, ExprParser.ExprContext(self, _parentctx, _parentState) ) self.pushNewRecursionContext( - localctx, _startState, self.RULE_shift_expr + localctx, _startState, self.RULE_expr ) - self.state = 45 - if not self.precpred(self._ctx, 1): + self.state = 75 + if not self.precpred(self._ctx, 6): from antlr4.error.Errors import FailedPredicateException raise FailedPredicateException( - self, "self.precpred(self._ctx, 1)" + self, "self.precpred(self._ctx, 6)" ) - self.state = 46 - localctx.op = self._input.LT(1) - _la = self._input.LA(1) - if not (_la == 1 or _la == 2): - localctx.op = self._errHandler.recoverInline(self) - else: - self._errHandler.reportMatch(self) - self.consume() - self.state = 47 - self.expr(0) + self.state = 76 + self.match(ExprParser.COMPARISON) + self.state = 77 + self.expr(7) pass - self.state = 52 + self.state = 82 self._errHandler.sync(self) - _alt = self._interp.adaptivePredict(self._input, 3, self._ctx) + _alt = self._interp.adaptivePredict(self._input, 4, self._ctx) except RecognitionException as re: localctx.exception = re @@ -1736,7 +1810,7 @@ def shift_expr(self, _p: int = 0): self.unrollRecursionContexts(_parentctx) return localctx - class ExprContext(ParserRuleContext): + class AtomContext(ParserRuleContext): __slots__ = "parser" def __init__( @@ -1746,459 +1820,303 @@ def __init__( self.parser = parser def getRuleIndex(self): - return ExprParser.RULE_expr + return ExprParser.RULE_atom def copyFrom(self, ctx: ParserRuleContext): super().copyFrom(ctx) - class IdentifierContext(ExprContext): + class NumberContext(AtomContext): def __init__( self, parser, ctx: ParserRuleContext - ): # actually a ExprParser.ExprContext + ): # actually a ExprParser.AtomContext super().__init__(parser) self.copyFrom(ctx) - def IDENTIFIER(self): - return self.getToken(ExprParser.IDENTIFIER, 0) + def NUMBER(self): + return self.getToken(ExprParser.NUMBER, 0) def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitIdentifier"): - return visitor.visitIdentifier(self) + if hasattr(visitor, "visitNumber"): + return visitor.visitNumber(self) else: return visitor.visitChildren(self) - class NegationContext(ExprContext): + class IdentifierContext(AtomContext): def __init__( self, parser, ctx: ParserRuleContext - ): # actually a ExprParser.ExprContext + ): # actually a ExprParser.AtomContext super().__init__(parser) self.copyFrom(ctx) - def expr(self): - return self.getTypedRuleContext(ExprParser.ExprContext, 0) + def IDENTIFIER(self): + return self.getToken(ExprParser.IDENTIFIER, 0) def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitNegation"): - return visitor.visitNegation(self) + if hasattr(visitor, "visitIdentifier"): + return visitor.visitIdentifier(self) else: return visitor.visitChildren(self) - class ExpressionContext(ExprContext): - def __init__( - self, parser, ctx: ParserRuleContext - ): # actually a ExprParser.ExprContext - super().__init__(parser) - self.copyFrom(ctx) - - def expr(self): - return self.getTypedRuleContext(ExprParser.ExprContext, 0) - - def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitExpression"): - return visitor.visitExpression(self) + def atom(self): + localctx = ExprParser.AtomContext(self, self._ctx, self.state) + self.enterRule(localctx, 4, self.RULE_atom) + try: + self.state = 85 + self._errHandler.sync(self) + token = self._input.LA(1) + if token in [10]: + localctx = ExprParser.NumberContext(self, localctx) + self.enterOuterAlt(localctx, 1) + self.state = 83 + self.match(ExprParser.NUMBER) + pass + elif token in [12]: + localctx = ExprParser.IdentifierContext(self, localctx) + self.enterOuterAlt(localctx, 2) + self.state = 84 + self.match(ExprParser.IDENTIFIER) + pass else: - return visitor.visitChildren(self) + raise NoViableAltException(self) - class ComparisonContext(ExprContext): - def __init__( - self, parser, ctx: ParserRuleContext - ): # actually a ExprParser.ExprContext - super().__init__(parser) - self.copyFrom(ctx) + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx - def expr(self, i: int = None): - if i is None: - return self.getTypedRuleContexts(ExprParser.ExprContext) - else: - return self.getTypedRuleContext(ExprParser.ExprContext, i) + class ShiftContext(ParserRuleContext): + __slots__ = "parser" - def COMPARISON(self): - return self.getToken(ExprParser.COMPARISON, 0) + def __init__( + self, parser, parent: ParserRuleContext = None, invokingState: int = -1 + ): + super().__init__(parent, invokingState) + self.parser = parser - def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitComparison"): - return visitor.visitComparison(self) - else: - return visitor.visitChildren(self) + def TIME(self): + return self.getToken(ExprParser.TIME, 0) - class AddsubContext(ExprContext): - def __init__( - self, parser, ctx: ParserRuleContext - ): # actually a ExprParser.ExprContext - super().__init__(parser) - self.op = None # Token - self.copyFrom(ctx) + def shift_expr(self): + return self.getTypedRuleContext(ExprParser.Shift_exprContext, 0) - def expr(self, i: int = None): - if i is None: - return self.getTypedRuleContexts(ExprParser.ExprContext) - else: - return self.getTypedRuleContext(ExprParser.ExprContext, i) + def getRuleIndex(self): + return ExprParser.RULE_shift def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitAddsub"): - return visitor.visitAddsub(self) + if hasattr(visitor, "visitShift"): + return visitor.visitShift(self) else: return visitor.visitChildren(self) - class PortFieldContext(ExprContext): - def __init__( - self, parser, ctx: ParserRuleContext - ): # actually a ExprParser.ExprContext - super().__init__(parser) - self.copyFrom(ctx) + def shift(self): + localctx = ExprParser.ShiftContext(self, self._ctx, self.state) + self.enterRule(localctx, 6, self.RULE_shift) + self._la = 0 # Token type + try: + self.enterOuterAlt(localctx, 1) + self.state = 87 + self.match(ExprParser.TIME) + self.state = 89 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la == 2 or _la == 7: + self.state = 88 + self.shift_expr(0) - def IDENTIFIER(self, i: int = None): - if i is None: - return self.getTokens(ExprParser.IDENTIFIER) - else: - return self.getToken(ExprParser.IDENTIFIER, i) + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx - def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitPortField"): - return visitor.visitPortField(self) - else: - return visitor.visitChildren(self) + class Shift_exprContext(ParserRuleContext): + __slots__ = "parser" - class MuldivContext(ExprContext): def __init__( - self, parser, ctx: ParserRuleContext - ): # actually a ExprParser.ExprContext - super().__init__(parser) - self.op = None # Token - self.copyFrom(ctx) + self, parser, parent: ParserRuleContext = None, invokingState: int = -1 + ): + super().__init__(parent, invokingState) + self.parser = parser - def expr(self, i: int = None): - if i is None: - return self.getTypedRuleContexts(ExprParser.ExprContext) - else: - return self.getTypedRuleContext(ExprParser.ExprContext, i) + def getRuleIndex(self): + return ExprParser.RULE_shift_expr - def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitMuldiv"): - return visitor.visitMuldiv(self) - else: - return visitor.visitChildren(self) + def copyFrom(self, ctx: ParserRuleContext): + super().copyFrom(ctx) - class NumberContext(ExprContext): + class SignedAtomContext(Shift_exprContext): def __init__( self, parser, ctx: ParserRuleContext - ): # actually a ExprParser.ExprContext + ): # actually a ExprParser.Shift_exprContext super().__init__(parser) + self.op = None # Token self.copyFrom(ctx) - def NUMBER(self): - return self.getToken(ExprParser.NUMBER, 0) + def atom(self): + return self.getTypedRuleContext(ExprParser.AtomContext, 0) def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitNumber"): - return visitor.visitNumber(self) + if hasattr(visitor, "visitSignedAtom"): + return visitor.visitSignedAtom(self) else: return visitor.visitChildren(self) - class TimeIndexContext(ExprContext): + class SignedExpressionContext(Shift_exprContext): def __init__( self, parser, ctx: ParserRuleContext - ): # actually a ExprParser.ExprContext + ): # actually a ExprParser.Shift_exprContext super().__init__(parser) + self.op = None # Token self.copyFrom(ctx) - def IDENTIFIER(self): - return self.getToken(ExprParser.IDENTIFIER, 0) - - def LBRACKET(self): - return self.getToken(ExprParser.LBRACKET, 0) - - def expr(self, i: int = None): - if i is None: - return self.getTypedRuleContexts(ExprParser.ExprContext) - else: - return self.getTypedRuleContext(ExprParser.ExprContext, i) - - def RBRACKET(self): - return self.getToken(ExprParser.RBRACKET, 0) + def expr(self): + return self.getTypedRuleContext(ExprParser.ExprContext, 0) def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitTimeIndex"): - return visitor.visitTimeIndex(self) + if hasattr(visitor, "visitSignedExpression"): + return visitor.visitSignedExpression(self) else: return visitor.visitChildren(self) - class TimeShiftContext(ExprContext): + class ShiftMuldivAtomContext(Shift_exprContext): def __init__( self, parser, ctx: ParserRuleContext - ): # actually a ExprParser.ExprContext + ): # actually a ExprParser.Shift_exprContext super().__init__(parser) + self.op = None # Token self.copyFrom(ctx) - def IDENTIFIER(self): - return self.getToken(ExprParser.IDENTIFIER, 0) - - def LBRACKET(self): - return self.getToken(ExprParser.LBRACKET, 0) - - def shift(self, i: int = None): - if i is None: - return self.getTypedRuleContexts(ExprParser.ShiftContext) - else: - return self.getTypedRuleContext(ExprParser.ShiftContext, i) + def shift_expr(self): + return self.getTypedRuleContext(ExprParser.Shift_exprContext, 0) - def RBRACKET(self): - return self.getToken(ExprParser.RBRACKET, 0) + def atom(self): + return self.getTypedRuleContext(ExprParser.AtomContext, 0) def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitTimeShift"): - return visitor.visitTimeShift(self) + if hasattr(visitor, "visitShiftMuldivAtom"): + return visitor.visitShiftMuldivAtom(self) else: return visitor.visitChildren(self) - class FunctionContext(ExprContext): + class ShiftMuldivContext(Shift_exprContext): def __init__( self, parser, ctx: ParserRuleContext - ): # actually a ExprParser.ExprContext + ): # actually a ExprParser.Shift_exprContext super().__init__(parser) + self.op = None # Token self.copyFrom(ctx) - def IDENTIFIER(self): - return self.getToken(ExprParser.IDENTIFIER, 0) + def shift_expr(self): + return self.getTypedRuleContext(ExprParser.Shift_exprContext, 0) def expr(self): return self.getTypedRuleContext(ExprParser.ExprContext, 0) def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitFunction"): - return visitor.visitFunction(self) + if hasattr(visitor, "visitShiftMuldiv"): + return visitor.visitShiftMuldiv(self) else: return visitor.visitChildren(self) - class TimeShiftRangeContext(ExprContext): + class ShiftAddsubContext(Shift_exprContext): def __init__( self, parser, ctx: ParserRuleContext - ): # actually a ExprParser.ExprContext + ): # actually a ExprParser.Shift_exprContext super().__init__(parser) - self.shift1 = None # ShiftContext - self.shift2 = None # ShiftContext + self.op = None # Token self.copyFrom(ctx) - def IDENTIFIER(self): - return self.getToken(ExprParser.IDENTIFIER, 0) - - def LBRACKET(self): - return self.getToken(ExprParser.LBRACKET, 0) - - def RBRACKET(self): - return self.getToken(ExprParser.RBRACKET, 0) - - def shift(self, i: int = None): - if i is None: - return self.getTypedRuleContexts(ExprParser.ShiftContext) - else: - return self.getTypedRuleContext(ExprParser.ShiftContext, i) + def shift_expr(self): + return self.getTypedRuleContext(ExprParser.Shift_exprContext, 0) + + def expr(self): + return self.getTypedRuleContext(ExprParser.ExprContext, 0) def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitTimeShiftRange"): - return visitor.visitTimeShiftRange(self) + if hasattr(visitor, "visitShiftAddsub"): + return visitor.visitShiftAddsub(self) else: return visitor.visitChildren(self) - class TimeRangeContext(ExprContext): + class ShiftAddsubAtomContext(Shift_exprContext): def __init__( self, parser, ctx: ParserRuleContext - ): # actually a ExprParser.ExprContext + ): # actually a ExprParser.Shift_exprContext super().__init__(parser) + self.op = None # Token self.copyFrom(ctx) - def IDENTIFIER(self): - return self.getToken(ExprParser.IDENTIFIER, 0) - - def LBRACKET(self): - return self.getToken(ExprParser.LBRACKET, 0) - - def expr(self, i: int = None): - if i is None: - return self.getTypedRuleContexts(ExprParser.ExprContext) - else: - return self.getTypedRuleContext(ExprParser.ExprContext, i) + def shift_expr(self): + return self.getTypedRuleContext(ExprParser.Shift_exprContext, 0) - def RBRACKET(self): - return self.getToken(ExprParser.RBRACKET, 0) + def atom(self): + return self.getTypedRuleContext(ExprParser.AtomContext, 0) def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitTimeRange"): - return visitor.visitTimeRange(self) + if hasattr(visitor, "visitShiftAddsubAtom"): + return visitor.visitShiftAddsubAtom(self) else: return visitor.visitChildren(self) - def expr(self, _p: int = 0): + def shift_expr(self, _p: int = 0): _parentctx = self._ctx _parentState = self.state - localctx = ExprParser.ExprContext(self, self._ctx, _parentState) + localctx = ExprParser.Shift_exprContext(self, self._ctx, _parentState) _prevctx = localctx - _startState = 6 - self.enterRecursionRule(localctx, 6, self.RULE_expr, _p) + _startState = 8 + self.enterRecursionRule(localctx, 8, self.RULE_shift_expr, _p) self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 108 + self.state = 99 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input, 6, self._ctx) + la_ = self._interp.adaptivePredict(self._input, 7, self._ctx) if la_ == 1: - localctx = ExprParser.NegationContext(self, localctx) - self._ctx = localctx - _prevctx = localctx - - self.state = 54 - self.match(ExprParser.T__1) - self.state = 55 - self.expr(13) - pass - - elif la_ == 2: - localctx = ExprParser.IdentifierContext(self, localctx) - self._ctx = localctx - _prevctx = localctx - self.state = 56 - self.match(ExprParser.IDENTIFIER) - pass - - elif la_ == 3: - localctx = ExprParser.PortFieldContext(self, localctx) - self._ctx = localctx - _prevctx = localctx - self.state = 57 - self.match(ExprParser.IDENTIFIER) - self.state = 58 - self.match(ExprParser.T__6) - self.state = 59 - self.match(ExprParser.IDENTIFIER) - pass - - elif la_ == 4: - localctx = ExprParser.NumberContext(self, localctx) - self._ctx = localctx - _prevctx = localctx - self.state = 60 - self.match(ExprParser.NUMBER) - pass - - elif la_ == 5: - localctx = ExprParser.ExpressionContext(self, localctx) - self._ctx = localctx - _prevctx = localctx - self.state = 61 - self.match(ExprParser.T__2) - self.state = 62 - self.expr(0) - self.state = 63 - self.match(ExprParser.T__3) - pass - - elif la_ == 6: - localctx = ExprParser.FunctionContext(self, localctx) - self._ctx = localctx - _prevctx = localctx - self.state = 65 - self.match(ExprParser.IDENTIFIER) - self.state = 66 - self.match(ExprParser.T__2) - self.state = 67 - self.expr(0) - self.state = 68 - self.match(ExprParser.T__3) - pass - - elif la_ == 7: - localctx = ExprParser.TimeShiftContext(self, localctx) - self._ctx = localctx - _prevctx = localctx - self.state = 70 - self.match(ExprParser.IDENTIFIER) - self.state = 71 - self.match(ExprParser.LBRACKET) - self.state = 72 - self.shift() - self.state = 77 - self._errHandler.sync(self) - _la = self._input.LA(1) - while _la == 8: - self.state = 73 - self.match(ExprParser.T__7) - self.state = 74 - self.shift() - self.state = 79 - self._errHandler.sync(self) - _la = self._input.LA(1) - - self.state = 80 - self.match(ExprParser.RBRACKET) - pass - - elif la_ == 8: - localctx = ExprParser.TimeIndexContext(self, localctx) + localctx = ExprParser.SignedAtomContext(self, localctx) self._ctx = localctx _prevctx = localctx - self.state = 82 - self.match(ExprParser.IDENTIFIER) - self.state = 83 - self.match(ExprParser.LBRACKET) - self.state = 84 - self.expr(0) - self.state = 89 - self._errHandler.sync(self) - _la = self._input.LA(1) - while _la == 8: - self.state = 85 - self.match(ExprParser.T__7) - self.state = 86 - self.expr(0) - self.state = 91 - self._errHandler.sync(self) - _la = self._input.LA(1) self.state = 92 - self.match(ExprParser.RBRACKET) + localctx.op = self._input.LT(1) + _la = self._input.LA(1) + if not (_la == 2 or _la == 7): + localctx.op = self._errHandler.recoverInline(self) + else: + self._errHandler.reportMatch(self) + self.consume() + self.state = 93 + self.atom() pass - elif la_ == 9: - localctx = ExprParser.TimeShiftRangeContext(self, localctx) + elif la_ == 2: + localctx = ExprParser.SignedExpressionContext(self, localctx) self._ctx = localctx _prevctx = localctx self.state = 94 - self.match(ExprParser.IDENTIFIER) + localctx.op = self._input.LT(1) + _la = self._input.LA(1) + if not (_la == 2 or _la == 7): + localctx.op = self._errHandler.recoverInline(self) + else: + self._errHandler.reportMatch(self) + self.consume() self.state = 95 - self.match(ExprParser.LBRACKET) + self.match(ExprParser.T__2) self.state = 96 - localctx.shift1 = self.shift() - self.state = 97 - self.match(ExprParser.T__8) - self.state = 98 - localctx.shift2 = self.shift() - self.state = 99 - self.match(ExprParser.RBRACKET) - pass - - elif la_ == 10: - localctx = ExprParser.TimeRangeContext(self, localctx) - self._ctx = localctx - _prevctx = localctx - self.state = 101 - self.match(ExprParser.IDENTIFIER) - self.state = 102 - self.match(ExprParser.LBRACKET) - self.state = 103 self.expr(0) - self.state = 104 - self.match(ExprParser.T__8) - self.state = 105 - self.expr(0) - self.state = 106 - self.match(ExprParser.RBRACKET) + self.state = 97 + self.match(ExprParser.T__3) pass self._ctx.stop = self._input.LT(-1) self.state = 121 self._errHandler.sync(self) - _alt = self._interp.adaptivePredict(self._input, 8, self._ctx) + _alt = self._interp.adaptivePredict(self._input, 9, self._ctx) while _alt != 2 and _alt != ATN.INVALID_ALT_NUMBER: if _alt == 1: if self._parseListeners is not None: @@ -2206,22 +2124,25 @@ def expr(self, _p: int = 0): _prevctx = localctx self.state = 119 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input, 7, self._ctx) + la_ = self._interp.adaptivePredict(self._input, 8, self._ctx) if la_ == 1: - localctx = ExprParser.MuldivContext( - self, ExprParser.ExprContext(self, _parentctx, _parentState) + localctx = ExprParser.ShiftMuldivAtomContext( + self, + ExprParser.Shift_exprContext( + self, _parentctx, _parentState + ), ) self.pushNewRecursionContext( - localctx, _startState, self.RULE_expr + localctx, _startState, self.RULE_shift_expr ) - self.state = 110 - if not self.precpred(self._ctx, 12): + self.state = 101 + if not self.precpred(self._ctx, 4): from antlr4.error.Errors import FailedPredicateException raise FailedPredicateException( - self, "self.precpred(self._ctx, 12)" + self, "self.precpred(self._ctx, 4)" ) - self.state = 111 + self.state = 102 localctx.op = self._input.LT(1) _la = self._input.LA(1) if not (_la == 5 or _la == 6): @@ -2229,59 +2150,108 @@ def expr(self, _p: int = 0): else: self._errHandler.reportMatch(self) self.consume() - self.state = 112 - self.expr(13) + self.state = 103 + self.atom() pass elif la_ == 2: - localctx = ExprParser.AddsubContext( - self, ExprParser.ExprContext(self, _parentctx, _parentState) + localctx = ExprParser.ShiftMuldivContext( + self, + ExprParser.Shift_exprContext( + self, _parentctx, _parentState + ), ) self.pushNewRecursionContext( - localctx, _startState, self.RULE_expr + localctx, _startState, self.RULE_shift_expr ) - self.state = 113 - if not self.precpred(self._ctx, 11): + self.state = 104 + if not self.precpred(self._ctx, 3): from antlr4.error.Errors import FailedPredicateException raise FailedPredicateException( - self, "self.precpred(self._ctx, 11)" + self, "self.precpred(self._ctx, 3)" ) - self.state = 114 + self.state = 105 localctx.op = self._input.LT(1) _la = self._input.LA(1) - if not (_la == 1 or _la == 2): + if not (_la == 5 or _la == 6): localctx.op = self._errHandler.recoverInline(self) else: self._errHandler.reportMatch(self) self.consume() - self.state = 115 - self.expr(12) + self.state = 106 + self.match(ExprParser.T__2) + self.state = 107 + self.expr(0) + self.state = 108 + self.match(ExprParser.T__3) pass elif la_ == 3: - localctx = ExprParser.ComparisonContext( - self, ExprParser.ExprContext(self, _parentctx, _parentState) + localctx = ExprParser.ShiftAddsubAtomContext( + self, + ExprParser.Shift_exprContext( + self, _parentctx, _parentState + ), ) self.pushNewRecursionContext( - localctx, _startState, self.RULE_expr + localctx, _startState, self.RULE_shift_expr ) - self.state = 116 - if not self.precpred(self._ctx, 10): + self.state = 110 + if not self.precpred(self._ctx, 2): + from antlr4.error.Errors import FailedPredicateException + + raise FailedPredicateException( + self, "self.precpred(self._ctx, 2)" + ) + self.state = 111 + localctx.op = self._input.LT(1) + _la = self._input.LA(1) + if not (_la == 2 or _la == 7): + localctx.op = self._errHandler.recoverInline(self) + else: + self._errHandler.reportMatch(self) + self.consume() + self.state = 112 + self.atom() + pass + + elif la_ == 4: + localctx = ExprParser.ShiftAddsubContext( + self, + ExprParser.Shift_exprContext( + self, _parentctx, _parentState + ), + ) + self.pushNewRecursionContext( + localctx, _startState, self.RULE_shift_expr + ) + self.state = 113 + if not self.precpred(self._ctx, 1): from antlr4.error.Errors import FailedPredicateException raise FailedPredicateException( - self, "self.precpred(self._ctx, 10)" + self, "self.precpred(self._ctx, 1)" ) + self.state = 114 + localctx.op = self._input.LT(1) + _la = self._input.LA(1) + if not (_la == 2 or _la == 7): + localctx.op = self._errHandler.recoverInline(self) + else: + self._errHandler.reportMatch(self) + self.consume() + self.state = 115 + self.match(ExprParser.T__2) + self.state = 116 + self.expr(0) self.state = 117 - self.match(ExprParser.COMPARISON) - self.state = 118 - self.expr(11) + self.match(ExprParser.T__3) pass self.state = 123 self._errHandler.sync(self) - _alt = self._interp.adaptivePredict(self._input, 8, self._ctx) + _alt = self._interp.adaptivePredict(self._input, 9, self._ctx) except RecognitionException as re: localctx.exception = re @@ -2294,33 +2264,33 @@ def expr(self, _p: int = 0): def sempred(self, localctx: RuleContext, ruleIndex: int, predIndex: int): if self._predicates == None: self._predicates = dict() - self._predicates[2] = self.shift_expr_sempred - self._predicates[3] = self.expr_sempred + self._predicates[1] = self.expr_sempred + self._predicates[4] = self.shift_expr_sempred pred = self._predicates.get(ruleIndex, None) if pred is None: raise Exception("No predicate with index:" + str(ruleIndex)) else: return pred(localctx, predIndex) - def shift_expr_sempred(self, localctx: Shift_exprContext, predIndex: int): + def expr_sempred(self, localctx: ExprContext, predIndex: int): if predIndex == 0: - return self.precpred(self._ctx, 4) + return self.precpred(self._ctx, 8) if predIndex == 1: - return self.precpred(self._ctx, 3) + return self.precpred(self._ctx, 7) if predIndex == 2: - return self.precpred(self._ctx, 2) + return self.precpred(self._ctx, 6) + def shift_expr_sempred(self, localctx: Shift_exprContext, predIndex: int): if predIndex == 3: - return self.precpred(self._ctx, 1) + return self.precpred(self._ctx, 4) - def expr_sempred(self, localctx: ExprContext, predIndex: int): if predIndex == 4: - return self.precpred(self._ctx, 12) + return self.precpred(self._ctx, 3) if predIndex == 5: - return self.precpred(self._ctx, 11) + return self.precpred(self._ctx, 2) if predIndex == 6: - return self.precpred(self._ctx, 10) + return self.precpred(self._ctx, 1) diff --git a/src/andromede/expression/parsing/antlr/ExprVisitor.py b/src/andromede/expression/parsing/antlr/ExprVisitor.py index 0eb272f1..88ae0049 100644 --- a/src/andromede/expression/parsing/antlr/ExprVisitor.py +++ b/src/andromede/expression/parsing/antlr/ExprVisitor.py @@ -14,92 +14,88 @@ class ExprVisitor(ParseTreeVisitor): def visitFullexpr(self, ctx: ExprParser.FullexprContext): return self.visitChildren(ctx) - # Visit a parse tree produced by ExprParser#shift. - def visitShift(self, ctx: ExprParser.ShiftContext): - return self.visitChildren(ctx) - - # Visit a parse tree produced by ExprParser#shiftMuldivIdentifier. - def visitShiftMuldivIdentifier(self, ctx: ExprParser.ShiftMuldivIdentifierContext): + # Visit a parse tree produced by ExprParser#negation. + def visitNegation(self, ctx: ExprParser.NegationContext): return self.visitChildren(ctx) - # Visit a parse tree produced by ExprParser#signedIdentifier. - def visitSignedIdentifier(self, ctx: ExprParser.SignedIdentifierContext): + # Visit a parse tree produced by ExprParser#unsignedAtom. + def visitUnsignedAtom(self, ctx: ExprParser.UnsignedAtomContext): return self.visitChildren(ctx) - # Visit a parse tree produced by ExprParser#signedExpression. - def visitSignedExpression(self, ctx: ExprParser.SignedExpressionContext): + # Visit a parse tree produced by ExprParser#expression. + def visitExpression(self, ctx: ExprParser.ExpressionContext): return self.visitChildren(ctx) - # Visit a parse tree produced by ExprParser#signedNumber. - def visitSignedNumber(self, ctx: ExprParser.SignedNumberContext): + # Visit a parse tree produced by ExprParser#timeIndex. + def visitTimeIndex(self, ctx: ExprParser.TimeIndexContext): return self.visitChildren(ctx) - # Visit a parse tree produced by ExprParser#signedFunction. - def visitSignedFunction(self, ctx: ExprParser.SignedFunctionContext): + # Visit a parse tree produced by ExprParser#comparison. + def visitComparison(self, ctx: ExprParser.ComparisonContext): return self.visitChildren(ctx) - # Visit a parse tree produced by ExprParser#shiftMuldivNumber. - def visitShiftMuldivNumber(self, ctx: ExprParser.ShiftMuldivNumberContext): + # Visit a parse tree produced by ExprParser#timeShift. + def visitTimeShift(self, ctx: ExprParser.TimeShiftContext): return self.visitChildren(ctx) - # Visit a parse tree produced by ExprParser#shiftMuldiv. - def visitShiftMuldiv(self, ctx: ExprParser.ShiftMuldivContext): + # Visit a parse tree produced by ExprParser#function. + def visitFunction(self, ctx: ExprParser.FunctionContext): return self.visitChildren(ctx) - # Visit a parse tree produced by ExprParser#shiftAddsub. - def visitShiftAddsub(self, ctx: ExprParser.ShiftAddsubContext): + # Visit a parse tree produced by ExprParser#addsub. + def visitAddsub(self, ctx: ExprParser.AddsubContext): return self.visitChildren(ctx) - # Visit a parse tree produced by ExprParser#identifier. - def visitIdentifier(self, ctx: ExprParser.IdentifierContext): + # Visit a parse tree produced by ExprParser#timeShiftRange. + def visitTimeShiftRange(self, ctx: ExprParser.TimeShiftRangeContext): return self.visitChildren(ctx) - # Visit a parse tree produced by ExprParser#negation. - def visitNegation(self, ctx: ExprParser.NegationContext): + # Visit a parse tree produced by ExprParser#portField. + def visitPortField(self, ctx: ExprParser.PortFieldContext): return self.visitChildren(ctx) - # Visit a parse tree produced by ExprParser#expression. - def visitExpression(self, ctx: ExprParser.ExpressionContext): + # Visit a parse tree produced by ExprParser#muldiv. + def visitMuldiv(self, ctx: ExprParser.MuldivContext): return self.visitChildren(ctx) - # Visit a parse tree produced by ExprParser#comparison. - def visitComparison(self, ctx: ExprParser.ComparisonContext): + # Visit a parse tree produced by ExprParser#timeRange. + def visitTimeRange(self, ctx: ExprParser.TimeRangeContext): return self.visitChildren(ctx) - # Visit a parse tree produced by ExprParser#addsub. - def visitAddsub(self, ctx: ExprParser.AddsubContext): + # Visit a parse tree produced by ExprParser#number. + def visitNumber(self, ctx: ExprParser.NumberContext): return self.visitChildren(ctx) - # Visit a parse tree produced by ExprParser#portField. - def visitPortField(self, ctx: ExprParser.PortFieldContext): + # Visit a parse tree produced by ExprParser#identifier. + def visitIdentifier(self, ctx: ExprParser.IdentifierContext): return self.visitChildren(ctx) - # Visit a parse tree produced by ExprParser#muldiv. - def visitMuldiv(self, ctx: ExprParser.MuldivContext): + # Visit a parse tree produced by ExprParser#shift. + def visitShift(self, ctx: ExprParser.ShiftContext): return self.visitChildren(ctx) - # Visit a parse tree produced by ExprParser#number. - def visitNumber(self, ctx: ExprParser.NumberContext): + # Visit a parse tree produced by ExprParser#signedAtom. + def visitSignedAtom(self, ctx: ExprParser.SignedAtomContext): return self.visitChildren(ctx) - # Visit a parse tree produced by ExprParser#timeIndex. - def visitTimeIndex(self, ctx: ExprParser.TimeIndexContext): + # Visit a parse tree produced by ExprParser#signedExpression. + def visitSignedExpression(self, ctx: ExprParser.SignedExpressionContext): return self.visitChildren(ctx) - # Visit a parse tree produced by ExprParser#timeShift. - def visitTimeShift(self, ctx: ExprParser.TimeShiftContext): + # Visit a parse tree produced by ExprParser#shiftMuldivAtom. + def visitShiftMuldivAtom(self, ctx: ExprParser.ShiftMuldivAtomContext): return self.visitChildren(ctx) - # Visit a parse tree produced by ExprParser#function. - def visitFunction(self, ctx: ExprParser.FunctionContext): + # Visit a parse tree produced by ExprParser#shiftMuldiv. + def visitShiftMuldiv(self, ctx: ExprParser.ShiftMuldivContext): return self.visitChildren(ctx) - # Visit a parse tree produced by ExprParser#timeShiftRange. - def visitTimeShiftRange(self, ctx: ExprParser.TimeShiftRangeContext): + # Visit a parse tree produced by ExprParser#shiftAddsub. + def visitShiftAddsub(self, ctx: ExprParser.ShiftAddsubContext): return self.visitChildren(ctx) - # Visit a parse tree produced by ExprParser#timeRange. - def visitTimeRange(self, ctx: ExprParser.TimeRangeContext): + # Visit a parse tree produced by ExprParser#shiftAddsubAtom. + def visitShiftAddsubAtom(self, ctx: ExprParser.ShiftAddsubAtomContext): return self.visitChildren(ctx) diff --git a/src/andromede/expression/parsing/parse_expression.py b/src/andromede/expression/parsing/parse_expression.py index ffa6b6bc..5a621dd6 100644 --- a/src/andromede/expression/parsing/parse_expression.py +++ b/src/andromede/expression/parsing/parse_expression.py @@ -55,6 +55,14 @@ class ExpressionNodeBuilderVisitor(ExprVisitor): def visitFullexpr(self, ctx: ExprParser.FullexprContext) -> ExpressionNode: return ctx.expr().accept(self) # type: ignore + # Visit a parse tree produced by ExprParser#number. + def visitNumber(self, ctx: ExprParser.NumberContext) -> ExpressionNode: + return literal(float(ctx.NUMBER().getText())) # type: ignore + + # Visit a parse tree produced by ExprParser#identifier. + def visitIdentifier(self, ctx: ExprParser.IdentifierContext) -> ExpressionNode: + return self._convert_identifier(ctx.IDENTIFIER().getText()) # type: ignore + # Visit a parse tree produced by ExprParser#division. def visitMuldiv(self, ctx: ExprParser.MuldivContext) -> ExpressionNode: left = ctx.expr(0).accept(self) # type: ignore @@ -77,10 +85,6 @@ def visitAddsub(self, ctx: ExprParser.AddsubContext) -> ExpressionNode: return left - right raise ValueError(f"Invalid operator {op}") - # Visit a parse tree produced by ExprParser#number. - def visitNumber(self, ctx: ExprParser.NumberContext) -> ExpressionNode: - return literal(float(ctx.getText())) - # Visit a parse tree produced by ExprParser#negation. def visitNegation(self, ctx: ExprParser.NegationContext) -> ExpressionNode: return -ctx.expr().accept(self) # type: ignore @@ -89,9 +93,9 @@ def visitNegation(self, ctx: ExprParser.NegationContext) -> ExpressionNode: def visitExpression(self, ctx: ExprParser.ExpressionContext) -> ExpressionNode: return ctx.expr().accept(self) # type: ignore - # Visit a parse tree produced by ExprParser#identifier. - def visitIdentifier(self, ctx: ExprParser.IdentifierContext) -> ExpressionNode: - return self._convert_identifier(ctx.IDENTIFIER().getText()) # type: ignore + # Visit a parse tree produced by ExprParser#unsignedAtom. + def visitUnsignedAtom(self, ctx: ExprParser.UnsignedAtomContext) -> ExpressionNode: + return ctx.atom().accept(self) # type: ignore def _convert_identifier(self, identifier: str) -> ExpressionNode: if self.identifiers.is_variable(identifier): @@ -163,13 +167,6 @@ def visitShift(self, ctx: ExprParser.ShiftContext) -> ExpressionNode: shift = ctx.shift_expr().accept(self) # type: ignore return shift - # Visit a parse tree produced by ExprParser#signedNumber. - def visitSignedNumber(self, ctx: ExprParser.SignedNumberContext) -> ExpressionNode: - if ctx.op.text == "-": # type: ignore - return -literal(float(ctx.NUMBER().getText())) # type: ignore - else: - return literal(float(ctx.NUMBER().getText())) # type: ignore - # Visit a parse tree produced by ExprParser#shiftAddsub. def visitShiftAddsub(self, ctx: ExprParser.ShiftAddsubContext) -> ExpressionNode: left = ctx.shift_expr().accept(self) # type: ignore @@ -181,34 +178,23 @@ def visitShiftAddsub(self, ctx: ExprParser.ShiftAddsubContext) -> ExpressionNode return left - right raise ValueError(f"Invalid operator {op}") - # Visit a parse tree produced by ExprParser#signedIdentifier. - def visitSignedIdentifier( - self, ctx: ExprParser.SignedIdentifierContext - ) -> ExpressionNode: - if ctx.op.text == "-": # type: ignore - return -self._convert_identifier(ctx.IDENTIFIER().getText()) # type: ignore - else: - return self._convert_identifier(ctx.IDENTIFIER().getText()) # type: ignore - - # Visit a parse tree produced by ExprParser#shiftMuldivIdentifier. - def visitShiftMuldivIdentifier( - self, ctx: ExprParser.ShiftMuldivIdentifierContext + # Visit a parse tree produced by ExprParser#shiftAddsubAtom. + def visitShiftAddsubAtom( + self, ctx: ExprParser.ShiftAddsubAtomContext ) -> ExpressionNode: left = ctx.shift_expr().accept(self) # type: ignore - right = self._convert_identifier(ctx.IDENTIFIER().getText()) # type: ignore + right = ctx.atom().accept(self) # type: ignore op = ctx.op.text # type: ignore - if op == "*": - return left * right - elif op == "/": - return left / right + if op == "+": + return left + right + elif op == "-": + return left - right raise ValueError(f"Invalid operator {op}") - # Visit a parse tree produced by ExprParser#shiftMuldivNumber. - def visitShiftMuldivNumber( - self, ctx: ExprParser.ShiftMuldivNumberContext - ) -> ExpressionNode: + # Visit a parse tree produced by ExprParser#shiftMuldiv. + def visitShiftMuldiv(self, ctx: ExprParser.ShiftMuldivContext) -> ExpressionNode: left = ctx.shift_expr().accept(self) # type: ignore - right = literal(float(ctx.NUMBER().getText())) # type: ignore + right = ctx.expr().accept(self) # type: ignore op = ctx.op.text # type: ignore if op == "*": return left * right @@ -216,10 +202,12 @@ def visitShiftMuldivNumber( return left / right raise ValueError(f"Invalid operator {op}") - # Visit a parse tree produced by ExprParser#shiftMuldiv. - def visitShiftMuldiv(self, ctx: ExprParser.ShiftMuldivContext) -> ExpressionNode: + # Visit a parse tree produced by ExprParser#shiftMuldivAtom. + def visitShiftMuldivAtom( + self, ctx: ExprParser.ShiftMuldivAtomContext + ) -> ExpressionNode: left = ctx.shift_expr().accept(self) # type: ignore - right = ctx.expr().accept(self) # type: ignore + right = ctx.atom().accept(self) # type: ignore op = ctx.op.text # type: ignore if op == "*": return left * right @@ -236,20 +224,12 @@ def visitSignedExpression( else: return ctx.expr().accept(self) # type: ignore - # Visit a parse tree produced by ExprParser#signedFunction. - def visitSignedFunction( - self, ctx: ExprParser.SignedFunctionContext - ) -> ExpressionNode: - function_name: str = ctx.IDENTIFIER().getText() # type: ignore - operand: ExpressionNode = ctx.expr().accept(self) # type: ignore - op = ctx.op.text # type: ignore - fn = _FUNCTIONS.get(function_name, None) - if fn is None: - raise ValueError(f"Encountered invalid function name {function_name}") + # Visit a parse tree produced by ExprParser#signedAtom. + def visitSignedAtom(self, ctx: ExprParser.SignedAtomContext) -> ExpressionNode: if ctx.op.text == "-": # type: ignore - return -fn(operand) + return -ctx.atom().accept(self) # type: ignore else: - return fn(operand) + return ctx.atom().accept(self) # type: ignore _FUNCTIONS = { diff --git a/tests/unittests/expressions/parsing/test_expression_parsing.py b/tests/unittests/expressions/parsing/test_expression_parsing.py index 23045d03..524097ed 100644 --- a/tests/unittests/expressions/parsing/test_expression_parsing.py +++ b/tests/unittests/expressions/parsing/test_expression_parsing.py @@ -75,7 +75,13 @@ "x[t-2*d+1]", var("x").shift(-literal(2) * param("d") + literal(1)), ), - ( # TO_DO it should be an error !!!!!!" + ( + {"x"}, + {"d"}, + "x[t-2-d+1]", + var("x").shift(-literal(2) - param("d") + literal(1)), + ), + ( {"x"}, {"d"}, "x[t 4]",