diff --git a/Wyst.g4 b/Wyst.g4 index 9fa5ccc..fc4f022 100644 --- a/Wyst.g4 +++ b/Wyst.g4 @@ -3,18 +3,23 @@ grammar Wyst; WS: [ \t\r\n]+ -> skip; NUMBER: [1-9][0-9]* | '0'; HEX: '0x' [a-fA-F0-9]*; -IDENTIFIER: [a-zA-Z_] ([a-zA-Z0-9] | '::')*; +IDENTIFIER: [a-zA-Z_] ([a-zA-Z0-9_] | '::')*; MATH: '+' | '-' | '*' | '/'; fragment ESC: '\\' ['"\\] ; STRING: '"' (ESC | ~["\\])* '"'; round_def: '(' (var_def (',' var_def)* ','?)? ')'; +round_call: '(' (expr (',' expr)* ','?)? ')'; +fn_call: IDENTIFIER round_call; func_def: IDENTIFIER IDENTIFIER round_def code_block; var_def: IDENTIFIER IDENTIFIER; var_def_set: var_def '=' expr; +call_tree: (fn_call|IDENTIFIER) ('.' (fn_call|IDENTIFIER))*; asm: '%' IDENTIFIER expr (',' expr)* ';'; expr: - ( NUMBER | + ( + call_tree | + NUMBER | HEX | IDENTIFIER | STRING diff --git a/parser/Wyst.interp b/parser/Wyst.interp index 72adc43..111c50c 100644 --- a/parser/Wyst.interp +++ b/parser/Wyst.interp @@ -4,6 +4,7 @@ null ',' ')' '=' +'.' '%' ';' '{' @@ -25,6 +26,7 @@ null null null null +null WS NUMBER HEX @@ -34,9 +36,12 @@ STRING rule names: round_def +round_call +fn_call func_def var_def var_def_set +call_tree asm expr code_block @@ -44,4 +49,4 @@ top atn: -[4, 1, 14, 87, 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, 1, 0, 1, 0, 1, 0, 1, 0, 5, 0, 21, 8, 0, 10, 0, 12, 0, 24, 9, 0, 1, 0, 3, 0, 27, 8, 0, 3, 0, 29, 8, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 5, 4, 50, 8, 4, 10, 4, 12, 4, 53, 9, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 5, 5, 60, 8, 5, 10, 5, 12, 5, 63, 9, 5, 1, 6, 1, 6, 1, 6, 1, 6, 3, 6, 69, 8, 6, 1, 6, 1, 6, 5, 6, 73, 8, 6, 10, 6, 12, 6, 76, 9, 6, 1, 6, 1, 6, 1, 7, 1, 7, 5, 7, 82, 8, 7, 10, 7, 12, 7, 85, 9, 7, 1, 7, 0, 0, 8, 0, 2, 4, 6, 8, 10, 12, 14, 0, 1, 2, 0, 10, 12, 14, 14, 88, 0, 16, 1, 0, 0, 0, 2, 32, 1, 0, 0, 0, 4, 37, 1, 0, 0, 0, 6, 40, 1, 0, 0, 0, 8, 44, 1, 0, 0, 0, 10, 56, 1, 0, 0, 0, 12, 64, 1, 0, 0, 0, 14, 83, 1, 0, 0, 0, 16, 28, 5, 1, 0, 0, 17, 22, 3, 4, 2, 0, 18, 19, 5, 2, 0, 0, 19, 21, 3, 4, 2, 0, 20, 18, 1, 0, 0, 0, 21, 24, 1, 0, 0, 0, 22, 20, 1, 0, 0, 0, 22, 23, 1, 0, 0, 0, 23, 26, 1, 0, 0, 0, 24, 22, 1, 0, 0, 0, 25, 27, 5, 2, 0, 0, 26, 25, 1, 0, 0, 0, 26, 27, 1, 0, 0, 0, 27, 29, 1, 0, 0, 0, 28, 17, 1, 0, 0, 0, 28, 29, 1, 0, 0, 0, 29, 30, 1, 0, 0, 0, 30, 31, 5, 3, 0, 0, 31, 1, 1, 0, 0, 0, 32, 33, 5, 12, 0, 0, 33, 34, 5, 12, 0, 0, 34, 35, 3, 0, 0, 0, 35, 36, 3, 12, 6, 0, 36, 3, 1, 0, 0, 0, 37, 38, 5, 12, 0, 0, 38, 39, 5, 12, 0, 0, 39, 5, 1, 0, 0, 0, 40, 41, 3, 4, 2, 0, 41, 42, 5, 4, 0, 0, 42, 43, 3, 10, 5, 0, 43, 7, 1, 0, 0, 0, 44, 45, 5, 5, 0, 0, 45, 46, 5, 12, 0, 0, 46, 51, 3, 10, 5, 0, 47, 48, 5, 2, 0, 0, 48, 50, 3, 10, 5, 0, 49, 47, 1, 0, 0, 0, 50, 53, 1, 0, 0, 0, 51, 49, 1, 0, 0, 0, 51, 52, 1, 0, 0, 0, 52, 54, 1, 0, 0, 0, 53, 51, 1, 0, 0, 0, 54, 55, 5, 6, 0, 0, 55, 9, 1, 0, 0, 0, 56, 61, 7, 0, 0, 0, 57, 58, 5, 13, 0, 0, 58, 60, 3, 10, 5, 0, 59, 57, 1, 0, 0, 0, 60, 63, 1, 0, 0, 0, 61, 59, 1, 0, 0, 0, 61, 62, 1, 0, 0, 0, 62, 11, 1, 0, 0, 0, 63, 61, 1, 0, 0, 0, 64, 74, 5, 7, 0, 0, 65, 69, 3, 10, 5, 0, 66, 69, 3, 4, 2, 0, 67, 69, 3, 6, 3, 0, 68, 65, 1, 0, 0, 0, 68, 66, 1, 0, 0, 0, 68, 67, 1, 0, 0, 0, 69, 70, 1, 0, 0, 0, 70, 71, 5, 6, 0, 0, 71, 73, 1, 0, 0, 0, 72, 68, 1, 0, 0, 0, 73, 76, 1, 0, 0, 0, 74, 72, 1, 0, 0, 0, 74, 75, 1, 0, 0, 0, 75, 77, 1, 0, 0, 0, 76, 74, 1, 0, 0, 0, 77, 78, 5, 8, 0, 0, 78, 13, 1, 0, 0, 0, 79, 82, 3, 8, 4, 0, 80, 82, 3, 2, 1, 0, 81, 79, 1, 0, 0, 0, 81, 80, 1, 0, 0, 0, 82, 85, 1, 0, 0, 0, 83, 81, 1, 0, 0, 0, 83, 84, 1, 0, 0, 0, 84, 15, 1, 0, 0, 0, 85, 83, 1, 0, 0, 0, 9, 22, 26, 28, 51, 61, 68, 74, 81, 83] \ No newline at end of file +[4, 1, 15, 132, 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, 1, 0, 1, 0, 1, 0, 1, 0, 5, 0, 27, 8, 0, 10, 0, 12, 0, 30, 9, 0, 1, 0, 3, 0, 33, 8, 0, 3, 0, 35, 8, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 43, 8, 1, 10, 1, 12, 1, 46, 9, 1, 1, 1, 3, 1, 49, 8, 1, 3, 1, 51, 8, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 3, 6, 72, 8, 6, 1, 6, 1, 6, 1, 6, 3, 6, 77, 8, 6, 5, 6, 79, 8, 6, 10, 6, 12, 6, 82, 9, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 5, 7, 89, 8, 7, 10, 7, 12, 7, 92, 9, 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 3, 8, 101, 8, 8, 1, 8, 1, 8, 5, 8, 105, 8, 8, 10, 8, 12, 8, 108, 9, 8, 1, 9, 1, 9, 1, 9, 1, 9, 3, 9, 114, 8, 9, 1, 9, 1, 9, 5, 9, 118, 8, 9, 10, 9, 12, 9, 121, 9, 9, 1, 9, 1, 9, 1, 10, 1, 10, 5, 10, 127, 8, 10, 10, 10, 12, 10, 130, 9, 10, 1, 10, 0, 0, 11, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 0, 0, 140, 0, 22, 1, 0, 0, 0, 2, 38, 1, 0, 0, 0, 4, 54, 1, 0, 0, 0, 6, 57, 1, 0, 0, 0, 8, 62, 1, 0, 0, 0, 10, 65, 1, 0, 0, 0, 12, 71, 1, 0, 0, 0, 14, 83, 1, 0, 0, 0, 16, 100, 1, 0, 0, 0, 18, 109, 1, 0, 0, 0, 20, 128, 1, 0, 0, 0, 22, 34, 5, 1, 0, 0, 23, 28, 3, 8, 4, 0, 24, 25, 5, 2, 0, 0, 25, 27, 3, 8, 4, 0, 26, 24, 1, 0, 0, 0, 27, 30, 1, 0, 0, 0, 28, 26, 1, 0, 0, 0, 28, 29, 1, 0, 0, 0, 29, 32, 1, 0, 0, 0, 30, 28, 1, 0, 0, 0, 31, 33, 5, 2, 0, 0, 32, 31, 1, 0, 0, 0, 32, 33, 1, 0, 0, 0, 33, 35, 1, 0, 0, 0, 34, 23, 1, 0, 0, 0, 34, 35, 1, 0, 0, 0, 35, 36, 1, 0, 0, 0, 36, 37, 5, 3, 0, 0, 37, 1, 1, 0, 0, 0, 38, 50, 5, 1, 0, 0, 39, 44, 3, 16, 8, 0, 40, 41, 5, 2, 0, 0, 41, 43, 3, 16, 8, 0, 42, 40, 1, 0, 0, 0, 43, 46, 1, 0, 0, 0, 44, 42, 1, 0, 0, 0, 44, 45, 1, 0, 0, 0, 45, 48, 1, 0, 0, 0, 46, 44, 1, 0, 0, 0, 47, 49, 5, 2, 0, 0, 48, 47, 1, 0, 0, 0, 48, 49, 1, 0, 0, 0, 49, 51, 1, 0, 0, 0, 50, 39, 1, 0, 0, 0, 50, 51, 1, 0, 0, 0, 51, 52, 1, 0, 0, 0, 52, 53, 5, 3, 0, 0, 53, 3, 1, 0, 0, 0, 54, 55, 5, 13, 0, 0, 55, 56, 3, 2, 1, 0, 56, 5, 1, 0, 0, 0, 57, 58, 5, 13, 0, 0, 58, 59, 5, 13, 0, 0, 59, 60, 3, 0, 0, 0, 60, 61, 3, 18, 9, 0, 61, 7, 1, 0, 0, 0, 62, 63, 5, 13, 0, 0, 63, 64, 5, 13, 0, 0, 64, 9, 1, 0, 0, 0, 65, 66, 3, 8, 4, 0, 66, 67, 5, 4, 0, 0, 67, 68, 3, 16, 8, 0, 68, 11, 1, 0, 0, 0, 69, 72, 3, 4, 2, 0, 70, 72, 5, 13, 0, 0, 71, 69, 1, 0, 0, 0, 71, 70, 1, 0, 0, 0, 72, 80, 1, 0, 0, 0, 73, 76, 5, 5, 0, 0, 74, 77, 3, 4, 2, 0, 75, 77, 5, 13, 0, 0, 76, 74, 1, 0, 0, 0, 76, 75, 1, 0, 0, 0, 77, 79, 1, 0, 0, 0, 78, 73, 1, 0, 0, 0, 79, 82, 1, 0, 0, 0, 80, 78, 1, 0, 0, 0, 80, 81, 1, 0, 0, 0, 81, 13, 1, 0, 0, 0, 82, 80, 1, 0, 0, 0, 83, 84, 5, 6, 0, 0, 84, 85, 5, 13, 0, 0, 85, 90, 3, 16, 8, 0, 86, 87, 5, 2, 0, 0, 87, 89, 3, 16, 8, 0, 88, 86, 1, 0, 0, 0, 89, 92, 1, 0, 0, 0, 90, 88, 1, 0, 0, 0, 90, 91, 1, 0, 0, 0, 91, 93, 1, 0, 0, 0, 92, 90, 1, 0, 0, 0, 93, 94, 5, 7, 0, 0, 94, 15, 1, 0, 0, 0, 95, 101, 3, 12, 6, 0, 96, 101, 5, 11, 0, 0, 97, 101, 5, 12, 0, 0, 98, 101, 5, 13, 0, 0, 99, 101, 5, 15, 0, 0, 100, 95, 1, 0, 0, 0, 100, 96, 1, 0, 0, 0, 100, 97, 1, 0, 0, 0, 100, 98, 1, 0, 0, 0, 100, 99, 1, 0, 0, 0, 101, 106, 1, 0, 0, 0, 102, 103, 5, 14, 0, 0, 103, 105, 3, 16, 8, 0, 104, 102, 1, 0, 0, 0, 105, 108, 1, 0, 0, 0, 106, 104, 1, 0, 0, 0, 106, 107, 1, 0, 0, 0, 107, 17, 1, 0, 0, 0, 108, 106, 1, 0, 0, 0, 109, 119, 5, 8, 0, 0, 110, 114, 3, 16, 8, 0, 111, 114, 3, 8, 4, 0, 112, 114, 3, 10, 5, 0, 113, 110, 1, 0, 0, 0, 113, 111, 1, 0, 0, 0, 113, 112, 1, 0, 0, 0, 114, 115, 1, 0, 0, 0, 115, 116, 5, 7, 0, 0, 116, 118, 1, 0, 0, 0, 117, 113, 1, 0, 0, 0, 118, 121, 1, 0, 0, 0, 119, 117, 1, 0, 0, 0, 119, 120, 1, 0, 0, 0, 120, 122, 1, 0, 0, 0, 121, 119, 1, 0, 0, 0, 122, 123, 5, 9, 0, 0, 123, 19, 1, 0, 0, 0, 124, 127, 3, 14, 7, 0, 125, 127, 3, 6, 3, 0, 126, 124, 1, 0, 0, 0, 126, 125, 1, 0, 0, 0, 127, 130, 1, 0, 0, 0, 128, 126, 1, 0, 0, 0, 128, 129, 1, 0, 0, 0, 129, 21, 1, 0, 0, 0, 130, 128, 1, 0, 0, 0, 16, 28, 32, 34, 44, 48, 50, 71, 76, 80, 90, 100, 106, 113, 119, 126, 128] \ No newline at end of file diff --git a/parser/Wyst.tokens b/parser/Wyst.tokens index 3dc2b72..f26bf47 100644 --- a/parser/Wyst.tokens +++ b/parser/Wyst.tokens @@ -6,17 +6,19 @@ T__4=5 T__5=6 T__6=7 T__7=8 -WS=9 -NUMBER=10 -HEX=11 -IDENTIFIER=12 -MATH=13 -STRING=14 +T__8=9 +WS=10 +NUMBER=11 +HEX=12 +IDENTIFIER=13 +MATH=14 +STRING=15 '('=1 ','=2 ')'=3 '='=4 -'%'=5 -';'=6 -'{'=7 -'}'=8 +'.'=5 +'%'=6 +';'=7 +'{'=8 +'}'=9 diff --git a/parser/WystLexer.interp b/parser/WystLexer.interp index bec247b..43a845f 100644 --- a/parser/WystLexer.interp +++ b/parser/WystLexer.interp @@ -4,6 +4,7 @@ null ',' ')' '=' +'.' '%' ';' '{' @@ -25,6 +26,7 @@ null null null null +null WS NUMBER HEX @@ -41,6 +43,7 @@ T__4 T__5 T__6 T__7 +T__8 WS NUMBER HEX @@ -57,4 +60,4 @@ mode names: DEFAULT_MODE atn: -[4, 0, 14, 97, 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, 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, 4, 8, 49, 8, 8, 11, 8, 12, 8, 50, 1, 8, 1, 8, 1, 9, 1, 9, 5, 9, 57, 8, 9, 10, 9, 12, 9, 60, 9, 9, 1, 9, 3, 9, 63, 8, 9, 1, 10, 1, 10, 1, 10, 1, 10, 5, 10, 69, 8, 10, 10, 10, 12, 10, 72, 9, 10, 1, 11, 1, 11, 1, 11, 1, 11, 5, 11, 78, 8, 11, 10, 11, 12, 11, 81, 9, 11, 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 5, 14, 91, 8, 14, 10, 14, 12, 14, 94, 9, 14, 1, 14, 1, 14, 0, 0, 15, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 0, 29, 14, 1, 0, 9, 3, 0, 9, 10, 13, 13, 32, 32, 1, 0, 49, 57, 1, 0, 48, 57, 3, 0, 48, 57, 65, 70, 97, 102, 3, 0, 65, 90, 95, 95, 97, 122, 3, 0, 48, 57, 65, 90, 97, 122, 3, 0, 42, 43, 45, 45, 47, 47, 3, 0, 34, 34, 39, 39, 92, 92, 2, 0, 34, 34, 92, 92, 103, 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, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 1, 31, 1, 0, 0, 0, 3, 33, 1, 0, 0, 0, 5, 35, 1, 0, 0, 0, 7, 37, 1, 0, 0, 0, 9, 39, 1, 0, 0, 0, 11, 41, 1, 0, 0, 0, 13, 43, 1, 0, 0, 0, 15, 45, 1, 0, 0, 0, 17, 48, 1, 0, 0, 0, 19, 62, 1, 0, 0, 0, 21, 64, 1, 0, 0, 0, 23, 73, 1, 0, 0, 0, 25, 82, 1, 0, 0, 0, 27, 84, 1, 0, 0, 0, 29, 87, 1, 0, 0, 0, 31, 32, 5, 40, 0, 0, 32, 2, 1, 0, 0, 0, 33, 34, 5, 44, 0, 0, 34, 4, 1, 0, 0, 0, 35, 36, 5, 41, 0, 0, 36, 6, 1, 0, 0, 0, 37, 38, 5, 61, 0, 0, 38, 8, 1, 0, 0, 0, 39, 40, 5, 37, 0, 0, 40, 10, 1, 0, 0, 0, 41, 42, 5, 59, 0, 0, 42, 12, 1, 0, 0, 0, 43, 44, 5, 123, 0, 0, 44, 14, 1, 0, 0, 0, 45, 46, 5, 125, 0, 0, 46, 16, 1, 0, 0, 0, 47, 49, 7, 0, 0, 0, 48, 47, 1, 0, 0, 0, 49, 50, 1, 0, 0, 0, 50, 48, 1, 0, 0, 0, 50, 51, 1, 0, 0, 0, 51, 52, 1, 0, 0, 0, 52, 53, 6, 8, 0, 0, 53, 18, 1, 0, 0, 0, 54, 58, 7, 1, 0, 0, 55, 57, 7, 2, 0, 0, 56, 55, 1, 0, 0, 0, 57, 60, 1, 0, 0, 0, 58, 56, 1, 0, 0, 0, 58, 59, 1, 0, 0, 0, 59, 63, 1, 0, 0, 0, 60, 58, 1, 0, 0, 0, 61, 63, 5, 48, 0, 0, 62, 54, 1, 0, 0, 0, 62, 61, 1, 0, 0, 0, 63, 20, 1, 0, 0, 0, 64, 65, 5, 48, 0, 0, 65, 66, 5, 120, 0, 0, 66, 70, 1, 0, 0, 0, 67, 69, 7, 3, 0, 0, 68, 67, 1, 0, 0, 0, 69, 72, 1, 0, 0, 0, 70, 68, 1, 0, 0, 0, 70, 71, 1, 0, 0, 0, 71, 22, 1, 0, 0, 0, 72, 70, 1, 0, 0, 0, 73, 79, 7, 4, 0, 0, 74, 78, 7, 5, 0, 0, 75, 76, 5, 58, 0, 0, 76, 78, 5, 58, 0, 0, 77, 74, 1, 0, 0, 0, 77, 75, 1, 0, 0, 0, 78, 81, 1, 0, 0, 0, 79, 77, 1, 0, 0, 0, 79, 80, 1, 0, 0, 0, 80, 24, 1, 0, 0, 0, 81, 79, 1, 0, 0, 0, 82, 83, 7, 6, 0, 0, 83, 26, 1, 0, 0, 0, 84, 85, 5, 92, 0, 0, 85, 86, 7, 7, 0, 0, 86, 28, 1, 0, 0, 0, 87, 92, 5, 34, 0, 0, 88, 91, 3, 27, 13, 0, 89, 91, 8, 8, 0, 0, 90, 88, 1, 0, 0, 0, 90, 89, 1, 0, 0, 0, 91, 94, 1, 0, 0, 0, 92, 90, 1, 0, 0, 0, 92, 93, 1, 0, 0, 0, 93, 95, 1, 0, 0, 0, 94, 92, 1, 0, 0, 0, 95, 96, 5, 34, 0, 0, 96, 30, 1, 0, 0, 0, 9, 0, 50, 58, 62, 70, 77, 79, 90, 92, 1, 6, 0, 0] \ No newline at end of file +[4, 0, 15, 101, 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, 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, 9, 4, 9, 53, 8, 9, 11, 9, 12, 9, 54, 1, 9, 1, 9, 1, 10, 1, 10, 5, 10, 61, 8, 10, 10, 10, 12, 10, 64, 9, 10, 1, 10, 3, 10, 67, 8, 10, 1, 11, 1, 11, 1, 11, 1, 11, 5, 11, 73, 8, 11, 10, 11, 12, 11, 76, 9, 11, 1, 12, 1, 12, 1, 12, 1, 12, 5, 12, 82, 8, 12, 10, 12, 12, 12, 85, 9, 12, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 15, 5, 15, 95, 8, 15, 10, 15, 12, 15, 98, 9, 15, 1, 15, 1, 15, 0, 0, 16, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 0, 31, 15, 1, 0, 9, 3, 0, 9, 10, 13, 13, 32, 32, 1, 0, 49, 57, 1, 0, 48, 57, 3, 0, 48, 57, 65, 70, 97, 102, 3, 0, 65, 90, 95, 95, 97, 122, 4, 0, 48, 57, 65, 90, 95, 95, 97, 122, 3, 0, 42, 43, 45, 45, 47, 47, 3, 0, 34, 34, 39, 39, 92, 92, 2, 0, 34, 34, 92, 92, 107, 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, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 1, 33, 1, 0, 0, 0, 3, 35, 1, 0, 0, 0, 5, 37, 1, 0, 0, 0, 7, 39, 1, 0, 0, 0, 9, 41, 1, 0, 0, 0, 11, 43, 1, 0, 0, 0, 13, 45, 1, 0, 0, 0, 15, 47, 1, 0, 0, 0, 17, 49, 1, 0, 0, 0, 19, 52, 1, 0, 0, 0, 21, 66, 1, 0, 0, 0, 23, 68, 1, 0, 0, 0, 25, 77, 1, 0, 0, 0, 27, 86, 1, 0, 0, 0, 29, 88, 1, 0, 0, 0, 31, 91, 1, 0, 0, 0, 33, 34, 5, 40, 0, 0, 34, 2, 1, 0, 0, 0, 35, 36, 5, 44, 0, 0, 36, 4, 1, 0, 0, 0, 37, 38, 5, 41, 0, 0, 38, 6, 1, 0, 0, 0, 39, 40, 5, 61, 0, 0, 40, 8, 1, 0, 0, 0, 41, 42, 5, 46, 0, 0, 42, 10, 1, 0, 0, 0, 43, 44, 5, 37, 0, 0, 44, 12, 1, 0, 0, 0, 45, 46, 5, 59, 0, 0, 46, 14, 1, 0, 0, 0, 47, 48, 5, 123, 0, 0, 48, 16, 1, 0, 0, 0, 49, 50, 5, 125, 0, 0, 50, 18, 1, 0, 0, 0, 51, 53, 7, 0, 0, 0, 52, 51, 1, 0, 0, 0, 53, 54, 1, 0, 0, 0, 54, 52, 1, 0, 0, 0, 54, 55, 1, 0, 0, 0, 55, 56, 1, 0, 0, 0, 56, 57, 6, 9, 0, 0, 57, 20, 1, 0, 0, 0, 58, 62, 7, 1, 0, 0, 59, 61, 7, 2, 0, 0, 60, 59, 1, 0, 0, 0, 61, 64, 1, 0, 0, 0, 62, 60, 1, 0, 0, 0, 62, 63, 1, 0, 0, 0, 63, 67, 1, 0, 0, 0, 64, 62, 1, 0, 0, 0, 65, 67, 5, 48, 0, 0, 66, 58, 1, 0, 0, 0, 66, 65, 1, 0, 0, 0, 67, 22, 1, 0, 0, 0, 68, 69, 5, 48, 0, 0, 69, 70, 5, 120, 0, 0, 70, 74, 1, 0, 0, 0, 71, 73, 7, 3, 0, 0, 72, 71, 1, 0, 0, 0, 73, 76, 1, 0, 0, 0, 74, 72, 1, 0, 0, 0, 74, 75, 1, 0, 0, 0, 75, 24, 1, 0, 0, 0, 76, 74, 1, 0, 0, 0, 77, 83, 7, 4, 0, 0, 78, 82, 7, 5, 0, 0, 79, 80, 5, 58, 0, 0, 80, 82, 5, 58, 0, 0, 81, 78, 1, 0, 0, 0, 81, 79, 1, 0, 0, 0, 82, 85, 1, 0, 0, 0, 83, 81, 1, 0, 0, 0, 83, 84, 1, 0, 0, 0, 84, 26, 1, 0, 0, 0, 85, 83, 1, 0, 0, 0, 86, 87, 7, 6, 0, 0, 87, 28, 1, 0, 0, 0, 88, 89, 5, 92, 0, 0, 89, 90, 7, 7, 0, 0, 90, 30, 1, 0, 0, 0, 91, 96, 5, 34, 0, 0, 92, 95, 3, 29, 14, 0, 93, 95, 8, 8, 0, 0, 94, 92, 1, 0, 0, 0, 94, 93, 1, 0, 0, 0, 95, 98, 1, 0, 0, 0, 96, 94, 1, 0, 0, 0, 96, 97, 1, 0, 0, 0, 97, 99, 1, 0, 0, 0, 98, 96, 1, 0, 0, 0, 99, 100, 5, 34, 0, 0, 100, 32, 1, 0, 0, 0, 9, 0, 54, 62, 66, 74, 81, 83, 94, 96, 1, 6, 0, 0] \ No newline at end of file diff --git a/parser/WystLexer.tokens b/parser/WystLexer.tokens index 3dc2b72..f26bf47 100644 --- a/parser/WystLexer.tokens +++ b/parser/WystLexer.tokens @@ -6,17 +6,19 @@ T__4=5 T__5=6 T__6=7 T__7=8 -WS=9 -NUMBER=10 -HEX=11 -IDENTIFIER=12 -MATH=13 -STRING=14 +T__8=9 +WS=10 +NUMBER=11 +HEX=12 +IDENTIFIER=13 +MATH=14 +STRING=15 '('=1 ','=2 ')'=3 '='=4 -'%'=5 -';'=6 -'{'=7 -'}'=8 +'.'=5 +'%'=6 +';'=7 +'{'=8 +'}'=9 diff --git a/parser/wyst_base_listener.go b/parser/wyst_base_listener.go index 12111de..48a555b 100644 --- a/parser/wyst_base_listener.go +++ b/parser/wyst_base_listener.go @@ -27,6 +27,18 @@ func (s *BaseWystListener) EnterRound_def(ctx *Round_defContext) {} // ExitRound_def is called when production round_def is exited. func (s *BaseWystListener) ExitRound_def(ctx *Round_defContext) {} +// EnterRound_call is called when production round_call is entered. +func (s *BaseWystListener) EnterRound_call(ctx *Round_callContext) {} + +// ExitRound_call is called when production round_call is exited. +func (s *BaseWystListener) ExitRound_call(ctx *Round_callContext) {} + +// EnterFn_call is called when production fn_call is entered. +func (s *BaseWystListener) EnterFn_call(ctx *Fn_callContext) {} + +// ExitFn_call is called when production fn_call is exited. +func (s *BaseWystListener) ExitFn_call(ctx *Fn_callContext) {} + // EnterFunc_def is called when production func_def is entered. func (s *BaseWystListener) EnterFunc_def(ctx *Func_defContext) {} @@ -45,6 +57,12 @@ func (s *BaseWystListener) EnterVar_def_set(ctx *Var_def_setContext) {} // ExitVar_def_set is called when production var_def_set is exited. func (s *BaseWystListener) ExitVar_def_set(ctx *Var_def_setContext) {} +// EnterCall_tree is called when production call_tree is entered. +func (s *BaseWystListener) EnterCall_tree(ctx *Call_treeContext) {} + +// ExitCall_tree is called when production call_tree is exited. +func (s *BaseWystListener) ExitCall_tree(ctx *Call_treeContext) {} + // EnterAsm is called when production asm is entered. func (s *BaseWystListener) EnterAsm(ctx *AsmContext) {} diff --git a/parser/wyst_lexer.go b/parser/wyst_lexer.go index 7396b9e..832fe49 100644 --- a/parser/wyst_lexer.go +++ b/parser/wyst_lexer.go @@ -43,62 +43,64 @@ func wystlexerLexerInit() { "DEFAULT_MODE", } staticData.LiteralNames = []string{ - "", "'('", "','", "')'", "'='", "'%'", "';'", "'{'", "'}'", + "", "'('", "','", "')'", "'='", "'.'", "'%'", "';'", "'{'", "'}'", } staticData.SymbolicNames = []string{ - "", "", "", "", "", "", "", "", "", "WS", "NUMBER", "HEX", "IDENTIFIER", + "", "", "", "", "", "", "", "", "", "", "WS", "NUMBER", "HEX", "IDENTIFIER", "MATH", "STRING", } staticData.RuleNames = []string{ - "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "WS", - "NUMBER", "HEX", "IDENTIFIER", "MATH", "ESC", "STRING", + "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8", + "WS", "NUMBER", "HEX", "IDENTIFIER", "MATH", "ESC", "STRING", } staticData.PredictionContextCache = antlr.NewPredictionContextCache() staticData.serializedATN = []int32{ - 4, 0, 14, 97, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, + 4, 0, 15, 101, 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, 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, 4, 8, 49, 8, 8, 11, 8, 12, 8, 50, 1, 8, 1, 8, 1, - 9, 1, 9, 5, 9, 57, 8, 9, 10, 9, 12, 9, 60, 9, 9, 1, 9, 3, 9, 63, 8, 9, - 1, 10, 1, 10, 1, 10, 1, 10, 5, 10, 69, 8, 10, 10, 10, 12, 10, 72, 9, 10, - 1, 11, 1, 11, 1, 11, 1, 11, 5, 11, 78, 8, 11, 10, 11, 12, 11, 81, 9, 11, - 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 5, 14, 91, 8, 14, - 10, 14, 12, 14, 94, 9, 14, 1, 14, 1, 14, 0, 0, 15, 1, 1, 3, 2, 5, 3, 7, - 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, - 0, 29, 14, 1, 0, 9, 3, 0, 9, 10, 13, 13, 32, 32, 1, 0, 49, 57, 1, 0, 48, - 57, 3, 0, 48, 57, 65, 70, 97, 102, 3, 0, 65, 90, 95, 95, 97, 122, 3, 0, - 48, 57, 65, 90, 97, 122, 3, 0, 42, 43, 45, 45, 47, 47, 3, 0, 34, 34, 39, - 39, 92, 92, 2, 0, 34, 34, 92, 92, 103, 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, 19, 1, 0, - 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 29, 1, - 0, 0, 0, 1, 31, 1, 0, 0, 0, 3, 33, 1, 0, 0, 0, 5, 35, 1, 0, 0, 0, 7, 37, - 1, 0, 0, 0, 9, 39, 1, 0, 0, 0, 11, 41, 1, 0, 0, 0, 13, 43, 1, 0, 0, 0, - 15, 45, 1, 0, 0, 0, 17, 48, 1, 0, 0, 0, 19, 62, 1, 0, 0, 0, 21, 64, 1, - 0, 0, 0, 23, 73, 1, 0, 0, 0, 25, 82, 1, 0, 0, 0, 27, 84, 1, 0, 0, 0, 29, - 87, 1, 0, 0, 0, 31, 32, 5, 40, 0, 0, 32, 2, 1, 0, 0, 0, 33, 34, 5, 44, - 0, 0, 34, 4, 1, 0, 0, 0, 35, 36, 5, 41, 0, 0, 36, 6, 1, 0, 0, 0, 37, 38, - 5, 61, 0, 0, 38, 8, 1, 0, 0, 0, 39, 40, 5, 37, 0, 0, 40, 10, 1, 0, 0, 0, - 41, 42, 5, 59, 0, 0, 42, 12, 1, 0, 0, 0, 43, 44, 5, 123, 0, 0, 44, 14, - 1, 0, 0, 0, 45, 46, 5, 125, 0, 0, 46, 16, 1, 0, 0, 0, 47, 49, 7, 0, 0, - 0, 48, 47, 1, 0, 0, 0, 49, 50, 1, 0, 0, 0, 50, 48, 1, 0, 0, 0, 50, 51, - 1, 0, 0, 0, 51, 52, 1, 0, 0, 0, 52, 53, 6, 8, 0, 0, 53, 18, 1, 0, 0, 0, - 54, 58, 7, 1, 0, 0, 55, 57, 7, 2, 0, 0, 56, 55, 1, 0, 0, 0, 57, 60, 1, - 0, 0, 0, 58, 56, 1, 0, 0, 0, 58, 59, 1, 0, 0, 0, 59, 63, 1, 0, 0, 0, 60, - 58, 1, 0, 0, 0, 61, 63, 5, 48, 0, 0, 62, 54, 1, 0, 0, 0, 62, 61, 1, 0, - 0, 0, 63, 20, 1, 0, 0, 0, 64, 65, 5, 48, 0, 0, 65, 66, 5, 120, 0, 0, 66, - 70, 1, 0, 0, 0, 67, 69, 7, 3, 0, 0, 68, 67, 1, 0, 0, 0, 69, 72, 1, 0, 0, - 0, 70, 68, 1, 0, 0, 0, 70, 71, 1, 0, 0, 0, 71, 22, 1, 0, 0, 0, 72, 70, - 1, 0, 0, 0, 73, 79, 7, 4, 0, 0, 74, 78, 7, 5, 0, 0, 75, 76, 5, 58, 0, 0, - 76, 78, 5, 58, 0, 0, 77, 74, 1, 0, 0, 0, 77, 75, 1, 0, 0, 0, 78, 81, 1, - 0, 0, 0, 79, 77, 1, 0, 0, 0, 79, 80, 1, 0, 0, 0, 80, 24, 1, 0, 0, 0, 81, - 79, 1, 0, 0, 0, 82, 83, 7, 6, 0, 0, 83, 26, 1, 0, 0, 0, 84, 85, 5, 92, - 0, 0, 85, 86, 7, 7, 0, 0, 86, 28, 1, 0, 0, 0, 87, 92, 5, 34, 0, 0, 88, - 91, 3, 27, 13, 0, 89, 91, 8, 8, 0, 0, 90, 88, 1, 0, 0, 0, 90, 89, 1, 0, - 0, 0, 91, 94, 1, 0, 0, 0, 92, 90, 1, 0, 0, 0, 92, 93, 1, 0, 0, 0, 93, 95, - 1, 0, 0, 0, 94, 92, 1, 0, 0, 0, 95, 96, 5, 34, 0, 0, 96, 30, 1, 0, 0, 0, - 9, 0, 50, 58, 62, 70, 77, 79, 90, 92, 1, 6, 0, 0, + 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, + 7, 15, 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, 9, 4, 9, 53, 8, 9, 11, 9, + 12, 9, 54, 1, 9, 1, 9, 1, 10, 1, 10, 5, 10, 61, 8, 10, 10, 10, 12, 10, + 64, 9, 10, 1, 10, 3, 10, 67, 8, 10, 1, 11, 1, 11, 1, 11, 1, 11, 5, 11, + 73, 8, 11, 10, 11, 12, 11, 76, 9, 11, 1, 12, 1, 12, 1, 12, 1, 12, 5, 12, + 82, 8, 12, 10, 12, 12, 12, 85, 9, 12, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, + 1, 15, 1, 15, 1, 15, 5, 15, 95, 8, 15, 10, 15, 12, 15, 98, 9, 15, 1, 15, + 1, 15, 0, 0, 16, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, + 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 0, 31, 15, 1, 0, 9, 3, 0, + 9, 10, 13, 13, 32, 32, 1, 0, 49, 57, 1, 0, 48, 57, 3, 0, 48, 57, 65, 70, + 97, 102, 3, 0, 65, 90, 95, 95, 97, 122, 4, 0, 48, 57, 65, 90, 95, 95, 97, + 122, 3, 0, 42, 43, 45, 45, 47, 47, 3, 0, 34, 34, 39, 39, 92, 92, 2, 0, + 34, 34, 92, 92, 107, 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, 19, 1, 0, 0, 0, 0, 21, 1, + 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 31, + 1, 0, 0, 0, 1, 33, 1, 0, 0, 0, 3, 35, 1, 0, 0, 0, 5, 37, 1, 0, 0, 0, 7, + 39, 1, 0, 0, 0, 9, 41, 1, 0, 0, 0, 11, 43, 1, 0, 0, 0, 13, 45, 1, 0, 0, + 0, 15, 47, 1, 0, 0, 0, 17, 49, 1, 0, 0, 0, 19, 52, 1, 0, 0, 0, 21, 66, + 1, 0, 0, 0, 23, 68, 1, 0, 0, 0, 25, 77, 1, 0, 0, 0, 27, 86, 1, 0, 0, 0, + 29, 88, 1, 0, 0, 0, 31, 91, 1, 0, 0, 0, 33, 34, 5, 40, 0, 0, 34, 2, 1, + 0, 0, 0, 35, 36, 5, 44, 0, 0, 36, 4, 1, 0, 0, 0, 37, 38, 5, 41, 0, 0, 38, + 6, 1, 0, 0, 0, 39, 40, 5, 61, 0, 0, 40, 8, 1, 0, 0, 0, 41, 42, 5, 46, 0, + 0, 42, 10, 1, 0, 0, 0, 43, 44, 5, 37, 0, 0, 44, 12, 1, 0, 0, 0, 45, 46, + 5, 59, 0, 0, 46, 14, 1, 0, 0, 0, 47, 48, 5, 123, 0, 0, 48, 16, 1, 0, 0, + 0, 49, 50, 5, 125, 0, 0, 50, 18, 1, 0, 0, 0, 51, 53, 7, 0, 0, 0, 52, 51, + 1, 0, 0, 0, 53, 54, 1, 0, 0, 0, 54, 52, 1, 0, 0, 0, 54, 55, 1, 0, 0, 0, + 55, 56, 1, 0, 0, 0, 56, 57, 6, 9, 0, 0, 57, 20, 1, 0, 0, 0, 58, 62, 7, + 1, 0, 0, 59, 61, 7, 2, 0, 0, 60, 59, 1, 0, 0, 0, 61, 64, 1, 0, 0, 0, 62, + 60, 1, 0, 0, 0, 62, 63, 1, 0, 0, 0, 63, 67, 1, 0, 0, 0, 64, 62, 1, 0, 0, + 0, 65, 67, 5, 48, 0, 0, 66, 58, 1, 0, 0, 0, 66, 65, 1, 0, 0, 0, 67, 22, + 1, 0, 0, 0, 68, 69, 5, 48, 0, 0, 69, 70, 5, 120, 0, 0, 70, 74, 1, 0, 0, + 0, 71, 73, 7, 3, 0, 0, 72, 71, 1, 0, 0, 0, 73, 76, 1, 0, 0, 0, 74, 72, + 1, 0, 0, 0, 74, 75, 1, 0, 0, 0, 75, 24, 1, 0, 0, 0, 76, 74, 1, 0, 0, 0, + 77, 83, 7, 4, 0, 0, 78, 82, 7, 5, 0, 0, 79, 80, 5, 58, 0, 0, 80, 82, 5, + 58, 0, 0, 81, 78, 1, 0, 0, 0, 81, 79, 1, 0, 0, 0, 82, 85, 1, 0, 0, 0, 83, + 81, 1, 0, 0, 0, 83, 84, 1, 0, 0, 0, 84, 26, 1, 0, 0, 0, 85, 83, 1, 0, 0, + 0, 86, 87, 7, 6, 0, 0, 87, 28, 1, 0, 0, 0, 88, 89, 5, 92, 0, 0, 89, 90, + 7, 7, 0, 0, 90, 30, 1, 0, 0, 0, 91, 96, 5, 34, 0, 0, 92, 95, 3, 29, 14, + 0, 93, 95, 8, 8, 0, 0, 94, 92, 1, 0, 0, 0, 94, 93, 1, 0, 0, 0, 95, 98, + 1, 0, 0, 0, 96, 94, 1, 0, 0, 0, 96, 97, 1, 0, 0, 0, 97, 99, 1, 0, 0, 0, + 98, 96, 1, 0, 0, 0, 99, 100, 5, 34, 0, 0, 100, 32, 1, 0, 0, 0, 9, 0, 54, + 62, 66, 74, 81, 83, 94, 96, 1, 6, 0, 0, } deserializer := antlr.NewATNDeserializer(nil) staticData.atn = deserializer.Deserialize(staticData.serializedATN) @@ -147,10 +149,11 @@ const ( WystLexerT__5 = 6 WystLexerT__6 = 7 WystLexerT__7 = 8 - WystLexerWS = 9 - WystLexerNUMBER = 10 - WystLexerHEX = 11 - WystLexerIDENTIFIER = 12 - WystLexerMATH = 13 - WystLexerSTRING = 14 + WystLexerT__8 = 9 + WystLexerWS = 10 + WystLexerNUMBER = 11 + WystLexerHEX = 12 + WystLexerIDENTIFIER = 13 + WystLexerMATH = 14 + WystLexerSTRING = 15 ) diff --git a/parser/wyst_listener.go b/parser/wyst_listener.go index e05a5d9..e0e6e3f 100644 --- a/parser/wyst_listener.go +++ b/parser/wyst_listener.go @@ -11,6 +11,12 @@ type WystListener interface { // EnterRound_def is called when entering the round_def production. EnterRound_def(c *Round_defContext) + // EnterRound_call is called when entering the round_call production. + EnterRound_call(c *Round_callContext) + + // EnterFn_call is called when entering the fn_call production. + EnterFn_call(c *Fn_callContext) + // EnterFunc_def is called when entering the func_def production. EnterFunc_def(c *Func_defContext) @@ -20,6 +26,9 @@ type WystListener interface { // EnterVar_def_set is called when entering the var_def_set production. EnterVar_def_set(c *Var_def_setContext) + // EnterCall_tree is called when entering the call_tree production. + EnterCall_tree(c *Call_treeContext) + // EnterAsm is called when entering the asm production. EnterAsm(c *AsmContext) @@ -35,6 +44,12 @@ type WystListener interface { // ExitRound_def is called when exiting the round_def production. ExitRound_def(c *Round_defContext) + // ExitRound_call is called when exiting the round_call production. + ExitRound_call(c *Round_callContext) + + // ExitFn_call is called when exiting the fn_call production. + ExitFn_call(c *Fn_callContext) + // ExitFunc_def is called when exiting the func_def production. ExitFunc_def(c *Func_defContext) @@ -44,6 +59,9 @@ type WystListener interface { // ExitVar_def_set is called when exiting the var_def_set production. ExitVar_def_set(c *Var_def_setContext) + // ExitCall_tree is called when exiting the call_tree production. + ExitCall_tree(c *Call_treeContext) + // ExitAsm is called when exiting the asm production. ExitAsm(c *AsmContext) diff --git a/parser/wyst_parser.go b/parser/wyst_parser.go index 60c32ea..76c5fe0 100644 --- a/parser/wyst_parser.go +++ b/parser/wyst_parser.go @@ -33,53 +33,73 @@ var WystParserStaticData struct { func wystParserInit() { staticData := &WystParserStaticData staticData.LiteralNames = []string{ - "", "'('", "','", "')'", "'='", "'%'", "';'", "'{'", "'}'", + "", "'('", "','", "')'", "'='", "'.'", "'%'", "';'", "'{'", "'}'", } staticData.SymbolicNames = []string{ - "", "", "", "", "", "", "", "", "", "WS", "NUMBER", "HEX", "IDENTIFIER", + "", "", "", "", "", "", "", "", "", "", "WS", "NUMBER", "HEX", "IDENTIFIER", "MATH", "STRING", } staticData.RuleNames = []string{ - "round_def", "func_def", "var_def", "var_def_set", "asm", "expr", "code_block", - "top", + "round_def", "round_call", "fn_call", "func_def", "var_def", "var_def_set", + "call_tree", "asm", "expr", "code_block", "top", } staticData.PredictionContextCache = antlr.NewPredictionContextCache() staticData.serializedATN = []int32{ - 4, 1, 14, 87, 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, 1, 0, 1, 0, 1, 0, 1, 0, 5, 0, 21, - 8, 0, 10, 0, 12, 0, 24, 9, 0, 1, 0, 3, 0, 27, 8, 0, 3, 0, 29, 8, 0, 1, - 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, - 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 5, 4, 50, 8, 4, 10, 4, 12, 4, 53, - 9, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 5, 5, 60, 8, 5, 10, 5, 12, 5, 63, 9, - 5, 1, 6, 1, 6, 1, 6, 1, 6, 3, 6, 69, 8, 6, 1, 6, 1, 6, 5, 6, 73, 8, 6, - 10, 6, 12, 6, 76, 9, 6, 1, 6, 1, 6, 1, 7, 1, 7, 5, 7, 82, 8, 7, 10, 7, - 12, 7, 85, 9, 7, 1, 7, 0, 0, 8, 0, 2, 4, 6, 8, 10, 12, 14, 0, 1, 2, 0, - 10, 12, 14, 14, 88, 0, 16, 1, 0, 0, 0, 2, 32, 1, 0, 0, 0, 4, 37, 1, 0, - 0, 0, 6, 40, 1, 0, 0, 0, 8, 44, 1, 0, 0, 0, 10, 56, 1, 0, 0, 0, 12, 64, - 1, 0, 0, 0, 14, 83, 1, 0, 0, 0, 16, 28, 5, 1, 0, 0, 17, 22, 3, 4, 2, 0, - 18, 19, 5, 2, 0, 0, 19, 21, 3, 4, 2, 0, 20, 18, 1, 0, 0, 0, 21, 24, 1, - 0, 0, 0, 22, 20, 1, 0, 0, 0, 22, 23, 1, 0, 0, 0, 23, 26, 1, 0, 0, 0, 24, - 22, 1, 0, 0, 0, 25, 27, 5, 2, 0, 0, 26, 25, 1, 0, 0, 0, 26, 27, 1, 0, 0, - 0, 27, 29, 1, 0, 0, 0, 28, 17, 1, 0, 0, 0, 28, 29, 1, 0, 0, 0, 29, 30, - 1, 0, 0, 0, 30, 31, 5, 3, 0, 0, 31, 1, 1, 0, 0, 0, 32, 33, 5, 12, 0, 0, - 33, 34, 5, 12, 0, 0, 34, 35, 3, 0, 0, 0, 35, 36, 3, 12, 6, 0, 36, 3, 1, - 0, 0, 0, 37, 38, 5, 12, 0, 0, 38, 39, 5, 12, 0, 0, 39, 5, 1, 0, 0, 0, 40, - 41, 3, 4, 2, 0, 41, 42, 5, 4, 0, 0, 42, 43, 3, 10, 5, 0, 43, 7, 1, 0, 0, - 0, 44, 45, 5, 5, 0, 0, 45, 46, 5, 12, 0, 0, 46, 51, 3, 10, 5, 0, 47, 48, - 5, 2, 0, 0, 48, 50, 3, 10, 5, 0, 49, 47, 1, 0, 0, 0, 50, 53, 1, 0, 0, 0, - 51, 49, 1, 0, 0, 0, 51, 52, 1, 0, 0, 0, 52, 54, 1, 0, 0, 0, 53, 51, 1, - 0, 0, 0, 54, 55, 5, 6, 0, 0, 55, 9, 1, 0, 0, 0, 56, 61, 7, 0, 0, 0, 57, - 58, 5, 13, 0, 0, 58, 60, 3, 10, 5, 0, 59, 57, 1, 0, 0, 0, 60, 63, 1, 0, - 0, 0, 61, 59, 1, 0, 0, 0, 61, 62, 1, 0, 0, 0, 62, 11, 1, 0, 0, 0, 63, 61, - 1, 0, 0, 0, 64, 74, 5, 7, 0, 0, 65, 69, 3, 10, 5, 0, 66, 69, 3, 4, 2, 0, - 67, 69, 3, 6, 3, 0, 68, 65, 1, 0, 0, 0, 68, 66, 1, 0, 0, 0, 68, 67, 1, - 0, 0, 0, 69, 70, 1, 0, 0, 0, 70, 71, 5, 6, 0, 0, 71, 73, 1, 0, 0, 0, 72, - 68, 1, 0, 0, 0, 73, 76, 1, 0, 0, 0, 74, 72, 1, 0, 0, 0, 74, 75, 1, 0, 0, - 0, 75, 77, 1, 0, 0, 0, 76, 74, 1, 0, 0, 0, 77, 78, 5, 8, 0, 0, 78, 13, - 1, 0, 0, 0, 79, 82, 3, 8, 4, 0, 80, 82, 3, 2, 1, 0, 81, 79, 1, 0, 0, 0, - 81, 80, 1, 0, 0, 0, 82, 85, 1, 0, 0, 0, 83, 81, 1, 0, 0, 0, 83, 84, 1, - 0, 0, 0, 84, 15, 1, 0, 0, 0, 85, 83, 1, 0, 0, 0, 9, 22, 26, 28, 51, 61, - 68, 74, 81, 83, + 4, 1, 15, 132, 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, 1, 0, 1, 0, 1, 0, 1, 0, 5, 0, 27, 8, 0, 10, 0, 12, 0, 30, 9, 0, 1, + 0, 3, 0, 33, 8, 0, 3, 0, 35, 8, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, + 5, 1, 43, 8, 1, 10, 1, 12, 1, 46, 9, 1, 1, 1, 3, 1, 49, 8, 1, 3, 1, 51, + 8, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 4, + 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 3, 6, 72, 8, 6, 1, 6, 1, + 6, 1, 6, 3, 6, 77, 8, 6, 5, 6, 79, 8, 6, 10, 6, 12, 6, 82, 9, 6, 1, 7, + 1, 7, 1, 7, 1, 7, 1, 7, 5, 7, 89, 8, 7, 10, 7, 12, 7, 92, 9, 7, 1, 7, 1, + 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 3, 8, 101, 8, 8, 1, 8, 1, 8, 5, 8, 105, + 8, 8, 10, 8, 12, 8, 108, 9, 8, 1, 9, 1, 9, 1, 9, 1, 9, 3, 9, 114, 8, 9, + 1, 9, 1, 9, 5, 9, 118, 8, 9, 10, 9, 12, 9, 121, 9, 9, 1, 9, 1, 9, 1, 10, + 1, 10, 5, 10, 127, 8, 10, 10, 10, 12, 10, 130, 9, 10, 1, 10, 0, 0, 11, + 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 0, 0, 140, 0, 22, 1, 0, 0, 0, 2, + 38, 1, 0, 0, 0, 4, 54, 1, 0, 0, 0, 6, 57, 1, 0, 0, 0, 8, 62, 1, 0, 0, 0, + 10, 65, 1, 0, 0, 0, 12, 71, 1, 0, 0, 0, 14, 83, 1, 0, 0, 0, 16, 100, 1, + 0, 0, 0, 18, 109, 1, 0, 0, 0, 20, 128, 1, 0, 0, 0, 22, 34, 5, 1, 0, 0, + 23, 28, 3, 8, 4, 0, 24, 25, 5, 2, 0, 0, 25, 27, 3, 8, 4, 0, 26, 24, 1, + 0, 0, 0, 27, 30, 1, 0, 0, 0, 28, 26, 1, 0, 0, 0, 28, 29, 1, 0, 0, 0, 29, + 32, 1, 0, 0, 0, 30, 28, 1, 0, 0, 0, 31, 33, 5, 2, 0, 0, 32, 31, 1, 0, 0, + 0, 32, 33, 1, 0, 0, 0, 33, 35, 1, 0, 0, 0, 34, 23, 1, 0, 0, 0, 34, 35, + 1, 0, 0, 0, 35, 36, 1, 0, 0, 0, 36, 37, 5, 3, 0, 0, 37, 1, 1, 0, 0, 0, + 38, 50, 5, 1, 0, 0, 39, 44, 3, 16, 8, 0, 40, 41, 5, 2, 0, 0, 41, 43, 3, + 16, 8, 0, 42, 40, 1, 0, 0, 0, 43, 46, 1, 0, 0, 0, 44, 42, 1, 0, 0, 0, 44, + 45, 1, 0, 0, 0, 45, 48, 1, 0, 0, 0, 46, 44, 1, 0, 0, 0, 47, 49, 5, 2, 0, + 0, 48, 47, 1, 0, 0, 0, 48, 49, 1, 0, 0, 0, 49, 51, 1, 0, 0, 0, 50, 39, + 1, 0, 0, 0, 50, 51, 1, 0, 0, 0, 51, 52, 1, 0, 0, 0, 52, 53, 5, 3, 0, 0, + 53, 3, 1, 0, 0, 0, 54, 55, 5, 13, 0, 0, 55, 56, 3, 2, 1, 0, 56, 5, 1, 0, + 0, 0, 57, 58, 5, 13, 0, 0, 58, 59, 5, 13, 0, 0, 59, 60, 3, 0, 0, 0, 60, + 61, 3, 18, 9, 0, 61, 7, 1, 0, 0, 0, 62, 63, 5, 13, 0, 0, 63, 64, 5, 13, + 0, 0, 64, 9, 1, 0, 0, 0, 65, 66, 3, 8, 4, 0, 66, 67, 5, 4, 0, 0, 67, 68, + 3, 16, 8, 0, 68, 11, 1, 0, 0, 0, 69, 72, 3, 4, 2, 0, 70, 72, 5, 13, 0, + 0, 71, 69, 1, 0, 0, 0, 71, 70, 1, 0, 0, 0, 72, 80, 1, 0, 0, 0, 73, 76, + 5, 5, 0, 0, 74, 77, 3, 4, 2, 0, 75, 77, 5, 13, 0, 0, 76, 74, 1, 0, 0, 0, + 76, 75, 1, 0, 0, 0, 77, 79, 1, 0, 0, 0, 78, 73, 1, 0, 0, 0, 79, 82, 1, + 0, 0, 0, 80, 78, 1, 0, 0, 0, 80, 81, 1, 0, 0, 0, 81, 13, 1, 0, 0, 0, 82, + 80, 1, 0, 0, 0, 83, 84, 5, 6, 0, 0, 84, 85, 5, 13, 0, 0, 85, 90, 3, 16, + 8, 0, 86, 87, 5, 2, 0, 0, 87, 89, 3, 16, 8, 0, 88, 86, 1, 0, 0, 0, 89, + 92, 1, 0, 0, 0, 90, 88, 1, 0, 0, 0, 90, 91, 1, 0, 0, 0, 91, 93, 1, 0, 0, + 0, 92, 90, 1, 0, 0, 0, 93, 94, 5, 7, 0, 0, 94, 15, 1, 0, 0, 0, 95, 101, + 3, 12, 6, 0, 96, 101, 5, 11, 0, 0, 97, 101, 5, 12, 0, 0, 98, 101, 5, 13, + 0, 0, 99, 101, 5, 15, 0, 0, 100, 95, 1, 0, 0, 0, 100, 96, 1, 0, 0, 0, 100, + 97, 1, 0, 0, 0, 100, 98, 1, 0, 0, 0, 100, 99, 1, 0, 0, 0, 101, 106, 1, + 0, 0, 0, 102, 103, 5, 14, 0, 0, 103, 105, 3, 16, 8, 0, 104, 102, 1, 0, + 0, 0, 105, 108, 1, 0, 0, 0, 106, 104, 1, 0, 0, 0, 106, 107, 1, 0, 0, 0, + 107, 17, 1, 0, 0, 0, 108, 106, 1, 0, 0, 0, 109, 119, 5, 8, 0, 0, 110, 114, + 3, 16, 8, 0, 111, 114, 3, 8, 4, 0, 112, 114, 3, 10, 5, 0, 113, 110, 1, + 0, 0, 0, 113, 111, 1, 0, 0, 0, 113, 112, 1, 0, 0, 0, 114, 115, 1, 0, 0, + 0, 115, 116, 5, 7, 0, 0, 116, 118, 1, 0, 0, 0, 117, 113, 1, 0, 0, 0, 118, + 121, 1, 0, 0, 0, 119, 117, 1, 0, 0, 0, 119, 120, 1, 0, 0, 0, 120, 122, + 1, 0, 0, 0, 121, 119, 1, 0, 0, 0, 122, 123, 5, 9, 0, 0, 123, 19, 1, 0, + 0, 0, 124, 127, 3, 14, 7, 0, 125, 127, 3, 6, 3, 0, 126, 124, 1, 0, 0, 0, + 126, 125, 1, 0, 0, 0, 127, 130, 1, 0, 0, 0, 128, 126, 1, 0, 0, 0, 128, + 129, 1, 0, 0, 0, 129, 21, 1, 0, 0, 0, 130, 128, 1, 0, 0, 0, 16, 28, 32, + 34, 44, 48, 50, 71, 76, 80, 90, 100, 106, 113, 119, 126, 128, } deserializer := antlr.NewATNDeserializer(nil) staticData.atn = deserializer.Deserialize(staticData.serializedATN) @@ -126,24 +146,28 @@ const ( WystParserT__5 = 6 WystParserT__6 = 7 WystParserT__7 = 8 - WystParserWS = 9 - WystParserNUMBER = 10 - WystParserHEX = 11 - WystParserIDENTIFIER = 12 - WystParserMATH = 13 - WystParserSTRING = 14 + WystParserT__8 = 9 + WystParserWS = 10 + WystParserNUMBER = 11 + WystParserHEX = 12 + WystParserIDENTIFIER = 13 + WystParserMATH = 14 + WystParserSTRING = 15 ) // WystParser rules. const ( WystParserRULE_round_def = 0 - WystParserRULE_func_def = 1 - WystParserRULE_var_def = 2 - WystParserRULE_var_def_set = 3 - WystParserRULE_asm = 4 - WystParserRULE_expr = 5 - WystParserRULE_code_block = 6 - WystParserRULE_top = 7 + WystParserRULE_round_call = 1 + WystParserRULE_fn_call = 2 + WystParserRULE_func_def = 3 + WystParserRULE_var_def = 4 + WystParserRULE_var_def_set = 5 + WystParserRULE_call_tree = 6 + WystParserRULE_asm = 7 + WystParserRULE_expr = 8 + WystParserRULE_code_block = 9 + WystParserRULE_top = 10 ) // IRound_defContext is an interface to support dynamic dispatch. @@ -263,14 +287,14 @@ func (p *WystParser) Round_def() (localctx IRound_defContext) { p.EnterOuterAlt(localctx, 1) { - p.SetState(16) + p.SetState(22) p.Match(WystParserT__0) if p.HasError() { // Recognition error - abort rule goto errorExit } } - p.SetState(28) + p.SetState(34) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -279,10 +303,10 @@ func (p *WystParser) Round_def() (localctx IRound_defContext) { if _la == WystParserIDENTIFIER { { - p.SetState(17) + p.SetState(23) p.Var_def() } - p.SetState(22) + p.SetState(28) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -294,7 +318,7 @@ func (p *WystParser) Round_def() (localctx IRound_defContext) { for _alt != 2 && _alt != antlr.ATNInvalidAltNumber { if _alt == 1 { { - p.SetState(18) + p.SetState(24) p.Match(WystParserT__1) if p.HasError() { // Recognition error - abort rule @@ -302,12 +326,12 @@ func (p *WystParser) Round_def() (localctx IRound_defContext) { } } { - p.SetState(19) + p.SetState(25) p.Var_def() } } - p.SetState(24) + p.SetState(30) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -317,7 +341,7 @@ func (p *WystParser) Round_def() (localctx IRound_defContext) { goto errorExit } } - p.SetState(26) + p.SetState(32) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -326,7 +350,7 @@ func (p *WystParser) Round_def() (localctx IRound_defContext) { if _la == WystParserT__1 { { - p.SetState(25) + p.SetState(31) p.Match(WystParserT__1) if p.HasError() { // Recognition error - abort rule @@ -338,7 +362,7 @@ func (p *WystParser) Round_def() (localctx IRound_defContext) { } { - p.SetState(30) + p.SetState(36) p.Match(WystParserT__2) if p.HasError() { // Recognition error - abort rule @@ -359,6 +383,336 @@ errorExit: goto errorExit // Trick to prevent compiler error if the label is not used } +// IRound_callContext is an interface to support dynamic dispatch. +type IRound_callContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + + // Getter signatures + AllExpr() []IExprContext + Expr(i int) IExprContext + + // IsRound_callContext differentiates from other interfaces. + IsRound_callContext() +} + +type Round_callContext struct { + antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyRound_callContext() *Round_callContext { + var p = new(Round_callContext) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = WystParserRULE_round_call + return p +} + +func InitEmptyRound_callContext(p *Round_callContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = WystParserRULE_round_call +} + +func (*Round_callContext) IsRound_callContext() {} + +func NewRound_callContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *Round_callContext { + var p = new(Round_callContext) + + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) + + p.parser = parser + p.RuleIndex = WystParserRULE_round_call + + return p +} + +func (s *Round_callContext) GetParser() antlr.Parser { return s.parser } + +func (s *Round_callContext) AllExpr() []IExprContext { + children := s.GetChildren() + len := 0 + for _, ctx := range children { + if _, ok := ctx.(IExprContext); ok { + len++ + } + } + + tst := make([]IExprContext, len) + i := 0 + for _, ctx := range children { + if t, ok := ctx.(IExprContext); ok { + tst[i] = t.(IExprContext) + i++ + } + } + + return tst +} + +func (s *Round_callContext) Expr(i int) IExprContext { + var t antlr.RuleContext + j := 0 + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IExprContext); ok { + if j == i { + t = ctx.(antlr.RuleContext) + break + } + j++ + } + } + + if t == nil { + return nil + } + + return t.(IExprContext) +} + +func (s *Round_callContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *Round_callContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +func (s *Round_callContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(WystListener); ok { + listenerT.EnterRound_call(s) + } +} + +func (s *Round_callContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(WystListener); ok { + listenerT.ExitRound_call(s) + } +} + +func (p *WystParser) Round_call() (localctx IRound_callContext) { + localctx = NewRound_callContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 2, WystParserRULE_round_call) + var _la int + + var _alt int + + p.EnterOuterAlt(localctx, 1) + { + p.SetState(38) + p.Match(WystParserT__0) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + p.SetState(50) + p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } + _la = p.GetTokenStream().LA(1) + + if (int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&47104) != 0 { + { + p.SetState(39) + p.Expr() + } + p.SetState(44) + p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } + _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 3, p.GetParserRuleContext()) + if p.HasError() { + goto errorExit + } + for _alt != 2 && _alt != antlr.ATNInvalidAltNumber { + if _alt == 1 { + { + p.SetState(40) + p.Match(WystParserT__1) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + { + p.SetState(41) + p.Expr() + } + + } + p.SetState(46) + p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } + _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 3, p.GetParserRuleContext()) + if p.HasError() { + goto errorExit + } + } + p.SetState(48) + p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } + _la = p.GetTokenStream().LA(1) + + if _la == WystParserT__1 { + { + p.SetState(47) + p.Match(WystParserT__1) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + + } + + } + { + p.SetState(52) + p.Match(WystParserT__2) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + +errorExit: + if p.HasError() { + v := p.GetError() + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + p.SetError(nil) + } + p.ExitRule() + return localctx + goto errorExit // Trick to prevent compiler error if the label is not used +} + +// IFn_callContext is an interface to support dynamic dispatch. +type IFn_callContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + + // Getter signatures + IDENTIFIER() antlr.TerminalNode + Round_call() IRound_callContext + + // IsFn_callContext differentiates from other interfaces. + IsFn_callContext() +} + +type Fn_callContext struct { + antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyFn_callContext() *Fn_callContext { + var p = new(Fn_callContext) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = WystParserRULE_fn_call + return p +} + +func InitEmptyFn_callContext(p *Fn_callContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = WystParserRULE_fn_call +} + +func (*Fn_callContext) IsFn_callContext() {} + +func NewFn_callContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *Fn_callContext { + var p = new(Fn_callContext) + + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) + + p.parser = parser + p.RuleIndex = WystParserRULE_fn_call + + return p +} + +func (s *Fn_callContext) GetParser() antlr.Parser { return s.parser } + +func (s *Fn_callContext) IDENTIFIER() antlr.TerminalNode { + return s.GetToken(WystParserIDENTIFIER, 0) +} + +func (s *Fn_callContext) Round_call() IRound_callContext { + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IRound_callContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } + + if t == nil { + return nil + } + + return t.(IRound_callContext) +} + +func (s *Fn_callContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *Fn_callContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +func (s *Fn_callContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(WystListener); ok { + listenerT.EnterFn_call(s) + } +} + +func (s *Fn_callContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(WystListener); ok { + listenerT.ExitFn_call(s) + } +} + +func (p *WystParser) Fn_call() (localctx IFn_callContext) { + localctx = NewFn_callContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 4, WystParserRULE_fn_call) + p.EnterOuterAlt(localctx, 1) + { + p.SetState(54) + p.Match(WystParserIDENTIFIER) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + { + p.SetState(55) + p.Round_call() + } + +errorExit: + if p.HasError() { + v := p.GetError() + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + p.SetError(nil) + } + p.ExitRule() + return localctx + goto errorExit // Trick to prevent compiler error if the label is not used +} + // IFunc_defContext is an interface to support dynamic dispatch. type IFunc_defContext interface { antlr.ParserRuleContext @@ -470,10 +824,10 @@ func (s *Func_defContext) ExitRule(listener antlr.ParseTreeListener) { func (p *WystParser) Func_def() (localctx IFunc_defContext) { localctx = NewFunc_defContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 2, WystParserRULE_func_def) + p.EnterRule(localctx, 6, WystParserRULE_func_def) p.EnterOuterAlt(localctx, 1) { - p.SetState(32) + p.SetState(57) p.Match(WystParserIDENTIFIER) if p.HasError() { // Recognition error - abort rule @@ -481,7 +835,7 @@ func (p *WystParser) Func_def() (localctx IFunc_defContext) { } } { - p.SetState(33) + p.SetState(58) p.Match(WystParserIDENTIFIER) if p.HasError() { // Recognition error - abort rule @@ -489,11 +843,11 @@ func (p *WystParser) Func_def() (localctx IFunc_defContext) { } } { - p.SetState(34) + p.SetState(59) p.Round_def() } { - p.SetState(35) + p.SetState(60) p.Code_block() } @@ -587,10 +941,10 @@ func (s *Var_defContext) ExitRule(listener antlr.ParseTreeListener) { func (p *WystParser) Var_def() (localctx IVar_defContext) { localctx = NewVar_defContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 4, WystParserRULE_var_def) + p.EnterRule(localctx, 8, WystParserRULE_var_def) p.EnterOuterAlt(localctx, 1) { - p.SetState(37) + p.SetState(62) p.Match(WystParserIDENTIFIER) if p.HasError() { // Recognition error - abort rule @@ -598,7 +952,7 @@ func (p *WystParser) Var_def() (localctx IVar_defContext) { } } { - p.SetState(38) + p.SetState(63) p.Match(WystParserIDENTIFIER) if p.HasError() { // Recognition error - abort rule @@ -720,14 +1074,14 @@ func (s *Var_def_setContext) ExitRule(listener antlr.ParseTreeListener) { func (p *WystParser) Var_def_set() (localctx IVar_def_setContext) { localctx = NewVar_def_setContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 6, WystParserRULE_var_def_set) + p.EnterRule(localctx, 10, WystParserRULE_var_def_set) p.EnterOuterAlt(localctx, 1) { - p.SetState(40) + p.SetState(65) p.Var_def() } { - p.SetState(41) + p.SetState(66) p.Match(WystParserT__3) if p.HasError() { // Recognition error - abort rule @@ -735,7 +1089,7 @@ func (p *WystParser) Var_def_set() (localctx IVar_def_setContext) { } } { - p.SetState(42) + p.SetState(67) p.Expr() } @@ -752,6 +1106,220 @@ errorExit: goto errorExit // Trick to prevent compiler error if the label is not used } +// ICall_treeContext is an interface to support dynamic dispatch. +type ICall_treeContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + + // Getter signatures + AllFn_call() []IFn_callContext + Fn_call(i int) IFn_callContext + AllIDENTIFIER() []antlr.TerminalNode + IDENTIFIER(i int) antlr.TerminalNode + + // IsCall_treeContext differentiates from other interfaces. + IsCall_treeContext() +} + +type Call_treeContext struct { + antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyCall_treeContext() *Call_treeContext { + var p = new(Call_treeContext) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = WystParserRULE_call_tree + return p +} + +func InitEmptyCall_treeContext(p *Call_treeContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = WystParserRULE_call_tree +} + +func (*Call_treeContext) IsCall_treeContext() {} + +func NewCall_treeContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *Call_treeContext { + var p = new(Call_treeContext) + + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) + + p.parser = parser + p.RuleIndex = WystParserRULE_call_tree + + return p +} + +func (s *Call_treeContext) GetParser() antlr.Parser { return s.parser } + +func (s *Call_treeContext) AllFn_call() []IFn_callContext { + children := s.GetChildren() + len := 0 + for _, ctx := range children { + if _, ok := ctx.(IFn_callContext); ok { + len++ + } + } + + tst := make([]IFn_callContext, len) + i := 0 + for _, ctx := range children { + if t, ok := ctx.(IFn_callContext); ok { + tst[i] = t.(IFn_callContext) + i++ + } + } + + return tst +} + +func (s *Call_treeContext) Fn_call(i int) IFn_callContext { + var t antlr.RuleContext + j := 0 + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IFn_callContext); ok { + if j == i { + t = ctx.(antlr.RuleContext) + break + } + j++ + } + } + + if t == nil { + return nil + } + + return t.(IFn_callContext) +} + +func (s *Call_treeContext) AllIDENTIFIER() []antlr.TerminalNode { + return s.GetTokens(WystParserIDENTIFIER) +} + +func (s *Call_treeContext) IDENTIFIER(i int) antlr.TerminalNode { + return s.GetToken(WystParserIDENTIFIER, i) +} + +func (s *Call_treeContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *Call_treeContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +func (s *Call_treeContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(WystListener); ok { + listenerT.EnterCall_tree(s) + } +} + +func (s *Call_treeContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(WystListener); ok { + listenerT.ExitCall_tree(s) + } +} + +func (p *WystParser) Call_tree() (localctx ICall_treeContext) { + localctx = NewCall_treeContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 12, WystParserRULE_call_tree) + var _la int + + p.EnterOuterAlt(localctx, 1) + p.SetState(71) + p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } + + switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 6, p.GetParserRuleContext()) { + case 1: + { + p.SetState(69) + p.Fn_call() + } + + case 2: + { + p.SetState(70) + p.Match(WystParserIDENTIFIER) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + + case antlr.ATNInvalidAltNumber: + goto errorExit + } + p.SetState(80) + p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } + _la = p.GetTokenStream().LA(1) + + for _la == WystParserT__4 { + { + p.SetState(73) + p.Match(WystParserT__4) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + p.SetState(76) + p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } + + switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 7, p.GetParserRuleContext()) { + case 1: + { + p.SetState(74) + p.Fn_call() + } + + case 2: + { + p.SetState(75) + p.Match(WystParserIDENTIFIER) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + + case antlr.ATNInvalidAltNumber: + goto errorExit + } + + p.SetState(82) + p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } + _la = p.GetTokenStream().LA(1) + } + +errorExit: + if p.HasError() { + v := p.GetError() + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + p.SetError(nil) + } + p.ExitRule() + return localctx + goto errorExit // Trick to prevent compiler error if the label is not used +} + // IAsmContext is an interface to support dynamic dispatch. type IAsmContext interface { antlr.ParserRuleContext @@ -867,20 +1435,20 @@ func (s *AsmContext) ExitRule(listener antlr.ParseTreeListener) { func (p *WystParser) Asm() (localctx IAsmContext) { localctx = NewAsmContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 8, WystParserRULE_asm) + p.EnterRule(localctx, 14, WystParserRULE_asm) var _la int p.EnterOuterAlt(localctx, 1) { - p.SetState(44) - p.Match(WystParserT__4) + p.SetState(83) + p.Match(WystParserT__5) if p.HasError() { // Recognition error - abort rule goto errorExit } } { - p.SetState(45) + p.SetState(84) p.Match(WystParserIDENTIFIER) if p.HasError() { // Recognition error - abort rule @@ -888,10 +1456,10 @@ func (p *WystParser) Asm() (localctx IAsmContext) { } } { - p.SetState(46) + p.SetState(85) p.Expr() } - p.SetState(51) + p.SetState(90) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -900,7 +1468,7 @@ func (p *WystParser) Asm() (localctx IAsmContext) { for _la == WystParserT__1 { { - p.SetState(47) + p.SetState(86) p.Match(WystParserT__1) if p.HasError() { // Recognition error - abort rule @@ -908,11 +1476,11 @@ func (p *WystParser) Asm() (localctx IAsmContext) { } } { - p.SetState(48) + p.SetState(87) p.Expr() } - p.SetState(53) + p.SetState(92) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -920,8 +1488,8 @@ func (p *WystParser) Asm() (localctx IAsmContext) { _la = p.GetTokenStream().LA(1) } { - p.SetState(54) - p.Match(WystParserT__5) + p.SetState(93) + p.Match(WystParserT__6) if p.HasError() { // Recognition error - abort rule goto errorExit @@ -949,6 +1517,7 @@ type IExprContext interface { GetParser() antlr.Parser // Getter signatures + Call_tree() ICall_treeContext NUMBER() antlr.TerminalNode HEX() antlr.TerminalNode IDENTIFIER() antlr.TerminalNode @@ -994,6 +1563,22 @@ func NewExprContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokin func (s *ExprContext) GetParser() antlr.Parser { return s.parser } +func (s *ExprContext) Call_tree() ICall_treeContext { + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(ICall_treeContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } + + if t == nil { + return nil + } + + return t.(ICall_treeContext) +} + func (s *ExprContext) NUMBER() antlr.TerminalNode { return s.GetToken(WystParserNUMBER, 0) } @@ -1081,36 +1666,79 @@ func (s *ExprContext) ExitRule(listener antlr.ParseTreeListener) { func (p *WystParser) Expr() (localctx IExprContext) { localctx = NewExprContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 10, WystParserRULE_expr) - var _la int - + p.EnterRule(localctx, 16, WystParserRULE_expr) var _alt int p.EnterOuterAlt(localctx, 1) - { - p.SetState(56) - _la = p.GetTokenStream().LA(1) - - if !((int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&23552) != 0) { - p.GetErrorHandler().RecoverInline(p) - } else { - p.GetErrorHandler().ReportMatch(p) - p.Consume() - } - } - p.SetState(61) + p.SetState(100) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } - _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 4, p.GetParserRuleContext()) + + switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 10, p.GetParserRuleContext()) { + case 1: + { + p.SetState(95) + p.Call_tree() + } + + case 2: + { + p.SetState(96) + p.Match(WystParserNUMBER) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + + case 3: + { + p.SetState(97) + p.Match(WystParserHEX) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + + case 4: + { + p.SetState(98) + p.Match(WystParserIDENTIFIER) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + + case 5: + { + p.SetState(99) + p.Match(WystParserSTRING) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + + case antlr.ATNInvalidAltNumber: + goto errorExit + } + p.SetState(106) + p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } + _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 11, p.GetParserRuleContext()) if p.HasError() { goto errorExit } for _alt != 2 && _alt != antlr.ATNInvalidAltNumber { if _alt == 1 { { - p.SetState(57) + p.SetState(102) p.Match(WystParserMATH) if p.HasError() { // Recognition error - abort rule @@ -1118,17 +1746,17 @@ func (p *WystParser) Expr() (localctx IExprContext) { } } { - p.SetState(58) + p.SetState(103) p.Expr() } } - p.SetState(63) + p.SetState(108) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } - _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 4, p.GetParserRuleContext()) + _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 11, p.GetParserRuleContext()) if p.HasError() { goto errorExit } @@ -1343,48 +1971,48 @@ func (s *Code_blockContext) ExitRule(listener antlr.ParseTreeListener) { func (p *WystParser) Code_block() (localctx ICode_blockContext) { localctx = NewCode_blockContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 12, WystParserRULE_code_block) + p.EnterRule(localctx, 18, WystParserRULE_code_block) var _la int p.EnterOuterAlt(localctx, 1) { - p.SetState(64) - p.Match(WystParserT__6) + p.SetState(109) + p.Match(WystParserT__7) if p.HasError() { // Recognition error - abort rule goto errorExit } } - p.SetState(74) + p.SetState(119) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } _la = p.GetTokenStream().LA(1) - for (int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&23552) != 0 { - p.SetState(68) + for (int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&47104) != 0 { + p.SetState(113) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } - switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 5, p.GetParserRuleContext()) { + switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 12, p.GetParserRuleContext()) { case 1: { - p.SetState(65) + p.SetState(110) p.Expr() } case 2: { - p.SetState(66) + p.SetState(111) p.Var_def() } case 3: { - p.SetState(67) + p.SetState(112) p.Var_def_set() } @@ -1392,15 +2020,15 @@ func (p *WystParser) Code_block() (localctx ICode_blockContext) { goto errorExit } { - p.SetState(70) - p.Match(WystParserT__5) + p.SetState(115) + p.Match(WystParserT__6) if p.HasError() { // Recognition error - abort rule goto errorExit } } - p.SetState(76) + p.SetState(121) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -1408,8 +2036,8 @@ func (p *WystParser) Code_block() (localctx ICode_blockContext) { _la = p.GetTokenStream().LA(1) } { - p.SetState(77) - p.Match(WystParserT__7) + p.SetState(122) + p.Match(WystParserT__8) if p.HasError() { // Recognition error - abort rule goto errorExit @@ -1582,34 +2210,34 @@ func (s *TopContext) ExitRule(listener antlr.ParseTreeListener) { func (p *WystParser) Top() (localctx ITopContext) { localctx = NewTopContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 14, WystParserRULE_top) + p.EnterRule(localctx, 20, WystParserRULE_top) var _la int p.EnterOuterAlt(localctx, 1) - p.SetState(83) + p.SetState(128) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } _la = p.GetTokenStream().LA(1) - for _la == WystParserT__4 || _la == WystParserIDENTIFIER { - p.SetState(81) + for _la == WystParserT__5 || _la == WystParserIDENTIFIER { + p.SetState(126) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } switch p.GetTokenStream().LA(1) { - case WystParserT__4: + case WystParserT__5: { - p.SetState(79) + p.SetState(124) p.Asm() } case WystParserIDENTIFIER: { - p.SetState(80) + p.SetState(125) p.Func_def() } @@ -1618,7 +2246,7 @@ func (p *WystParser) Top() (localctx ITopContext) { goto errorExit } - p.SetState(85) + p.SetState(130) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit diff --git a/src/parser.go b/src/parser.go index 872a92a..6617795 100644 --- a/src/parser.go +++ b/src/parser.go @@ -37,7 +37,7 @@ func ConvertAST(node antlr.Tree, wparser *parser.WystParser, lexer *parser.WystL } for i := 0; i < node.GetChildCount(); i++ { l := ConvertAST(node.GetChild(i), wparser, lexer) - if l.Rule != ("'"+l.Text+"'") || l.Text == ";" { + if l.Rule != ("'"+l.Text+"'") || l.Text == ";" || l.Text == "," { ast.Inner = append(ast.Inner, l) } } diff --git a/src/transpiler.go b/src/transpiler.go index 6256ca5..fe532c9 100644 --- a/src/transpiler.go +++ b/src/transpiler.go @@ -29,6 +29,7 @@ func TranspileToken(node ASTNode) string { res += fmt.Sprintf("%x", c) } } + res = strings.ReplaceAll(res, "::", "::_0x") case "HEX": res += node.Text case "MATH": @@ -37,6 +38,8 @@ func TranspileToken(node ASTNode) string { res += node.Text case "';'": res += "\n " + case "','": + res += ", " default: fmt.Printf("\x1b[33mDEV NOTICE:\x1b[0m Missing token case for '%s'\n", node.Rule) @@ -57,19 +60,29 @@ func TranspileNode(node ASTNode) string { case "expr": res += TranspileNodes(node.Inner) case "code_block": - res += "{\n " - res += strings.TrimSuffix(TranspileNodes(node.Inner), " ") - res += "}\n" + res += fmt.Sprintf("{\n %s}", strings.TrimSuffix(TranspileNodes(node.Inner), " ")) case "var_def": res += fmt.Sprintf("var %s %s", TranspileNode(node.Inner[1]), TranspileNode(node.Inner[0])) case "round_def": - res += "(" - res += strings.TrimSuffix(strings.ReplaceAll(TranspileNodes(node.Inner), "var ", ""), " ") - res += ")" + fmt.Sprintf("(%s)", strings.TrimSuffix(strings.ReplaceAll(TranspileNodes(node.Inner), "var ", ""), " ")) case "asm": if node.Inner[0].Text == "map" && len(node.Inner) == 4 { wyst_map = append(wyst_map, wmap{node.Inner[1].Text, node.Inner[2].Text}) } + case "call_tree": + for i, c := range node.Inner { + res += TranspileNode(c) + if i+1 < len(node.Inner) { + res += "." + } + } + + case "fn_call": + res += TranspileNode(node.Inner[0]) + res += TranspileNode(node.Inner[1]) + + case "round_call": + res += fmt.Sprintf("(%s)", TranspileNodes(node.Inner)) default: fmt.Printf("\x1b[33mDEV NOTICE:\x1b[0m Missing case for '%s'\n", node.Rule) diff --git a/test/main.wst b/test/main.wst index 632016f..79a589f 100644 --- a/test/main.wst +++ b/test/main.wst @@ -1,2 +1,5 @@ -%map test, hi; -int main(test x) {} \ No newline at end of file +%map _, _; + +int main(test x) { + x::h.y.z(0, "test"); +} \ No newline at end of file