From 2f7cdb97ccd2d0b2ba7bff8aa6e66231534097a4 Mon Sep 17 00:00:00 2001 From: Leo dev Date: Tue, 20 Aug 2024 02:11:57 +0200 Subject: [PATCH] namespaces & structs --- Wyst.g4 | 13 +- parser/Wyst.interp | 22 +- parser/Wyst.tokens | 30 +- parser/WystLexer.interp | 19 +- parser/WystLexer.tokens | 30 +- parser/wyst_base_listener.go | 32 +- parser/wyst_lexer.go | 125 ++-- parser/wyst_listener.go | 32 +- parser/wyst_parser.go | 1278 ++++++++++++++++++++++++++++------ src/transpiler.go | 34 +- test/main.wst | 6 +- 11 files changed, 1296 insertions(+), 325 deletions(-) diff --git a/Wyst.g4 b/Wyst.g4 index fc4f022..5b58256 100644 --- a/Wyst.g4 +++ b/Wyst.g4 @@ -8,13 +8,17 @@ MATH: '+' | '-' | '*' | '/'; fragment ESC: '\\' ['"\\] ; STRING: '"' (ESC | ~["\\])* '"'; round_def: '(' (var_def (',' var_def)* ','?)? ')'; +enum_curly: '{' (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)* ';'; +struct_def: 'struct' IDENTIFIER enum_curly; +power_keyword: 'map'; +power_keyword_call: '#' power_keyword expr (',' expr)* ';'; +namespace: 'namespace' IDENTIFIER '{' (((var_def|var_def_set) ';')|func_def)* '}'; expr: ( @@ -30,4 +34,9 @@ code_block: '{' (( var_def | var_def_set ) ';')* '}'; -top: (asm|func_def)*; \ No newline at end of file +top: ( + power_keyword_call | + func_def | + struct_def | + namespace +)*; \ No newline at end of file diff --git a/parser/Wyst.interp b/parser/Wyst.interp index 111c50c..413b691 100644 --- a/parser/Wyst.interp +++ b/parser/Wyst.interp @@ -3,12 +3,15 @@ null '(' ',' ')' +'{' +';' +'}' '=' '.' -'%' -';' -'{' -'}' +'struct' +'map' +'#' +'namespace' null null null @@ -27,6 +30,9 @@ null null null null +null +null +null WS NUMBER HEX @@ -36,17 +42,21 @@ STRING rule names: round_def +enum_curly round_call fn_call func_def var_def var_def_set call_tree -asm +struct_def +power_keyword +power_keyword_call +namespace expr code_block top atn: -[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 +[4, 1, 18, 176, 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, 0, 1, 0, 5, 0, 35, 8, 0, 10, 0, 12, 0, 38, 9, 0, 1, 0, 3, 0, 41, 8, 0, 3, 0, 43, 8, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 51, 8, 1, 10, 1, 12, 1, 54, 9, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 5, 2, 62, 8, 2, 10, 2, 12, 2, 65, 9, 2, 1, 2, 3, 2, 68, 8, 2, 3, 2, 70, 8, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 3, 7, 91, 8, 7, 1, 7, 1, 7, 1, 7, 3, 7, 96, 8, 7, 5, 7, 98, 8, 7, 10, 7, 12, 7, 101, 9, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 5, 10, 114, 8, 10, 10, 10, 12, 10, 117, 9, 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 3, 11, 126, 8, 11, 1, 11, 1, 11, 1, 11, 5, 11, 131, 8, 11, 10, 11, 12, 11, 134, 9, 11, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 3, 12, 143, 8, 12, 1, 12, 1, 12, 5, 12, 147, 8, 12, 10, 12, 12, 12, 150, 9, 12, 1, 13, 1, 13, 1, 13, 1, 13, 3, 13, 156, 8, 13, 1, 13, 1, 13, 5, 13, 160, 8, 13, 10, 13, 12, 13, 163, 9, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 14, 5, 14, 171, 8, 14, 10, 14, 12, 14, 174, 9, 14, 1, 14, 0, 0, 15, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 0, 0, 186, 0, 30, 1, 0, 0, 0, 2, 46, 1, 0, 0, 0, 4, 57, 1, 0, 0, 0, 6, 73, 1, 0, 0, 0, 8, 76, 1, 0, 0, 0, 10, 81, 1, 0, 0, 0, 12, 84, 1, 0, 0, 0, 14, 90, 1, 0, 0, 0, 16, 102, 1, 0, 0, 0, 18, 106, 1, 0, 0, 0, 20, 108, 1, 0, 0, 0, 22, 120, 1, 0, 0, 0, 24, 142, 1, 0, 0, 0, 26, 151, 1, 0, 0, 0, 28, 172, 1, 0, 0, 0, 30, 42, 5, 1, 0, 0, 31, 36, 3, 10, 5, 0, 32, 33, 5, 2, 0, 0, 33, 35, 3, 10, 5, 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, 40, 1, 0, 0, 0, 38, 36, 1, 0, 0, 0, 39, 41, 5, 2, 0, 0, 40, 39, 1, 0, 0, 0, 40, 41, 1, 0, 0, 0, 41, 43, 1, 0, 0, 0, 42, 31, 1, 0, 0, 0, 42, 43, 1, 0, 0, 0, 43, 44, 1, 0, 0, 0, 44, 45, 5, 3, 0, 0, 45, 1, 1, 0, 0, 0, 46, 52, 5, 4, 0, 0, 47, 48, 3, 10, 5, 0, 48, 49, 5, 5, 0, 0, 49, 51, 1, 0, 0, 0, 50, 47, 1, 0, 0, 0, 51, 54, 1, 0, 0, 0, 52, 50, 1, 0, 0, 0, 52, 53, 1, 0, 0, 0, 53, 55, 1, 0, 0, 0, 54, 52, 1, 0, 0, 0, 55, 56, 5, 6, 0, 0, 56, 3, 1, 0, 0, 0, 57, 69, 5, 1, 0, 0, 58, 63, 3, 24, 12, 0, 59, 60, 5, 2, 0, 0, 60, 62, 3, 24, 12, 0, 61, 59, 1, 0, 0, 0, 62, 65, 1, 0, 0, 0, 63, 61, 1, 0, 0, 0, 63, 64, 1, 0, 0, 0, 64, 67, 1, 0, 0, 0, 65, 63, 1, 0, 0, 0, 66, 68, 5, 2, 0, 0, 67, 66, 1, 0, 0, 0, 67, 68, 1, 0, 0, 0, 68, 70, 1, 0, 0, 0, 69, 58, 1, 0, 0, 0, 69, 70, 1, 0, 0, 0, 70, 71, 1, 0, 0, 0, 71, 72, 5, 3, 0, 0, 72, 5, 1, 0, 0, 0, 73, 74, 5, 16, 0, 0, 74, 75, 3, 4, 2, 0, 75, 7, 1, 0, 0, 0, 76, 77, 5, 16, 0, 0, 77, 78, 5, 16, 0, 0, 78, 79, 3, 0, 0, 0, 79, 80, 3, 26, 13, 0, 80, 9, 1, 0, 0, 0, 81, 82, 5, 16, 0, 0, 82, 83, 5, 16, 0, 0, 83, 11, 1, 0, 0, 0, 84, 85, 3, 10, 5, 0, 85, 86, 5, 7, 0, 0, 86, 87, 3, 24, 12, 0, 87, 13, 1, 0, 0, 0, 88, 91, 3, 6, 3, 0, 89, 91, 5, 16, 0, 0, 90, 88, 1, 0, 0, 0, 90, 89, 1, 0, 0, 0, 91, 99, 1, 0, 0, 0, 92, 95, 5, 8, 0, 0, 93, 96, 3, 6, 3, 0, 94, 96, 5, 16, 0, 0, 95, 93, 1, 0, 0, 0, 95, 94, 1, 0, 0, 0, 96, 98, 1, 0, 0, 0, 97, 92, 1, 0, 0, 0, 98, 101, 1, 0, 0, 0, 99, 97, 1, 0, 0, 0, 99, 100, 1, 0, 0, 0, 100, 15, 1, 0, 0, 0, 101, 99, 1, 0, 0, 0, 102, 103, 5, 9, 0, 0, 103, 104, 5, 16, 0, 0, 104, 105, 3, 2, 1, 0, 105, 17, 1, 0, 0, 0, 106, 107, 5, 10, 0, 0, 107, 19, 1, 0, 0, 0, 108, 109, 5, 11, 0, 0, 109, 110, 3, 18, 9, 0, 110, 115, 3, 24, 12, 0, 111, 112, 5, 2, 0, 0, 112, 114, 3, 24, 12, 0, 113, 111, 1, 0, 0, 0, 114, 117, 1, 0, 0, 0, 115, 113, 1, 0, 0, 0, 115, 116, 1, 0, 0, 0, 116, 118, 1, 0, 0, 0, 117, 115, 1, 0, 0, 0, 118, 119, 5, 5, 0, 0, 119, 21, 1, 0, 0, 0, 120, 121, 5, 12, 0, 0, 121, 122, 5, 16, 0, 0, 122, 132, 5, 4, 0, 0, 123, 126, 3, 10, 5, 0, 124, 126, 3, 12, 6, 0, 125, 123, 1, 0, 0, 0, 125, 124, 1, 0, 0, 0, 126, 127, 1, 0, 0, 0, 127, 128, 5, 5, 0, 0, 128, 131, 1, 0, 0, 0, 129, 131, 3, 8, 4, 0, 130, 125, 1, 0, 0, 0, 130, 129, 1, 0, 0, 0, 131, 134, 1, 0, 0, 0, 132, 130, 1, 0, 0, 0, 132, 133, 1, 0, 0, 0, 133, 135, 1, 0, 0, 0, 134, 132, 1, 0, 0, 0, 135, 136, 5, 6, 0, 0, 136, 23, 1, 0, 0, 0, 137, 143, 3, 14, 7, 0, 138, 143, 5, 14, 0, 0, 139, 143, 5, 15, 0, 0, 140, 143, 5, 16, 0, 0, 141, 143, 5, 18, 0, 0, 142, 137, 1, 0, 0, 0, 142, 138, 1, 0, 0, 0, 142, 139, 1, 0, 0, 0, 142, 140, 1, 0, 0, 0, 142, 141, 1, 0, 0, 0, 143, 148, 1, 0, 0, 0, 144, 145, 5, 17, 0, 0, 145, 147, 3, 24, 12, 0, 146, 144, 1, 0, 0, 0, 147, 150, 1, 0, 0, 0, 148, 146, 1, 0, 0, 0, 148, 149, 1, 0, 0, 0, 149, 25, 1, 0, 0, 0, 150, 148, 1, 0, 0, 0, 151, 161, 5, 4, 0, 0, 152, 156, 3, 24, 12, 0, 153, 156, 3, 10, 5, 0, 154, 156, 3, 12, 6, 0, 155, 152, 1, 0, 0, 0, 155, 153, 1, 0, 0, 0, 155, 154, 1, 0, 0, 0, 156, 157, 1, 0, 0, 0, 157, 158, 5, 5, 0, 0, 158, 160, 1, 0, 0, 0, 159, 155, 1, 0, 0, 0, 160, 163, 1, 0, 0, 0, 161, 159, 1, 0, 0, 0, 161, 162, 1, 0, 0, 0, 162, 164, 1, 0, 0, 0, 163, 161, 1, 0, 0, 0, 164, 165, 5, 6, 0, 0, 165, 27, 1, 0, 0, 0, 166, 171, 3, 20, 10, 0, 167, 171, 3, 8, 4, 0, 168, 171, 3, 16, 8, 0, 169, 171, 3, 22, 11, 0, 170, 166, 1, 0, 0, 0, 170, 167, 1, 0, 0, 0, 170, 168, 1, 0, 0, 0, 170, 169, 1, 0, 0, 0, 171, 174, 1, 0, 0, 0, 172, 170, 1, 0, 0, 0, 172, 173, 1, 0, 0, 0, 173, 29, 1, 0, 0, 0, 174, 172, 1, 0, 0, 0, 20, 36, 40, 42, 52, 63, 67, 69, 90, 95, 99, 115, 125, 130, 132, 142, 148, 155, 161, 170, 172] \ No newline at end of file diff --git a/parser/Wyst.tokens b/parser/Wyst.tokens index f26bf47..603d454 100644 --- a/parser/Wyst.tokens +++ b/parser/Wyst.tokens @@ -7,18 +7,24 @@ T__5=6 T__6=7 T__7=8 T__8=9 -WS=10 -NUMBER=11 -HEX=12 -IDENTIFIER=13 -MATH=14 -STRING=15 +T__9=10 +T__10=11 +T__11=12 +WS=13 +NUMBER=14 +HEX=15 +IDENTIFIER=16 +MATH=17 +STRING=18 '('=1 ','=2 ')'=3 -'='=4 -'.'=5 -'%'=6 -';'=7 -'{'=8 -'}'=9 +'{'=4 +';'=5 +'}'=6 +'='=7 +'.'=8 +'struct'=9 +'map'=10 +'#'=11 +'namespace'=12 diff --git a/parser/WystLexer.interp b/parser/WystLexer.interp index 43a845f..0394788 100644 --- a/parser/WystLexer.interp +++ b/parser/WystLexer.interp @@ -3,12 +3,15 @@ null '(' ',' ')' +'{' +';' +'}' '=' '.' -'%' -';' -'{' -'}' +'struct' +'map' +'#' +'namespace' null null null @@ -27,6 +30,9 @@ null null null null +null +null +null WS NUMBER HEX @@ -44,6 +50,9 @@ T__5 T__6 T__7 T__8 +T__9 +T__10 +T__11 WS NUMBER HEX @@ -60,4 +69,4 @@ mode names: DEFAULT_MODE atn: -[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 +[4, 0, 18, 128, 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, 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, 8, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 12, 4, 12, 80, 8, 12, 11, 12, 12, 12, 81, 1, 12, 1, 12, 1, 13, 1, 13, 5, 13, 88, 8, 13, 10, 13, 12, 13, 91, 9, 13, 1, 13, 3, 13, 94, 8, 13, 1, 14, 1, 14, 1, 14, 1, 14, 5, 14, 100, 8, 14, 10, 14, 12, 14, 103, 9, 14, 1, 15, 1, 15, 1, 15, 1, 15, 5, 15, 109, 8, 15, 10, 15, 12, 15, 112, 9, 15, 1, 16, 1, 16, 1, 17, 1, 17, 1, 17, 1, 18, 1, 18, 1, 18, 5, 18, 122, 8, 18, 10, 18, 12, 18, 125, 9, 18, 1, 18, 1, 18, 0, 0, 19, 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, 15, 31, 16, 33, 17, 35, 0, 37, 18, 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, 134, 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, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 1, 39, 1, 0, 0, 0, 3, 41, 1, 0, 0, 0, 5, 43, 1, 0, 0, 0, 7, 45, 1, 0, 0, 0, 9, 47, 1, 0, 0, 0, 11, 49, 1, 0, 0, 0, 13, 51, 1, 0, 0, 0, 15, 53, 1, 0, 0, 0, 17, 55, 1, 0, 0, 0, 19, 62, 1, 0, 0, 0, 21, 66, 1, 0, 0, 0, 23, 68, 1, 0, 0, 0, 25, 79, 1, 0, 0, 0, 27, 93, 1, 0, 0, 0, 29, 95, 1, 0, 0, 0, 31, 104, 1, 0, 0, 0, 33, 113, 1, 0, 0, 0, 35, 115, 1, 0, 0, 0, 37, 118, 1, 0, 0, 0, 39, 40, 5, 40, 0, 0, 40, 2, 1, 0, 0, 0, 41, 42, 5, 44, 0, 0, 42, 4, 1, 0, 0, 0, 43, 44, 5, 41, 0, 0, 44, 6, 1, 0, 0, 0, 45, 46, 5, 123, 0, 0, 46, 8, 1, 0, 0, 0, 47, 48, 5, 59, 0, 0, 48, 10, 1, 0, 0, 0, 49, 50, 5, 125, 0, 0, 50, 12, 1, 0, 0, 0, 51, 52, 5, 61, 0, 0, 52, 14, 1, 0, 0, 0, 53, 54, 5, 46, 0, 0, 54, 16, 1, 0, 0, 0, 55, 56, 5, 115, 0, 0, 56, 57, 5, 116, 0, 0, 57, 58, 5, 114, 0, 0, 58, 59, 5, 117, 0, 0, 59, 60, 5, 99, 0, 0, 60, 61, 5, 116, 0, 0, 61, 18, 1, 0, 0, 0, 62, 63, 5, 109, 0, 0, 63, 64, 5, 97, 0, 0, 64, 65, 5, 112, 0, 0, 65, 20, 1, 0, 0, 0, 66, 67, 5, 35, 0, 0, 67, 22, 1, 0, 0, 0, 68, 69, 5, 110, 0, 0, 69, 70, 5, 97, 0, 0, 70, 71, 5, 109, 0, 0, 71, 72, 5, 101, 0, 0, 72, 73, 5, 115, 0, 0, 73, 74, 5, 112, 0, 0, 74, 75, 5, 97, 0, 0, 75, 76, 5, 99, 0, 0, 76, 77, 5, 101, 0, 0, 77, 24, 1, 0, 0, 0, 78, 80, 7, 0, 0, 0, 79, 78, 1, 0, 0, 0, 80, 81, 1, 0, 0, 0, 81, 79, 1, 0, 0, 0, 81, 82, 1, 0, 0, 0, 82, 83, 1, 0, 0, 0, 83, 84, 6, 12, 0, 0, 84, 26, 1, 0, 0, 0, 85, 89, 7, 1, 0, 0, 86, 88, 7, 2, 0, 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, 94, 1, 0, 0, 0, 91, 89, 1, 0, 0, 0, 92, 94, 5, 48, 0, 0, 93, 85, 1, 0, 0, 0, 93, 92, 1, 0, 0, 0, 94, 28, 1, 0, 0, 0, 95, 96, 5, 48, 0, 0, 96, 97, 5, 120, 0, 0, 97, 101, 1, 0, 0, 0, 98, 100, 7, 3, 0, 0, 99, 98, 1, 0, 0, 0, 100, 103, 1, 0, 0, 0, 101, 99, 1, 0, 0, 0, 101, 102, 1, 0, 0, 0, 102, 30, 1, 0, 0, 0, 103, 101, 1, 0, 0, 0, 104, 110, 7, 4, 0, 0, 105, 109, 7, 5, 0, 0, 106, 107, 5, 58, 0, 0, 107, 109, 5, 58, 0, 0, 108, 105, 1, 0, 0, 0, 108, 106, 1, 0, 0, 0, 109, 112, 1, 0, 0, 0, 110, 108, 1, 0, 0, 0, 110, 111, 1, 0, 0, 0, 111, 32, 1, 0, 0, 0, 112, 110, 1, 0, 0, 0, 113, 114, 7, 6, 0, 0, 114, 34, 1, 0, 0, 0, 115, 116, 5, 92, 0, 0, 116, 117, 7, 7, 0, 0, 117, 36, 1, 0, 0, 0, 118, 123, 5, 34, 0, 0, 119, 122, 3, 35, 17, 0, 120, 122, 8, 8, 0, 0, 121, 119, 1, 0, 0, 0, 121, 120, 1, 0, 0, 0, 122, 125, 1, 0, 0, 0, 123, 121, 1, 0, 0, 0, 123, 124, 1, 0, 0, 0, 124, 126, 1, 0, 0, 0, 125, 123, 1, 0, 0, 0, 126, 127, 5, 34, 0, 0, 127, 38, 1, 0, 0, 0, 9, 0, 81, 89, 93, 101, 108, 110, 121, 123, 1, 6, 0, 0] \ No newline at end of file diff --git a/parser/WystLexer.tokens b/parser/WystLexer.tokens index f26bf47..603d454 100644 --- a/parser/WystLexer.tokens +++ b/parser/WystLexer.tokens @@ -7,18 +7,24 @@ T__5=6 T__6=7 T__7=8 T__8=9 -WS=10 -NUMBER=11 -HEX=12 -IDENTIFIER=13 -MATH=14 -STRING=15 +T__9=10 +T__10=11 +T__11=12 +WS=13 +NUMBER=14 +HEX=15 +IDENTIFIER=16 +MATH=17 +STRING=18 '('=1 ','=2 ')'=3 -'='=4 -'.'=5 -'%'=6 -';'=7 -'{'=8 -'}'=9 +'{'=4 +';'=5 +'}'=6 +'='=7 +'.'=8 +'struct'=9 +'map'=10 +'#'=11 +'namespace'=12 diff --git a/parser/wyst_base_listener.go b/parser/wyst_base_listener.go index 48a555b..386403c 100644 --- a/parser/wyst_base_listener.go +++ b/parser/wyst_base_listener.go @@ -27,6 +27,12 @@ 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) {} +// EnterEnum_curly is called when production enum_curly is entered. +func (s *BaseWystListener) EnterEnum_curly(ctx *Enum_curlyContext) {} + +// ExitEnum_curly is called when production enum_curly is exited. +func (s *BaseWystListener) ExitEnum_curly(ctx *Enum_curlyContext) {} + // EnterRound_call is called when production round_call is entered. func (s *BaseWystListener) EnterRound_call(ctx *Round_callContext) {} @@ -63,11 +69,29 @@ 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) {} +// EnterStruct_def is called when production struct_def is entered. +func (s *BaseWystListener) EnterStruct_def(ctx *Struct_defContext) {} -// ExitAsm is called when production asm is exited. -func (s *BaseWystListener) ExitAsm(ctx *AsmContext) {} +// ExitStruct_def is called when production struct_def is exited. +func (s *BaseWystListener) ExitStruct_def(ctx *Struct_defContext) {} + +// EnterPower_keyword is called when production power_keyword is entered. +func (s *BaseWystListener) EnterPower_keyword(ctx *Power_keywordContext) {} + +// ExitPower_keyword is called when production power_keyword is exited. +func (s *BaseWystListener) ExitPower_keyword(ctx *Power_keywordContext) {} + +// EnterPower_keyword_call is called when production power_keyword_call is entered. +func (s *BaseWystListener) EnterPower_keyword_call(ctx *Power_keyword_callContext) {} + +// ExitPower_keyword_call is called when production power_keyword_call is exited. +func (s *BaseWystListener) ExitPower_keyword_call(ctx *Power_keyword_callContext) {} + +// EnterNamespace is called when production namespace is entered. +func (s *BaseWystListener) EnterNamespace(ctx *NamespaceContext) {} + +// ExitNamespace is called when production namespace is exited. +func (s *BaseWystListener) ExitNamespace(ctx *NamespaceContext) {} // EnterExpr is called when production expr is entered. func (s *BaseWystListener) EnterExpr(ctx *ExprContext) {} diff --git a/parser/wyst_lexer.go b/parser/wyst_lexer.go index 832fe49..5e97cb6 100644 --- a/parser/wyst_lexer.go +++ b/parser/wyst_lexer.go @@ -43,64 +43,78 @@ func wystlexerLexerInit() { "DEFAULT_MODE", } staticData.LiteralNames = []string{ - "", "'('", "','", "')'", "'='", "'.'", "'%'", "';'", "'{'", "'}'", + "", "'('", "','", "')'", "'{'", "';'", "'}'", "'='", "'.'", "'struct'", + "'map'", "'#'", "'namespace'", } staticData.SymbolicNames = []string{ - "", "", "", "", "", "", "", "", "", "", "WS", "NUMBER", "HEX", "IDENTIFIER", - "MATH", "STRING", + "", "", "", "", "", "", "", "", "", "", "", "", "", "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", "T__8", - "WS", "NUMBER", "HEX", "IDENTIFIER", "MATH", "ESC", "STRING", + "T__9", "T__10", "T__11", "WS", "NUMBER", "HEX", "IDENTIFIER", "MATH", + "ESC", "STRING", } staticData.PredictionContextCache = antlr.NewPredictionContextCache() staticData.serializedATN = []int32{ - 4, 0, 15, 101, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, + 4, 0, 18, 128, 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, + 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 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, 8, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 10, + 1, 10, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, + 11, 1, 12, 4, 12, 80, 8, 12, 11, 12, 12, 12, 81, 1, 12, 1, 12, 1, 13, 1, + 13, 5, 13, 88, 8, 13, 10, 13, 12, 13, 91, 9, 13, 1, 13, 3, 13, 94, 8, 13, + 1, 14, 1, 14, 1, 14, 1, 14, 5, 14, 100, 8, 14, 10, 14, 12, 14, 103, 9, + 14, 1, 15, 1, 15, 1, 15, 1, 15, 5, 15, 109, 8, 15, 10, 15, 12, 15, 112, + 9, 15, 1, 16, 1, 16, 1, 17, 1, 17, 1, 17, 1, 18, 1, 18, 1, 18, 5, 18, 122, + 8, 18, 10, 18, 12, 18, 125, 9, 18, 1, 18, 1, 18, 0, 0, 19, 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, 15, 31, 16, 33, 17, 35, 0, 37, 18, 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, 134, 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, 29, 1, 0, 0, + 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 1, 39, 1, 0, + 0, 0, 3, 41, 1, 0, 0, 0, 5, 43, 1, 0, 0, 0, 7, 45, 1, 0, 0, 0, 9, 47, 1, + 0, 0, 0, 11, 49, 1, 0, 0, 0, 13, 51, 1, 0, 0, 0, 15, 53, 1, 0, 0, 0, 17, + 55, 1, 0, 0, 0, 19, 62, 1, 0, 0, 0, 21, 66, 1, 0, 0, 0, 23, 68, 1, 0, 0, + 0, 25, 79, 1, 0, 0, 0, 27, 93, 1, 0, 0, 0, 29, 95, 1, 0, 0, 0, 31, 104, + 1, 0, 0, 0, 33, 113, 1, 0, 0, 0, 35, 115, 1, 0, 0, 0, 37, 118, 1, 0, 0, + 0, 39, 40, 5, 40, 0, 0, 40, 2, 1, 0, 0, 0, 41, 42, 5, 44, 0, 0, 42, 4, + 1, 0, 0, 0, 43, 44, 5, 41, 0, 0, 44, 6, 1, 0, 0, 0, 45, 46, 5, 123, 0, + 0, 46, 8, 1, 0, 0, 0, 47, 48, 5, 59, 0, 0, 48, 10, 1, 0, 0, 0, 49, 50, + 5, 125, 0, 0, 50, 12, 1, 0, 0, 0, 51, 52, 5, 61, 0, 0, 52, 14, 1, 0, 0, + 0, 53, 54, 5, 46, 0, 0, 54, 16, 1, 0, 0, 0, 55, 56, 5, 115, 0, 0, 56, 57, + 5, 116, 0, 0, 57, 58, 5, 114, 0, 0, 58, 59, 5, 117, 0, 0, 59, 60, 5, 99, + 0, 0, 60, 61, 5, 116, 0, 0, 61, 18, 1, 0, 0, 0, 62, 63, 5, 109, 0, 0, 63, + 64, 5, 97, 0, 0, 64, 65, 5, 112, 0, 0, 65, 20, 1, 0, 0, 0, 66, 67, 5, 35, + 0, 0, 67, 22, 1, 0, 0, 0, 68, 69, 5, 110, 0, 0, 69, 70, 5, 97, 0, 0, 70, + 71, 5, 109, 0, 0, 71, 72, 5, 101, 0, 0, 72, 73, 5, 115, 0, 0, 73, 74, 5, + 112, 0, 0, 74, 75, 5, 97, 0, 0, 75, 76, 5, 99, 0, 0, 76, 77, 5, 101, 0, + 0, 77, 24, 1, 0, 0, 0, 78, 80, 7, 0, 0, 0, 79, 78, 1, 0, 0, 0, 80, 81, + 1, 0, 0, 0, 81, 79, 1, 0, 0, 0, 81, 82, 1, 0, 0, 0, 82, 83, 1, 0, 0, 0, + 83, 84, 6, 12, 0, 0, 84, 26, 1, 0, 0, 0, 85, 89, 7, 1, 0, 0, 86, 88, 7, + 2, 0, 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, 94, 1, 0, 0, 0, 91, 89, 1, 0, 0, 0, 92, 94, 5, 48, + 0, 0, 93, 85, 1, 0, 0, 0, 93, 92, 1, 0, 0, 0, 94, 28, 1, 0, 0, 0, 95, 96, + 5, 48, 0, 0, 96, 97, 5, 120, 0, 0, 97, 101, 1, 0, 0, 0, 98, 100, 7, 3, + 0, 0, 99, 98, 1, 0, 0, 0, 100, 103, 1, 0, 0, 0, 101, 99, 1, 0, 0, 0, 101, + 102, 1, 0, 0, 0, 102, 30, 1, 0, 0, 0, 103, 101, 1, 0, 0, 0, 104, 110, 7, + 4, 0, 0, 105, 109, 7, 5, 0, 0, 106, 107, 5, 58, 0, 0, 107, 109, 5, 58, + 0, 0, 108, 105, 1, 0, 0, 0, 108, 106, 1, 0, 0, 0, 109, 112, 1, 0, 0, 0, + 110, 108, 1, 0, 0, 0, 110, 111, 1, 0, 0, 0, 111, 32, 1, 0, 0, 0, 112, 110, + 1, 0, 0, 0, 113, 114, 7, 6, 0, 0, 114, 34, 1, 0, 0, 0, 115, 116, 5, 92, + 0, 0, 116, 117, 7, 7, 0, 0, 117, 36, 1, 0, 0, 0, 118, 123, 5, 34, 0, 0, + 119, 122, 3, 35, 17, 0, 120, 122, 8, 8, 0, 0, 121, 119, 1, 0, 0, 0, 121, + 120, 1, 0, 0, 0, 122, 125, 1, 0, 0, 0, 123, 121, 1, 0, 0, 0, 123, 124, + 1, 0, 0, 0, 124, 126, 1, 0, 0, 0, 125, 123, 1, 0, 0, 0, 126, 127, 5, 34, + 0, 0, 127, 38, 1, 0, 0, 0, 9, 0, 81, 89, 93, 101, 108, 110, 121, 123, 1, + 6, 0, 0, } deserializer := antlr.NewATNDeserializer(nil) staticData.atn = deserializer.Deserialize(staticData.serializedATN) @@ -150,10 +164,13 @@ const ( WystLexerT__6 = 7 WystLexerT__7 = 8 WystLexerT__8 = 9 - WystLexerWS = 10 - WystLexerNUMBER = 11 - WystLexerHEX = 12 - WystLexerIDENTIFIER = 13 - WystLexerMATH = 14 - WystLexerSTRING = 15 + WystLexerT__9 = 10 + WystLexerT__10 = 11 + WystLexerT__11 = 12 + WystLexerWS = 13 + WystLexerNUMBER = 14 + WystLexerHEX = 15 + WystLexerIDENTIFIER = 16 + WystLexerMATH = 17 + WystLexerSTRING = 18 ) diff --git a/parser/wyst_listener.go b/parser/wyst_listener.go index e0e6e3f..baa2c5b 100644 --- a/parser/wyst_listener.go +++ b/parser/wyst_listener.go @@ -11,6 +11,9 @@ type WystListener interface { // EnterRound_def is called when entering the round_def production. EnterRound_def(c *Round_defContext) + // EnterEnum_curly is called when entering the enum_curly production. + EnterEnum_curly(c *Enum_curlyContext) + // EnterRound_call is called when entering the round_call production. EnterRound_call(c *Round_callContext) @@ -29,8 +32,17 @@ type WystListener interface { // 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) + // EnterStruct_def is called when entering the struct_def production. + EnterStruct_def(c *Struct_defContext) + + // EnterPower_keyword is called when entering the power_keyword production. + EnterPower_keyword(c *Power_keywordContext) + + // EnterPower_keyword_call is called when entering the power_keyword_call production. + EnterPower_keyword_call(c *Power_keyword_callContext) + + // EnterNamespace is called when entering the namespace production. + EnterNamespace(c *NamespaceContext) // EnterExpr is called when entering the expr production. EnterExpr(c *ExprContext) @@ -44,6 +56,9 @@ type WystListener interface { // ExitRound_def is called when exiting the round_def production. ExitRound_def(c *Round_defContext) + // ExitEnum_curly is called when exiting the enum_curly production. + ExitEnum_curly(c *Enum_curlyContext) + // ExitRound_call is called when exiting the round_call production. ExitRound_call(c *Round_callContext) @@ -62,8 +77,17 @@ type WystListener interface { // 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) + // ExitStruct_def is called when exiting the struct_def production. + ExitStruct_def(c *Struct_defContext) + + // ExitPower_keyword is called when exiting the power_keyword production. + ExitPower_keyword(c *Power_keywordContext) + + // ExitPower_keyword_call is called when exiting the power_keyword_call production. + ExitPower_keyword_call(c *Power_keyword_callContext) + + // ExitNamespace is called when exiting the namespace production. + ExitNamespace(c *NamespaceContext) // ExitExpr is called when exiting the expr production. ExitExpr(c *ExprContext) diff --git a/parser/wyst_parser.go b/parser/wyst_parser.go index 76c5fe0..79a3095 100644 --- a/parser/wyst_parser.go +++ b/parser/wyst_parser.go @@ -33,73 +33,95 @@ var WystParserStaticData struct { func wystParserInit() { staticData := &WystParserStaticData staticData.LiteralNames = []string{ - "", "'('", "','", "')'", "'='", "'.'", "'%'", "';'", "'{'", "'}'", + "", "'('", "','", "')'", "'{'", "';'", "'}'", "'='", "'.'", "'struct'", + "'map'", "'#'", "'namespace'", } staticData.SymbolicNames = []string{ - "", "", "", "", "", "", "", "", "", "", "WS", "NUMBER", "HEX", "IDENTIFIER", - "MATH", "STRING", + "", "", "", "", "", "", "", "", "", "", "", "", "", "WS", "NUMBER", + "HEX", "IDENTIFIER", "MATH", "STRING", } staticData.RuleNames = []string{ - "round_def", "round_call", "fn_call", "func_def", "var_def", "var_def_set", - "call_tree", "asm", "expr", "code_block", "top", + "round_def", "enum_curly", "round_call", "fn_call", "func_def", "var_def", + "var_def_set", "call_tree", "struct_def", "power_keyword", "power_keyword_call", + "namespace", "expr", "code_block", "top", } staticData.PredictionContextCache = antlr.NewPredictionContextCache() staticData.serializedATN = []int32{ - 4, 1, 15, 132, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, + 4, 1, 18, 176, 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, + 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 1, 0, 1, 0, + 1, 0, 1, 0, 5, 0, 35, 8, 0, 10, 0, 12, 0, 38, 9, 0, 1, 0, 3, 0, 41, 8, + 0, 3, 0, 43, 8, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 51, 8, 1, + 10, 1, 12, 1, 54, 9, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 5, 2, 62, 8, + 2, 10, 2, 12, 2, 65, 9, 2, 1, 2, 3, 2, 68, 8, 2, 3, 2, 70, 8, 2, 1, 2, + 1, 2, 1, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, + 1, 6, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 3, 7, 91, 8, 7, 1, 7, 1, 7, 1, 7, 3, + 7, 96, 8, 7, 5, 7, 98, 8, 7, 10, 7, 12, 7, 101, 9, 7, 1, 8, 1, 8, 1, 8, + 1, 8, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 5, 10, 114, 8, 10, + 10, 10, 12, 10, 117, 9, 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 11, 1, + 11, 3, 11, 126, 8, 11, 1, 11, 1, 11, 1, 11, 5, 11, 131, 8, 11, 10, 11, + 12, 11, 134, 9, 11, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 3, + 12, 143, 8, 12, 1, 12, 1, 12, 5, 12, 147, 8, 12, 10, 12, 12, 12, 150, 9, + 12, 1, 13, 1, 13, 1, 13, 1, 13, 3, 13, 156, 8, 13, 1, 13, 1, 13, 5, 13, + 160, 8, 13, 10, 13, 12, 13, 163, 9, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, + 14, 1, 14, 5, 14, 171, 8, 14, 10, 14, 12, 14, 174, 9, 14, 1, 14, 0, 0, + 15, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 0, 0, 186, 0, + 30, 1, 0, 0, 0, 2, 46, 1, 0, 0, 0, 4, 57, 1, 0, 0, 0, 6, 73, 1, 0, 0, 0, + 8, 76, 1, 0, 0, 0, 10, 81, 1, 0, 0, 0, 12, 84, 1, 0, 0, 0, 14, 90, 1, 0, + 0, 0, 16, 102, 1, 0, 0, 0, 18, 106, 1, 0, 0, 0, 20, 108, 1, 0, 0, 0, 22, + 120, 1, 0, 0, 0, 24, 142, 1, 0, 0, 0, 26, 151, 1, 0, 0, 0, 28, 172, 1, + 0, 0, 0, 30, 42, 5, 1, 0, 0, 31, 36, 3, 10, 5, 0, 32, 33, 5, 2, 0, 0, 33, + 35, 3, 10, 5, 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, 40, 1, 0, 0, 0, 38, 36, 1, 0, 0, 0, 39, 41, + 5, 2, 0, 0, 40, 39, 1, 0, 0, 0, 40, 41, 1, 0, 0, 0, 41, 43, 1, 0, 0, 0, + 42, 31, 1, 0, 0, 0, 42, 43, 1, 0, 0, 0, 43, 44, 1, 0, 0, 0, 44, 45, 5, + 3, 0, 0, 45, 1, 1, 0, 0, 0, 46, 52, 5, 4, 0, 0, 47, 48, 3, 10, 5, 0, 48, + 49, 5, 5, 0, 0, 49, 51, 1, 0, 0, 0, 50, 47, 1, 0, 0, 0, 51, 54, 1, 0, 0, + 0, 52, 50, 1, 0, 0, 0, 52, 53, 1, 0, 0, 0, 53, 55, 1, 0, 0, 0, 54, 52, + 1, 0, 0, 0, 55, 56, 5, 6, 0, 0, 56, 3, 1, 0, 0, 0, 57, 69, 5, 1, 0, 0, + 58, 63, 3, 24, 12, 0, 59, 60, 5, 2, 0, 0, 60, 62, 3, 24, 12, 0, 61, 59, + 1, 0, 0, 0, 62, 65, 1, 0, 0, 0, 63, 61, 1, 0, 0, 0, 63, 64, 1, 0, 0, 0, + 64, 67, 1, 0, 0, 0, 65, 63, 1, 0, 0, 0, 66, 68, 5, 2, 0, 0, 67, 66, 1, + 0, 0, 0, 67, 68, 1, 0, 0, 0, 68, 70, 1, 0, 0, 0, 69, 58, 1, 0, 0, 0, 69, + 70, 1, 0, 0, 0, 70, 71, 1, 0, 0, 0, 71, 72, 5, 3, 0, 0, 72, 5, 1, 0, 0, + 0, 73, 74, 5, 16, 0, 0, 74, 75, 3, 4, 2, 0, 75, 7, 1, 0, 0, 0, 76, 77, + 5, 16, 0, 0, 77, 78, 5, 16, 0, 0, 78, 79, 3, 0, 0, 0, 79, 80, 3, 26, 13, + 0, 80, 9, 1, 0, 0, 0, 81, 82, 5, 16, 0, 0, 82, 83, 5, 16, 0, 0, 83, 11, + 1, 0, 0, 0, 84, 85, 3, 10, 5, 0, 85, 86, 5, 7, 0, 0, 86, 87, 3, 24, 12, + 0, 87, 13, 1, 0, 0, 0, 88, 91, 3, 6, 3, 0, 89, 91, 5, 16, 0, 0, 90, 88, + 1, 0, 0, 0, 90, 89, 1, 0, 0, 0, 91, 99, 1, 0, 0, 0, 92, 95, 5, 8, 0, 0, + 93, 96, 3, 6, 3, 0, 94, 96, 5, 16, 0, 0, 95, 93, 1, 0, 0, 0, 95, 94, 1, + 0, 0, 0, 96, 98, 1, 0, 0, 0, 97, 92, 1, 0, 0, 0, 98, 101, 1, 0, 0, 0, 99, + 97, 1, 0, 0, 0, 99, 100, 1, 0, 0, 0, 100, 15, 1, 0, 0, 0, 101, 99, 1, 0, + 0, 0, 102, 103, 5, 9, 0, 0, 103, 104, 5, 16, 0, 0, 104, 105, 3, 2, 1, 0, + 105, 17, 1, 0, 0, 0, 106, 107, 5, 10, 0, 0, 107, 19, 1, 0, 0, 0, 108, 109, + 5, 11, 0, 0, 109, 110, 3, 18, 9, 0, 110, 115, 3, 24, 12, 0, 111, 112, 5, + 2, 0, 0, 112, 114, 3, 24, 12, 0, 113, 111, 1, 0, 0, 0, 114, 117, 1, 0, + 0, 0, 115, 113, 1, 0, 0, 0, 115, 116, 1, 0, 0, 0, 116, 118, 1, 0, 0, 0, + 117, 115, 1, 0, 0, 0, 118, 119, 5, 5, 0, 0, 119, 21, 1, 0, 0, 0, 120, 121, + 5, 12, 0, 0, 121, 122, 5, 16, 0, 0, 122, 132, 5, 4, 0, 0, 123, 126, 3, + 10, 5, 0, 124, 126, 3, 12, 6, 0, 125, 123, 1, 0, 0, 0, 125, 124, 1, 0, + 0, 0, 126, 127, 1, 0, 0, 0, 127, 128, 5, 5, 0, 0, 128, 131, 1, 0, 0, 0, + 129, 131, 3, 8, 4, 0, 130, 125, 1, 0, 0, 0, 130, 129, 1, 0, 0, 0, 131, + 134, 1, 0, 0, 0, 132, 130, 1, 0, 0, 0, 132, 133, 1, 0, 0, 0, 133, 135, + 1, 0, 0, 0, 134, 132, 1, 0, 0, 0, 135, 136, 5, 6, 0, 0, 136, 23, 1, 0, + 0, 0, 137, 143, 3, 14, 7, 0, 138, 143, 5, 14, 0, 0, 139, 143, 5, 15, 0, + 0, 140, 143, 5, 16, 0, 0, 141, 143, 5, 18, 0, 0, 142, 137, 1, 0, 0, 0, + 142, 138, 1, 0, 0, 0, 142, 139, 1, 0, 0, 0, 142, 140, 1, 0, 0, 0, 142, + 141, 1, 0, 0, 0, 143, 148, 1, 0, 0, 0, 144, 145, 5, 17, 0, 0, 145, 147, + 3, 24, 12, 0, 146, 144, 1, 0, 0, 0, 147, 150, 1, 0, 0, 0, 148, 146, 1, + 0, 0, 0, 148, 149, 1, 0, 0, 0, 149, 25, 1, 0, 0, 0, 150, 148, 1, 0, 0, + 0, 151, 161, 5, 4, 0, 0, 152, 156, 3, 24, 12, 0, 153, 156, 3, 10, 5, 0, + 154, 156, 3, 12, 6, 0, 155, 152, 1, 0, 0, 0, 155, 153, 1, 0, 0, 0, 155, + 154, 1, 0, 0, 0, 156, 157, 1, 0, 0, 0, 157, 158, 5, 5, 0, 0, 158, 160, + 1, 0, 0, 0, 159, 155, 1, 0, 0, 0, 160, 163, 1, 0, 0, 0, 161, 159, 1, 0, + 0, 0, 161, 162, 1, 0, 0, 0, 162, 164, 1, 0, 0, 0, 163, 161, 1, 0, 0, 0, + 164, 165, 5, 6, 0, 0, 165, 27, 1, 0, 0, 0, 166, 171, 3, 20, 10, 0, 167, + 171, 3, 8, 4, 0, 168, 171, 3, 16, 8, 0, 169, 171, 3, 22, 11, 0, 170, 166, + 1, 0, 0, 0, 170, 167, 1, 0, 0, 0, 170, 168, 1, 0, 0, 0, 170, 169, 1, 0, + 0, 0, 171, 174, 1, 0, 0, 0, 172, 170, 1, 0, 0, 0, 172, 173, 1, 0, 0, 0, + 173, 29, 1, 0, 0, 0, 174, 172, 1, 0, 0, 0, 20, 36, 40, 42, 52, 63, 67, + 69, 90, 95, 99, 115, 125, 130, 132, 142, 148, 155, 161, 170, 172, } deserializer := antlr.NewATNDeserializer(nil) staticData.atn = deserializer.Deserialize(staticData.serializedATN) @@ -147,27 +169,34 @@ const ( WystParserT__6 = 7 WystParserT__7 = 8 WystParserT__8 = 9 - WystParserWS = 10 - WystParserNUMBER = 11 - WystParserHEX = 12 - WystParserIDENTIFIER = 13 - WystParserMATH = 14 - WystParserSTRING = 15 + WystParserT__9 = 10 + WystParserT__10 = 11 + WystParserT__11 = 12 + WystParserWS = 13 + WystParserNUMBER = 14 + WystParserHEX = 15 + WystParserIDENTIFIER = 16 + WystParserMATH = 17 + WystParserSTRING = 18 ) // WystParser rules. const ( - WystParserRULE_round_def = 0 - 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 + WystParserRULE_round_def = 0 + WystParserRULE_enum_curly = 1 + WystParserRULE_round_call = 2 + WystParserRULE_fn_call = 3 + WystParserRULE_func_def = 4 + WystParserRULE_var_def = 5 + WystParserRULE_var_def_set = 6 + WystParserRULE_call_tree = 7 + WystParserRULE_struct_def = 8 + WystParserRULE_power_keyword = 9 + WystParserRULE_power_keyword_call = 10 + WystParserRULE_namespace = 11 + WystParserRULE_expr = 12 + WystParserRULE_code_block = 13 + WystParserRULE_top = 14 ) // IRound_defContext is an interface to support dynamic dispatch. @@ -287,14 +316,14 @@ func (p *WystParser) Round_def() (localctx IRound_defContext) { p.EnterOuterAlt(localctx, 1) { - p.SetState(22) + p.SetState(30) p.Match(WystParserT__0) if p.HasError() { // Recognition error - abort rule goto errorExit } } - p.SetState(34) + p.SetState(42) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -303,10 +332,10 @@ func (p *WystParser) Round_def() (localctx IRound_defContext) { if _la == WystParserIDENTIFIER { { - p.SetState(23) + p.SetState(31) p.Var_def() } - p.SetState(28) + p.SetState(36) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -318,7 +347,7 @@ func (p *WystParser) Round_def() (localctx IRound_defContext) { for _alt != 2 && _alt != antlr.ATNInvalidAltNumber { if _alt == 1 { { - p.SetState(24) + p.SetState(32) p.Match(WystParserT__1) if p.HasError() { // Recognition error - abort rule @@ -326,12 +355,12 @@ func (p *WystParser) Round_def() (localctx IRound_defContext) { } } { - p.SetState(25) + p.SetState(33) p.Var_def() } } - p.SetState(30) + p.SetState(38) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -341,7 +370,7 @@ func (p *WystParser) Round_def() (localctx IRound_defContext) { goto errorExit } } - p.SetState(32) + p.SetState(40) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -350,7 +379,7 @@ func (p *WystParser) Round_def() (localctx IRound_defContext) { if _la == WystParserT__1 { { - p.SetState(31) + p.SetState(39) p.Match(WystParserT__1) if p.HasError() { // Recognition error - abort rule @@ -362,7 +391,7 @@ func (p *WystParser) Round_def() (localctx IRound_defContext) { } { - p.SetState(36) + p.SetState(44) p.Match(WystParserT__2) if p.HasError() { // Recognition error - abort rule @@ -383,6 +412,178 @@ errorExit: goto errorExit // Trick to prevent compiler error if the label is not used } +// IEnum_curlyContext is an interface to support dynamic dispatch. +type IEnum_curlyContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + + // Getter signatures + AllVar_def() []IVar_defContext + Var_def(i int) IVar_defContext + + // IsEnum_curlyContext differentiates from other interfaces. + IsEnum_curlyContext() +} + +type Enum_curlyContext struct { + antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyEnum_curlyContext() *Enum_curlyContext { + var p = new(Enum_curlyContext) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = WystParserRULE_enum_curly + return p +} + +func InitEmptyEnum_curlyContext(p *Enum_curlyContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = WystParserRULE_enum_curly +} + +func (*Enum_curlyContext) IsEnum_curlyContext() {} + +func NewEnum_curlyContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *Enum_curlyContext { + var p = new(Enum_curlyContext) + + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) + + p.parser = parser + p.RuleIndex = WystParserRULE_enum_curly + + return p +} + +func (s *Enum_curlyContext) GetParser() antlr.Parser { return s.parser } + +func (s *Enum_curlyContext) AllVar_def() []IVar_defContext { + children := s.GetChildren() + len := 0 + for _, ctx := range children { + if _, ok := ctx.(IVar_defContext); ok { + len++ + } + } + + tst := make([]IVar_defContext, len) + i := 0 + for _, ctx := range children { + if t, ok := ctx.(IVar_defContext); ok { + tst[i] = t.(IVar_defContext) + i++ + } + } + + return tst +} + +func (s *Enum_curlyContext) Var_def(i int) IVar_defContext { + var t antlr.RuleContext + j := 0 + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IVar_defContext); ok { + if j == i { + t = ctx.(antlr.RuleContext) + break + } + j++ + } + } + + if t == nil { + return nil + } + + return t.(IVar_defContext) +} + +func (s *Enum_curlyContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *Enum_curlyContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +func (s *Enum_curlyContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(WystListener); ok { + listenerT.EnterEnum_curly(s) + } +} + +func (s *Enum_curlyContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(WystListener); ok { + listenerT.ExitEnum_curly(s) + } +} + +func (p *WystParser) Enum_curly() (localctx IEnum_curlyContext) { + localctx = NewEnum_curlyContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 2, WystParserRULE_enum_curly) + var _la int + + p.EnterOuterAlt(localctx, 1) + { + p.SetState(46) + p.Match(WystParserT__3) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + p.SetState(52) + p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } + _la = p.GetTokenStream().LA(1) + + for _la == WystParserIDENTIFIER { + { + p.SetState(47) + p.Var_def() + } + { + p.SetState(48) + p.Match(WystParserT__4) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + + p.SetState(54) + p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(55) + p.Match(WystParserT__5) + 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 +} + // IRound_callContext is an interface to support dynamic dispatch. type IRound_callContext interface { antlr.ParserRuleContext @@ -493,45 +694,45 @@ func (s *Round_callContext) ExitRule(listener antlr.ParseTreeListener) { func (p *WystParser) Round_call() (localctx IRound_callContext) { localctx = NewRound_callContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 2, WystParserRULE_round_call) + p.EnterRule(localctx, 4, WystParserRULE_round_call) var _la int var _alt int p.EnterOuterAlt(localctx, 1) { - p.SetState(38) + p.SetState(57) p.Match(WystParserT__0) if p.HasError() { // Recognition error - abort rule goto errorExit } } - p.SetState(50) + p.SetState(69) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } _la = p.GetTokenStream().LA(1) - if (int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&47104) != 0 { + if (int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&376832) != 0 { { - p.SetState(39) + p.SetState(58) p.Expr() } - p.SetState(44) + p.SetState(63) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } - _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 3, p.GetParserRuleContext()) + _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 4, p.GetParserRuleContext()) if p.HasError() { goto errorExit } for _alt != 2 && _alt != antlr.ATNInvalidAltNumber { if _alt == 1 { { - p.SetState(40) + p.SetState(59) p.Match(WystParserT__1) if p.HasError() { // Recognition error - abort rule @@ -539,22 +740,22 @@ func (p *WystParser) Round_call() (localctx IRound_callContext) { } } { - p.SetState(41) + p.SetState(60) p.Expr() } } - p.SetState(46) + p.SetState(65) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } - _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 3, p.GetParserRuleContext()) + _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 4, p.GetParserRuleContext()) if p.HasError() { goto errorExit } } - p.SetState(48) + p.SetState(67) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -563,7 +764,7 @@ func (p *WystParser) Round_call() (localctx IRound_callContext) { if _la == WystParserT__1 { { - p.SetState(47) + p.SetState(66) p.Match(WystParserT__1) if p.HasError() { // Recognition error - abort rule @@ -575,7 +776,7 @@ func (p *WystParser) Round_call() (localctx IRound_callContext) { } { - p.SetState(52) + p.SetState(71) p.Match(WystParserT__2) if p.HasError() { // Recognition error - abort rule @@ -685,10 +886,10 @@ func (s *Fn_callContext) ExitRule(listener antlr.ParseTreeListener) { func (p *WystParser) Fn_call() (localctx IFn_callContext) { localctx = NewFn_callContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 4, WystParserRULE_fn_call) + p.EnterRule(localctx, 6, WystParserRULE_fn_call) p.EnterOuterAlt(localctx, 1) { - p.SetState(54) + p.SetState(73) p.Match(WystParserIDENTIFIER) if p.HasError() { // Recognition error - abort rule @@ -696,7 +897,7 @@ func (p *WystParser) Fn_call() (localctx IFn_callContext) { } } { - p.SetState(55) + p.SetState(74) p.Round_call() } @@ -824,10 +1025,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, 6, WystParserRULE_func_def) + p.EnterRule(localctx, 8, WystParserRULE_func_def) p.EnterOuterAlt(localctx, 1) { - p.SetState(57) + p.SetState(76) p.Match(WystParserIDENTIFIER) if p.HasError() { // Recognition error - abort rule @@ -835,7 +1036,7 @@ func (p *WystParser) Func_def() (localctx IFunc_defContext) { } } { - p.SetState(58) + p.SetState(77) p.Match(WystParserIDENTIFIER) if p.HasError() { // Recognition error - abort rule @@ -843,11 +1044,11 @@ func (p *WystParser) Func_def() (localctx IFunc_defContext) { } } { - p.SetState(59) + p.SetState(78) p.Round_def() } { - p.SetState(60) + p.SetState(79) p.Code_block() } @@ -941,10 +1142,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, 8, WystParserRULE_var_def) + p.EnterRule(localctx, 10, WystParserRULE_var_def) p.EnterOuterAlt(localctx, 1) { - p.SetState(62) + p.SetState(81) p.Match(WystParserIDENTIFIER) if p.HasError() { // Recognition error - abort rule @@ -952,7 +1153,7 @@ func (p *WystParser) Var_def() (localctx IVar_defContext) { } } { - p.SetState(63) + p.SetState(82) p.Match(WystParserIDENTIFIER) if p.HasError() { // Recognition error - abort rule @@ -1074,22 +1275,22 @@ 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, 10, WystParserRULE_var_def_set) + p.EnterRule(localctx, 12, WystParserRULE_var_def_set) p.EnterOuterAlt(localctx, 1) { - p.SetState(65) + p.SetState(84) p.Var_def() } { - p.SetState(66) - p.Match(WystParserT__3) + p.SetState(85) + p.Match(WystParserT__6) if p.HasError() { // Recognition error - abort rule goto errorExit } } { - p.SetState(67) + p.SetState(86) p.Expr() } @@ -1226,26 +1427,26 @@ func (s *Call_treeContext) ExitRule(listener antlr.ParseTreeListener) { func (p *WystParser) Call_tree() (localctx ICall_treeContext) { localctx = NewCall_treeContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 12, WystParserRULE_call_tree) + p.EnterRule(localctx, 14, WystParserRULE_call_tree) var _la int p.EnterOuterAlt(localctx, 1) - p.SetState(71) + p.SetState(90) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } - switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 6, p.GetParserRuleContext()) { + switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 7, p.GetParserRuleContext()) { case 1: { - p.SetState(69) + p.SetState(88) p.Fn_call() } case 2: { - p.SetState(70) + p.SetState(89) p.Match(WystParserIDENTIFIER) if p.HasError() { // Recognition error - abort rule @@ -1256,38 +1457,38 @@ func (p *WystParser) Call_tree() (localctx ICall_treeContext) { case antlr.ATNInvalidAltNumber: goto errorExit } - p.SetState(80) + p.SetState(99) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } _la = p.GetTokenStream().LA(1) - for _la == WystParserT__4 { + for _la == WystParserT__7 { { - p.SetState(73) - p.Match(WystParserT__4) + p.SetState(92) + p.Match(WystParserT__7) if p.HasError() { // Recognition error - abort rule goto errorExit } } - p.SetState(76) + p.SetState(95) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } - switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 7, p.GetParserRuleContext()) { + switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 8, p.GetParserRuleContext()) { case 1: { - p.SetState(74) + p.SetState(93) p.Fn_call() } case 2: { - p.SetState(75) + p.SetState(94) p.Match(WystParserIDENTIFIER) if p.HasError() { // Recognition error - abort rule @@ -1299,7 +1500,7 @@ func (p *WystParser) Call_tree() (localctx ICall_treeContext) { goto errorExit } - p.SetState(82) + p.SetState(101) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -1320,8 +1521,8 @@ errorExit: goto errorExit // Trick to prevent compiler error if the label is not used } -// IAsmContext is an interface to support dynamic dispatch. -type IAsmContext interface { +// IStruct_defContext is an interface to support dynamic dispatch. +type IStruct_defContext interface { antlr.ParserRuleContext // GetParser returns the parser. @@ -1329,50 +1530,274 @@ type IAsmContext interface { // Getter signatures IDENTIFIER() antlr.TerminalNode - AllExpr() []IExprContext - Expr(i int) IExprContext + Enum_curly() IEnum_curlyContext - // IsAsmContext differentiates from other interfaces. - IsAsmContext() + // IsStruct_defContext differentiates from other interfaces. + IsStruct_defContext() } -type AsmContext struct { +type Struct_defContext struct { antlr.BaseParserRuleContext parser antlr.Parser } -func NewEmptyAsmContext() *AsmContext { - var p = new(AsmContext) +func NewEmptyStruct_defContext() *Struct_defContext { + var p = new(Struct_defContext) antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = WystParserRULE_asm + p.RuleIndex = WystParserRULE_struct_def return p } -func InitEmptyAsmContext(p *AsmContext) { +func InitEmptyStruct_defContext(p *Struct_defContext) { antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = WystParserRULE_asm + p.RuleIndex = WystParserRULE_struct_def } -func (*AsmContext) IsAsmContext() {} +func (*Struct_defContext) IsStruct_defContext() {} -func NewAsmContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *AsmContext { - var p = new(AsmContext) +func NewStruct_defContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *Struct_defContext { + var p = new(Struct_defContext) antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser - p.RuleIndex = WystParserRULE_asm + p.RuleIndex = WystParserRULE_struct_def return p } -func (s *AsmContext) GetParser() antlr.Parser { return s.parser } +func (s *Struct_defContext) GetParser() antlr.Parser { return s.parser } -func (s *AsmContext) IDENTIFIER() antlr.TerminalNode { +func (s *Struct_defContext) IDENTIFIER() antlr.TerminalNode { return s.GetToken(WystParserIDENTIFIER, 0) } -func (s *AsmContext) AllExpr() []IExprContext { +func (s *Struct_defContext) Enum_curly() IEnum_curlyContext { + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IEnum_curlyContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } + + if t == nil { + return nil + } + + return t.(IEnum_curlyContext) +} + +func (s *Struct_defContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *Struct_defContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +func (s *Struct_defContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(WystListener); ok { + listenerT.EnterStruct_def(s) + } +} + +func (s *Struct_defContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(WystListener); ok { + listenerT.ExitStruct_def(s) + } +} + +func (p *WystParser) Struct_def() (localctx IStruct_defContext) { + localctx = NewStruct_defContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 16, WystParserRULE_struct_def) + p.EnterOuterAlt(localctx, 1) + { + p.SetState(102) + p.Match(WystParserT__8) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + { + p.SetState(103) + p.Match(WystParserIDENTIFIER) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + { + p.SetState(104) + p.Enum_curly() + } + +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 +} + +// IPower_keywordContext is an interface to support dynamic dispatch. +type IPower_keywordContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + // IsPower_keywordContext differentiates from other interfaces. + IsPower_keywordContext() +} + +type Power_keywordContext struct { + antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyPower_keywordContext() *Power_keywordContext { + var p = new(Power_keywordContext) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = WystParserRULE_power_keyword + return p +} + +func InitEmptyPower_keywordContext(p *Power_keywordContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = WystParserRULE_power_keyword +} + +func (*Power_keywordContext) IsPower_keywordContext() {} + +func NewPower_keywordContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *Power_keywordContext { + var p = new(Power_keywordContext) + + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) + + p.parser = parser + p.RuleIndex = WystParserRULE_power_keyword + + return p +} + +func (s *Power_keywordContext) GetParser() antlr.Parser { return s.parser } +func (s *Power_keywordContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *Power_keywordContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +func (s *Power_keywordContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(WystListener); ok { + listenerT.EnterPower_keyword(s) + } +} + +func (s *Power_keywordContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(WystListener); ok { + listenerT.ExitPower_keyword(s) + } +} + +func (p *WystParser) Power_keyword() (localctx IPower_keywordContext) { + localctx = NewPower_keywordContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 18, WystParserRULE_power_keyword) + p.EnterOuterAlt(localctx, 1) + { + p.SetState(106) + p.Match(WystParserT__9) + 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 +} + +// IPower_keyword_callContext is an interface to support dynamic dispatch. +type IPower_keyword_callContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + + // Getter signatures + Power_keyword() IPower_keywordContext + AllExpr() []IExprContext + Expr(i int) IExprContext + + // IsPower_keyword_callContext differentiates from other interfaces. + IsPower_keyword_callContext() +} + +type Power_keyword_callContext struct { + antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyPower_keyword_callContext() *Power_keyword_callContext { + var p = new(Power_keyword_callContext) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = WystParserRULE_power_keyword_call + return p +} + +func InitEmptyPower_keyword_callContext(p *Power_keyword_callContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = WystParserRULE_power_keyword_call +} + +func (*Power_keyword_callContext) IsPower_keyword_callContext() {} + +func NewPower_keyword_callContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *Power_keyword_callContext { + var p = new(Power_keyword_callContext) + + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) + + p.parser = parser + p.RuleIndex = WystParserRULE_power_keyword_call + + return p +} + +func (s *Power_keyword_callContext) GetParser() antlr.Parser { return s.parser } + +func (s *Power_keyword_callContext) Power_keyword() IPower_keywordContext { + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IPower_keywordContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } + + if t == nil { + return nil + } + + return t.(IPower_keywordContext) +} + +func (s *Power_keyword_callContext) AllExpr() []IExprContext { children := s.GetChildren() len := 0 for _, ctx := range children { @@ -1393,7 +1818,7 @@ func (s *AsmContext) AllExpr() []IExprContext { return tst } -func (s *AsmContext) Expr(i int) IExprContext { +func (s *Power_keyword_callContext) Expr(i int) IExprContext { var t antlr.RuleContext j := 0 for _, ctx := range s.GetChildren() { @@ -1413,53 +1838,49 @@ func (s *AsmContext) Expr(i int) IExprContext { return t.(IExprContext) } -func (s *AsmContext) GetRuleContext() antlr.RuleContext { +func (s *Power_keyword_callContext) GetRuleContext() antlr.RuleContext { return s } -func (s *AsmContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { +func (s *Power_keyword_callContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { return antlr.TreesStringTree(s, ruleNames, recog) } -func (s *AsmContext) EnterRule(listener antlr.ParseTreeListener) { +func (s *Power_keyword_callContext) EnterRule(listener antlr.ParseTreeListener) { if listenerT, ok := listener.(WystListener); ok { - listenerT.EnterAsm(s) + listenerT.EnterPower_keyword_call(s) } } -func (s *AsmContext) ExitRule(listener antlr.ParseTreeListener) { +func (s *Power_keyword_callContext) ExitRule(listener antlr.ParseTreeListener) { if listenerT, ok := listener.(WystListener); ok { - listenerT.ExitAsm(s) + listenerT.ExitPower_keyword_call(s) } } -func (p *WystParser) Asm() (localctx IAsmContext) { - localctx = NewAsmContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 14, WystParserRULE_asm) +func (p *WystParser) Power_keyword_call() (localctx IPower_keyword_callContext) { + localctx = NewPower_keyword_callContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 20, WystParserRULE_power_keyword_call) var _la int p.EnterOuterAlt(localctx, 1) { - p.SetState(83) - p.Match(WystParserT__5) + p.SetState(108) + p.Match(WystParserT__10) if p.HasError() { // Recognition error - abort rule goto errorExit } } { - p.SetState(84) - p.Match(WystParserIDENTIFIER) - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } + p.SetState(109) + p.Power_keyword() } { - p.SetState(85) + p.SetState(110) p.Expr() } - p.SetState(90) + p.SetState(115) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -1468,7 +1889,7 @@ func (p *WystParser) Asm() (localctx IAsmContext) { for _la == WystParserT__1 { { - p.SetState(86) + p.SetState(111) p.Match(WystParserT__1) if p.HasError() { // Recognition error - abort rule @@ -1476,11 +1897,11 @@ func (p *WystParser) Asm() (localctx IAsmContext) { } } { - p.SetState(87) + p.SetState(112) p.Expr() } - p.SetState(92) + p.SetState(117) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -1488,8 +1909,323 @@ func (p *WystParser) Asm() (localctx IAsmContext) { _la = p.GetTokenStream().LA(1) } { - p.SetState(93) - p.Match(WystParserT__6) + p.SetState(118) + p.Match(WystParserT__4) + 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 +} + +// INamespaceContext is an interface to support dynamic dispatch. +type INamespaceContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + + // Getter signatures + IDENTIFIER() antlr.TerminalNode + AllFunc_def() []IFunc_defContext + Func_def(i int) IFunc_defContext + AllVar_def() []IVar_defContext + Var_def(i int) IVar_defContext + AllVar_def_set() []IVar_def_setContext + Var_def_set(i int) IVar_def_setContext + + // IsNamespaceContext differentiates from other interfaces. + IsNamespaceContext() +} + +type NamespaceContext struct { + antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyNamespaceContext() *NamespaceContext { + var p = new(NamespaceContext) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = WystParserRULE_namespace + return p +} + +func InitEmptyNamespaceContext(p *NamespaceContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = WystParserRULE_namespace +} + +func (*NamespaceContext) IsNamespaceContext() {} + +func NewNamespaceContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *NamespaceContext { + var p = new(NamespaceContext) + + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) + + p.parser = parser + p.RuleIndex = WystParserRULE_namespace + + return p +} + +func (s *NamespaceContext) GetParser() antlr.Parser { return s.parser } + +func (s *NamespaceContext) IDENTIFIER() antlr.TerminalNode { + return s.GetToken(WystParserIDENTIFIER, 0) +} + +func (s *NamespaceContext) AllFunc_def() []IFunc_defContext { + children := s.GetChildren() + len := 0 + for _, ctx := range children { + if _, ok := ctx.(IFunc_defContext); ok { + len++ + } + } + + tst := make([]IFunc_defContext, len) + i := 0 + for _, ctx := range children { + if t, ok := ctx.(IFunc_defContext); ok { + tst[i] = t.(IFunc_defContext) + i++ + } + } + + return tst +} + +func (s *NamespaceContext) Func_def(i int) IFunc_defContext { + var t antlr.RuleContext + j := 0 + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IFunc_defContext); ok { + if j == i { + t = ctx.(antlr.RuleContext) + break + } + j++ + } + } + + if t == nil { + return nil + } + + return t.(IFunc_defContext) +} + +func (s *NamespaceContext) AllVar_def() []IVar_defContext { + children := s.GetChildren() + len := 0 + for _, ctx := range children { + if _, ok := ctx.(IVar_defContext); ok { + len++ + } + } + + tst := make([]IVar_defContext, len) + i := 0 + for _, ctx := range children { + if t, ok := ctx.(IVar_defContext); ok { + tst[i] = t.(IVar_defContext) + i++ + } + } + + return tst +} + +func (s *NamespaceContext) Var_def(i int) IVar_defContext { + var t antlr.RuleContext + j := 0 + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IVar_defContext); ok { + if j == i { + t = ctx.(antlr.RuleContext) + break + } + j++ + } + } + + if t == nil { + return nil + } + + return t.(IVar_defContext) +} + +func (s *NamespaceContext) AllVar_def_set() []IVar_def_setContext { + children := s.GetChildren() + len := 0 + for _, ctx := range children { + if _, ok := ctx.(IVar_def_setContext); ok { + len++ + } + } + + tst := make([]IVar_def_setContext, len) + i := 0 + for _, ctx := range children { + if t, ok := ctx.(IVar_def_setContext); ok { + tst[i] = t.(IVar_def_setContext) + i++ + } + } + + return tst +} + +func (s *NamespaceContext) Var_def_set(i int) IVar_def_setContext { + var t antlr.RuleContext + j := 0 + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IVar_def_setContext); ok { + if j == i { + t = ctx.(antlr.RuleContext) + break + } + j++ + } + } + + if t == nil { + return nil + } + + return t.(IVar_def_setContext) +} + +func (s *NamespaceContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *NamespaceContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +func (s *NamespaceContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(WystListener); ok { + listenerT.EnterNamespace(s) + } +} + +func (s *NamespaceContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(WystListener); ok { + listenerT.ExitNamespace(s) + } +} + +func (p *WystParser) Namespace() (localctx INamespaceContext) { + localctx = NewNamespaceContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 22, WystParserRULE_namespace) + var _la int + + p.EnterOuterAlt(localctx, 1) + { + p.SetState(120) + p.Match(WystParserT__11) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + { + p.SetState(121) + p.Match(WystParserIDENTIFIER) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + { + p.SetState(122) + p.Match(WystParserT__3) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + p.SetState(132) + p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } + _la = p.GetTokenStream().LA(1) + + for _la == WystParserIDENTIFIER { + p.SetState(130) + p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } + + switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 12, p.GetParserRuleContext()) { + case 1: + p.SetState(125) + p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } + + switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 11, p.GetParserRuleContext()) { + case 1: + { + p.SetState(123) + p.Var_def() + } + + case 2: + { + p.SetState(124) + p.Var_def_set() + } + + case antlr.ATNInvalidAltNumber: + goto errorExit + } + { + p.SetState(127) + p.Match(WystParserT__4) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + + case 2: + { + p.SetState(129) + p.Func_def() + } + + case antlr.ATNInvalidAltNumber: + goto errorExit + } + + p.SetState(134) + p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(135) + p.Match(WystParserT__5) if p.HasError() { // Recognition error - abort rule goto errorExit @@ -1666,26 +2402,26 @@ func (s *ExprContext) ExitRule(listener antlr.ParseTreeListener) { func (p *WystParser) Expr() (localctx IExprContext) { localctx = NewExprContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 16, WystParserRULE_expr) + p.EnterRule(localctx, 24, WystParserRULE_expr) var _alt int p.EnterOuterAlt(localctx, 1) - p.SetState(100) + p.SetState(142) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } - switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 10, p.GetParserRuleContext()) { + switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 14, p.GetParserRuleContext()) { case 1: { - p.SetState(95) + p.SetState(137) p.Call_tree() } case 2: { - p.SetState(96) + p.SetState(138) p.Match(WystParserNUMBER) if p.HasError() { // Recognition error - abort rule @@ -1695,7 +2431,7 @@ func (p *WystParser) Expr() (localctx IExprContext) { case 3: { - p.SetState(97) + p.SetState(139) p.Match(WystParserHEX) if p.HasError() { // Recognition error - abort rule @@ -1705,7 +2441,7 @@ func (p *WystParser) Expr() (localctx IExprContext) { case 4: { - p.SetState(98) + p.SetState(140) p.Match(WystParserIDENTIFIER) if p.HasError() { // Recognition error - abort rule @@ -1715,7 +2451,7 @@ func (p *WystParser) Expr() (localctx IExprContext) { case 5: { - p.SetState(99) + p.SetState(141) p.Match(WystParserSTRING) if p.HasError() { // Recognition error - abort rule @@ -1726,19 +2462,19 @@ func (p *WystParser) Expr() (localctx IExprContext) { case antlr.ATNInvalidAltNumber: goto errorExit } - p.SetState(106) + p.SetState(148) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } - _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 11, p.GetParserRuleContext()) + _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 15, p.GetParserRuleContext()) if p.HasError() { goto errorExit } for _alt != 2 && _alt != antlr.ATNInvalidAltNumber { if _alt == 1 { { - p.SetState(102) + p.SetState(144) p.Match(WystParserMATH) if p.HasError() { // Recognition error - abort rule @@ -1746,17 +2482,17 @@ func (p *WystParser) Expr() (localctx IExprContext) { } } { - p.SetState(103) + p.SetState(145) p.Expr() } } - p.SetState(108) + p.SetState(150) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } - _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 11, p.GetParserRuleContext()) + _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 15, p.GetParserRuleContext()) if p.HasError() { goto errorExit } @@ -1971,48 +2707,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, 18, WystParserRULE_code_block) + p.EnterRule(localctx, 26, WystParserRULE_code_block) var _la int p.EnterOuterAlt(localctx, 1) { - p.SetState(109) - p.Match(WystParserT__7) + p.SetState(151) + p.Match(WystParserT__3) if p.HasError() { // Recognition error - abort rule goto errorExit } } - p.SetState(119) + p.SetState(161) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } _la = p.GetTokenStream().LA(1) - for (int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&47104) != 0 { - p.SetState(113) + for (int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&376832) != 0 { + p.SetState(155) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } - switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 12, p.GetParserRuleContext()) { + switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 16, p.GetParserRuleContext()) { case 1: { - p.SetState(110) + p.SetState(152) p.Expr() } case 2: { - p.SetState(111) + p.SetState(153) p.Var_def() } case 3: { - p.SetState(112) + p.SetState(154) p.Var_def_set() } @@ -2020,15 +2756,15 @@ func (p *WystParser) Code_block() (localctx ICode_blockContext) { goto errorExit } { - p.SetState(115) - p.Match(WystParserT__6) + p.SetState(157) + p.Match(WystParserT__4) if p.HasError() { // Recognition error - abort rule goto errorExit } } - p.SetState(121) + p.SetState(163) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -2036,8 +2772,8 @@ func (p *WystParser) Code_block() (localctx ICode_blockContext) { _la = p.GetTokenStream().LA(1) } { - p.SetState(122) - p.Match(WystParserT__8) + p.SetState(164) + p.Match(WystParserT__5) if p.HasError() { // Recognition error - abort rule goto errorExit @@ -2065,10 +2801,14 @@ type ITopContext interface { GetParser() antlr.Parser // Getter signatures - AllAsm() []IAsmContext - Asm(i int) IAsmContext + AllPower_keyword_call() []IPower_keyword_callContext + Power_keyword_call(i int) IPower_keyword_callContext AllFunc_def() []IFunc_defContext Func_def(i int) IFunc_defContext + AllStruct_def() []IStruct_defContext + Struct_def(i int) IStruct_defContext + AllNamespace() []INamespaceContext + Namespace(i int) INamespaceContext // IsTopContext differentiates from other interfaces. IsTopContext() @@ -2106,20 +2846,20 @@ func NewTopContext(parser antlr.Parser, parent antlr.ParserRuleContext, invoking func (s *TopContext) GetParser() antlr.Parser { return s.parser } -func (s *TopContext) AllAsm() []IAsmContext { +func (s *TopContext) AllPower_keyword_call() []IPower_keyword_callContext { children := s.GetChildren() len := 0 for _, ctx := range children { - if _, ok := ctx.(IAsmContext); ok { + if _, ok := ctx.(IPower_keyword_callContext); ok { len++ } } - tst := make([]IAsmContext, len) + tst := make([]IPower_keyword_callContext, len) i := 0 for _, ctx := range children { - if t, ok := ctx.(IAsmContext); ok { - tst[i] = t.(IAsmContext) + if t, ok := ctx.(IPower_keyword_callContext); ok { + tst[i] = t.(IPower_keyword_callContext) i++ } } @@ -2127,11 +2867,11 @@ func (s *TopContext) AllAsm() []IAsmContext { return tst } -func (s *TopContext) Asm(i int) IAsmContext { +func (s *TopContext) Power_keyword_call(i int) IPower_keyword_callContext { var t antlr.RuleContext j := 0 for _, ctx := range s.GetChildren() { - if _, ok := ctx.(IAsmContext); ok { + if _, ok := ctx.(IPower_keyword_callContext); ok { if j == i { t = ctx.(antlr.RuleContext) break @@ -2144,7 +2884,7 @@ func (s *TopContext) Asm(i int) IAsmContext { return nil } - return t.(IAsmContext) + return t.(IPower_keyword_callContext) } func (s *TopContext) AllFunc_def() []IFunc_defContext { @@ -2188,6 +2928,88 @@ func (s *TopContext) Func_def(i int) IFunc_defContext { return t.(IFunc_defContext) } +func (s *TopContext) AllStruct_def() []IStruct_defContext { + children := s.GetChildren() + len := 0 + for _, ctx := range children { + if _, ok := ctx.(IStruct_defContext); ok { + len++ + } + } + + tst := make([]IStruct_defContext, len) + i := 0 + for _, ctx := range children { + if t, ok := ctx.(IStruct_defContext); ok { + tst[i] = t.(IStruct_defContext) + i++ + } + } + + return tst +} + +func (s *TopContext) Struct_def(i int) IStruct_defContext { + var t antlr.RuleContext + j := 0 + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IStruct_defContext); ok { + if j == i { + t = ctx.(antlr.RuleContext) + break + } + j++ + } + } + + if t == nil { + return nil + } + + return t.(IStruct_defContext) +} + +func (s *TopContext) AllNamespace() []INamespaceContext { + children := s.GetChildren() + len := 0 + for _, ctx := range children { + if _, ok := ctx.(INamespaceContext); ok { + len++ + } + } + + tst := make([]INamespaceContext, len) + i := 0 + for _, ctx := range children { + if t, ok := ctx.(INamespaceContext); ok { + tst[i] = t.(INamespaceContext) + i++ + } + } + + return tst +} + +func (s *TopContext) Namespace(i int) INamespaceContext { + var t antlr.RuleContext + j := 0 + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(INamespaceContext); ok { + if j == i { + t = ctx.(antlr.RuleContext) + break + } + j++ + } + } + + if t == nil { + return nil + } + + return t.(INamespaceContext) +} + func (s *TopContext) GetRuleContext() antlr.RuleContext { return s } @@ -2210,43 +3032,55 @@ func (s *TopContext) ExitRule(listener antlr.ParseTreeListener) { func (p *WystParser) Top() (localctx ITopContext) { localctx = NewTopContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 20, WystParserRULE_top) + p.EnterRule(localctx, 28, WystParserRULE_top) var _la int p.EnterOuterAlt(localctx, 1) - p.SetState(128) + p.SetState(172) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } _la = p.GetTokenStream().LA(1) - for _la == WystParserT__5 || _la == WystParserIDENTIFIER { - p.SetState(126) + for (int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&72192) != 0 { + p.SetState(170) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } switch p.GetTokenStream().LA(1) { - case WystParserT__5: + case WystParserT__10: { - p.SetState(124) - p.Asm() + p.SetState(166) + p.Power_keyword_call() } case WystParserIDENTIFIER: { - p.SetState(125) + p.SetState(167) p.Func_def() } + case WystParserT__8: + { + p.SetState(168) + p.Struct_def() + } + + case WystParserT__11: + { + p.SetState(169) + p.Namespace() + } + default: p.SetError(antlr.NewNoViableAltException(p, nil, nil, nil, nil, nil)) goto errorExit } - p.SetState(130) + p.SetState(174) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit diff --git a/src/transpiler.go b/src/transpiler.go index fe532c9..6a8ae26 100644 --- a/src/transpiler.go +++ b/src/transpiler.go @@ -65,7 +65,7 @@ func TranspileNode(node ASTNode) string { res += fmt.Sprintf("var %s %s", TranspileNode(node.Inner[1]), TranspileNode(node.Inner[0])) case "round_def": fmt.Sprintf("(%s)", strings.TrimSuffix(strings.ReplaceAll(TranspileNodes(node.Inner), "var ", ""), " ")) - case "asm": + case "power_keyword_call": if node.Inner[0].Text == "map" && len(node.Inner) == 4 { wyst_map = append(wyst_map, wmap{node.Inner[1].Text, node.Inner[2].Text}) } @@ -84,6 +84,38 @@ func TranspileNode(node ASTNode) string { case "round_call": res += fmt.Sprintf("(%s)", TranspileNodes(node.Inner)) + case "struct_def": + res += fmt.Sprintf("type %s struct %s\n", TranspileNode(node.Inner[0]), TranspileNode(node.Inner[1])) + + case "enum_curly": + res += fmt.Sprintf("{\n %s}", strings.TrimSuffix(TranspileNodes(node.Inner), " ")) + + case "namespace": + namespace_name := "n" + TranspileNode(node.Inner[0]) + res += fmt.Sprintf("type %s struct {\n ", namespace_name) + vals := "" + for _, c := range node.Inner { + if c.Rule == "var_def" { + res += strings.TrimPrefix(TranspileNode(c), "var ") + res += "\n " + } else if c.Rule == "var_def_set" { + res += strings.TrimPrefix(TranspileNode(c.Inner[0]), "var ") + res += "\n " + vals += fmt.Sprintf("%s: %s, ", TranspileNode(c.Inner[0].Inner[1]), TranspileNode(c.Inner[1])) + } + } + res += "}\n" + for _, c := range node.Inner { + if c.Rule == "func_def" { + res += fmt.Sprintf("func (%s) %s%s %s %s", namespace_name, TranspileNode(c.Inner[1]), TranspileNode(c.Inner[2]), TranspileNode(c.Inner[0]), TranspileNode(c.Inner[3])) + res += "\n " + } + } + res += fmt.Sprintf("var %s %s = %s{%s}", TranspileNode(node.Inner[0]), namespace_name, namespace_name, vals) + + case "var_def_set": + res += fmt.Sprintf("%s = %s", TranspileNode(node.Inner[0]), TranspileNode(node.Inner[1])) + 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 79a589f..a2d368d 100644 --- a/test/main.wst +++ b/test/main.wst @@ -1,5 +1,5 @@ -%map _, _; +#map _, _; -int main(test x) { - x::h.y.z(0, "test"); +int main() { + int x = 20; } \ No newline at end of file