From 2ca95bcc0327aadaa0f5ebed9035893630ac2097 Mon Sep 17 00:00:00 2001 From: Leo dev Date: Thu, 22 Aug 2024 15:41:27 +0200 Subject: [PATCH] fixed a few mod system bugs --- Wyst.g4 | 27 +- parser/Wyst.interp | 26 +- parser/Wyst.tokens | 26 +- parser/WystLexer.interp | 26 +- parser/WystLexer.tokens | 26 +- parser/wyst_base_listener.go | 48 + parser/wyst_lexer.go | 222 ++-- parser/wyst_listener.go | 48 + parser/wyst_parser.go | 1899 ++++++++++++++++++++++++++++++---- src/transpiler.go | 46 +- src/utils.go | 24 +- 11 files changed, 2066 insertions(+), 352 deletions(-) diff --git a/Wyst.g4 b/Wyst.g4 index 86e5431..b232c46 100644 --- a/Wyst.g4 +++ b/Wyst.g4 @@ -4,7 +4,8 @@ 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_]* ('::' [a-zA-Z_] [a-zA-Z0-9_]*)*; -MATH: '+' | '-' | '*' | '/'; +GOIDENTIFIER: '^' [a-zA-Z_] [a-zA-Z0-9_]* ('.' [a-zA-Z_] [a-zA-Z0-9_]*)*; +MATH: '+' | '-' | '*' | '/' | '==' | '!=' | '>=' | '<='; fragment ESC: '\\' ['"\\] ; STRING: '"' (ESC | ~["\\])* '"'; MODULE_NAME: [a-zA-Z_] [a-zA-Z0-9_]*; @@ -22,6 +23,16 @@ struct_def: 'struct' IDENTIFIER enum_curly; namespace: 'namespace' IDENTIFIER '{' (((var_def|var_def_set) ';')|func_def)* '}'; import_statement: 'include' MODULE_NAME ';'; use_statement: 'use' IDENTIFIER ';'; +go_import: '%import' STRING ';'; +map: '%map' IDENTIFIER ',' IDENTIFIER ';'; +go_call: GOIDENTIFIER round_call; + +// if else statements +if_expr: '(' expr (('&&'|'||') expr)* ')'; +if_statement: 'if' if_expr code_block*; +elseif_statement: 'else' if_statement; +else_statement: 'else' code_block*; +if_tree: if_statement elseif_statement* else_statement?; expr: ( @@ -29,19 +40,25 @@ expr: NUMBER | HEX | IDENTIFIER | - STRING + STRING | + go_call | + GOIDENTIFIER ) (MATH expr)*; -code_block: '{' (( +code_block: '{' ((( expr | var_def | var_def_set -) ';')* '}'; +) ';') | ( + if_tree +))* '}'; top: ( func_def | struct_def | namespace | import_statement | - use_statement + use_statement | + go_import | + map )*; \ No newline at end of file diff --git a/parser/Wyst.interp b/parser/Wyst.interp index a091a7f..835eb08 100644 --- a/parser/Wyst.interp +++ b/parser/Wyst.interp @@ -12,6 +12,14 @@ null 'namespace' 'include' 'use' +'%import' +'%map' +'&&' +'||' +'if' +'else' +null +null null null null @@ -33,12 +41,20 @@ null null null null +null +null +null +null +null +null WS NUMBER HEX IDENTIFIER +GOIDENTIFIER MATH STRING +MODULE_NAME rule names: round_def @@ -53,10 +69,18 @@ struct_def namespace import_statement use_statement +go_import +map +go_call +if_expr +if_statement +elseif_statement +else_statement +if_tree expr code_block top atn: -[4, 1, 18, 171, 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, 9, 1, 9, 1, 9, 3, 9, 112, 8, 9, 1, 9, 1, 9, 1, 9, 5, 9, 117, 8, 9, 10, 9, 12, 9, 120, 9, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 3, 12, 137, 8, 12, 1, 12, 1, 12, 5, 12, 141, 8, 12, 10, 12, 12, 12, 144, 9, 12, 1, 13, 1, 13, 1, 13, 1, 13, 3, 13, 150, 8, 13, 1, 13, 1, 13, 5, 13, 154, 8, 13, 10, 13, 12, 13, 157, 9, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 5, 14, 166, 8, 14, 10, 14, 12, 14, 169, 9, 14, 1, 14, 0, 0, 15, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 0, 0, 181, 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, 123, 1, 0, 0, 0, 22, 127, 1, 0, 0, 0, 24, 136, 1, 0, 0, 0, 26, 145, 1, 0, 0, 0, 28, 167, 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, 108, 5, 16, 0, 0, 108, 118, 5, 4, 0, 0, 109, 112, 3, 10, 5, 0, 110, 112, 3, 12, 6, 0, 111, 109, 1, 0, 0, 0, 111, 110, 1, 0, 0, 0, 112, 113, 1, 0, 0, 0, 113, 114, 5, 5, 0, 0, 114, 117, 1, 0, 0, 0, 115, 117, 3, 8, 4, 0, 116, 111, 1, 0, 0, 0, 116, 115, 1, 0, 0, 0, 117, 120, 1, 0, 0, 0, 118, 116, 1, 0, 0, 0, 118, 119, 1, 0, 0, 0, 119, 121, 1, 0, 0, 0, 120, 118, 1, 0, 0, 0, 121, 122, 5, 6, 0, 0, 122, 19, 1, 0, 0, 0, 123, 124, 5, 11, 0, 0, 124, 125, 5, 16, 0, 0, 125, 126, 5, 5, 0, 0, 126, 21, 1, 0, 0, 0, 127, 128, 5, 12, 0, 0, 128, 129, 5, 16, 0, 0, 129, 130, 5, 5, 0, 0, 130, 23, 1, 0, 0, 0, 131, 137, 3, 14, 7, 0, 132, 137, 5, 14, 0, 0, 133, 137, 5, 15, 0, 0, 134, 137, 5, 16, 0, 0, 135, 137, 5, 18, 0, 0, 136, 131, 1, 0, 0, 0, 136, 132, 1, 0, 0, 0, 136, 133, 1, 0, 0, 0, 136, 134, 1, 0, 0, 0, 136, 135, 1, 0, 0, 0, 137, 142, 1, 0, 0, 0, 138, 139, 5, 17, 0, 0, 139, 141, 3, 24, 12, 0, 140, 138, 1, 0, 0, 0, 141, 144, 1, 0, 0, 0, 142, 140, 1, 0, 0, 0, 142, 143, 1, 0, 0, 0, 143, 25, 1, 0, 0, 0, 144, 142, 1, 0, 0, 0, 145, 155, 5, 4, 0, 0, 146, 150, 3, 24, 12, 0, 147, 150, 3, 10, 5, 0, 148, 150, 3, 12, 6, 0, 149, 146, 1, 0, 0, 0, 149, 147, 1, 0, 0, 0, 149, 148, 1, 0, 0, 0, 150, 151, 1, 0, 0, 0, 151, 152, 5, 5, 0, 0, 152, 154, 1, 0, 0, 0, 153, 149, 1, 0, 0, 0, 154, 157, 1, 0, 0, 0, 155, 153, 1, 0, 0, 0, 155, 156, 1, 0, 0, 0, 156, 158, 1, 0, 0, 0, 157, 155, 1, 0, 0, 0, 158, 159, 5, 6, 0, 0, 159, 27, 1, 0, 0, 0, 160, 166, 3, 8, 4, 0, 161, 166, 3, 16, 8, 0, 162, 166, 3, 18, 9, 0, 163, 166, 3, 20, 10, 0, 164, 166, 3, 22, 11, 0, 165, 160, 1, 0, 0, 0, 165, 161, 1, 0, 0, 0, 165, 162, 1, 0, 0, 0, 165, 163, 1, 0, 0, 0, 165, 164, 1, 0, 0, 0, 166, 169, 1, 0, 0, 0, 167, 165, 1, 0, 0, 0, 167, 168, 1, 0, 0, 0, 168, 29, 1, 0, 0, 0, 169, 167, 1, 0, 0, 0, 19, 36, 40, 42, 52, 63, 67, 69, 90, 95, 99, 111, 116, 118, 136, 142, 149, 155, 165, 167] \ No newline at end of file +[4, 1, 26, 244, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 1, 0, 1, 0, 1, 0, 1, 0, 5, 0, 51, 8, 0, 10, 0, 12, 0, 54, 9, 0, 1, 0, 3, 0, 57, 8, 0, 3, 0, 59, 8, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 67, 8, 1, 10, 1, 12, 1, 70, 9, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 5, 2, 78, 8, 2, 10, 2, 12, 2, 81, 9, 2, 1, 2, 3, 2, 84, 8, 2, 3, 2, 86, 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, 107, 8, 7, 1, 7, 1, 7, 1, 7, 3, 7, 112, 8, 7, 5, 7, 114, 8, 7, 10, 7, 12, 7, 117, 9, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 3, 9, 128, 8, 9, 1, 9, 1, 9, 1, 9, 5, 9, 133, 8, 9, 10, 9, 12, 9, 136, 9, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 15, 1, 15, 5, 15, 165, 8, 15, 10, 15, 12, 15, 168, 9, 15, 1, 15, 1, 15, 1, 16, 1, 16, 1, 16, 5, 16, 175, 8, 16, 10, 16, 12, 16, 178, 9, 16, 1, 17, 1, 17, 1, 17, 1, 18, 1, 18, 5, 18, 185, 8, 18, 10, 18, 12, 18, 188, 9, 18, 1, 19, 1, 19, 5, 19, 192, 8, 19, 10, 19, 12, 19, 195, 9, 19, 1, 19, 3, 19, 198, 8, 19, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 3, 20, 207, 8, 20, 1, 20, 1, 20, 5, 20, 211, 8, 20, 10, 20, 12, 20, 214, 9, 20, 1, 21, 1, 21, 1, 21, 1, 21, 3, 21, 220, 8, 21, 1, 21, 1, 21, 1, 21, 5, 21, 225, 8, 21, 10, 21, 12, 21, 228, 9, 21, 1, 21, 1, 21, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 5, 22, 239, 8, 22, 10, 22, 12, 22, 242, 9, 22, 1, 22, 0, 0, 23, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 0, 1, 1, 0, 15, 16, 256, 0, 46, 1, 0, 0, 0, 2, 62, 1, 0, 0, 0, 4, 73, 1, 0, 0, 0, 6, 89, 1, 0, 0, 0, 8, 92, 1, 0, 0, 0, 10, 97, 1, 0, 0, 0, 12, 100, 1, 0, 0, 0, 14, 106, 1, 0, 0, 0, 16, 118, 1, 0, 0, 0, 18, 122, 1, 0, 0, 0, 20, 139, 1, 0, 0, 0, 22, 143, 1, 0, 0, 0, 24, 147, 1, 0, 0, 0, 26, 151, 1, 0, 0, 0, 28, 157, 1, 0, 0, 0, 30, 160, 1, 0, 0, 0, 32, 171, 1, 0, 0, 0, 34, 179, 1, 0, 0, 0, 36, 182, 1, 0, 0, 0, 38, 189, 1, 0, 0, 0, 40, 206, 1, 0, 0, 0, 42, 215, 1, 0, 0, 0, 44, 240, 1, 0, 0, 0, 46, 58, 5, 1, 0, 0, 47, 52, 3, 10, 5, 0, 48, 49, 5, 2, 0, 0, 49, 51, 3, 10, 5, 0, 50, 48, 1, 0, 0, 0, 51, 54, 1, 0, 0, 0, 52, 50, 1, 0, 0, 0, 52, 53, 1, 0, 0, 0, 53, 56, 1, 0, 0, 0, 54, 52, 1, 0, 0, 0, 55, 57, 5, 2, 0, 0, 56, 55, 1, 0, 0, 0, 56, 57, 1, 0, 0, 0, 57, 59, 1, 0, 0, 0, 58, 47, 1, 0, 0, 0, 58, 59, 1, 0, 0, 0, 59, 60, 1, 0, 0, 0, 60, 61, 5, 3, 0, 0, 61, 1, 1, 0, 0, 0, 62, 68, 5, 4, 0, 0, 63, 64, 3, 10, 5, 0, 64, 65, 5, 5, 0, 0, 65, 67, 1, 0, 0, 0, 66, 63, 1, 0, 0, 0, 67, 70, 1, 0, 0, 0, 68, 66, 1, 0, 0, 0, 68, 69, 1, 0, 0, 0, 69, 71, 1, 0, 0, 0, 70, 68, 1, 0, 0, 0, 71, 72, 5, 6, 0, 0, 72, 3, 1, 0, 0, 0, 73, 85, 5, 1, 0, 0, 74, 79, 3, 40, 20, 0, 75, 76, 5, 2, 0, 0, 76, 78, 3, 40, 20, 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, 83, 1, 0, 0, 0, 81, 79, 1, 0, 0, 0, 82, 84, 5, 2, 0, 0, 83, 82, 1, 0, 0, 0, 83, 84, 1, 0, 0, 0, 84, 86, 1, 0, 0, 0, 85, 74, 1, 0, 0, 0, 85, 86, 1, 0, 0, 0, 86, 87, 1, 0, 0, 0, 87, 88, 5, 3, 0, 0, 88, 5, 1, 0, 0, 0, 89, 90, 5, 22, 0, 0, 90, 91, 3, 4, 2, 0, 91, 7, 1, 0, 0, 0, 92, 93, 5, 22, 0, 0, 93, 94, 5, 22, 0, 0, 94, 95, 3, 0, 0, 0, 95, 96, 3, 42, 21, 0, 96, 9, 1, 0, 0, 0, 97, 98, 5, 22, 0, 0, 98, 99, 5, 22, 0, 0, 99, 11, 1, 0, 0, 0, 100, 101, 3, 10, 5, 0, 101, 102, 5, 7, 0, 0, 102, 103, 3, 40, 20, 0, 103, 13, 1, 0, 0, 0, 104, 107, 3, 6, 3, 0, 105, 107, 5, 22, 0, 0, 106, 104, 1, 0, 0, 0, 106, 105, 1, 0, 0, 0, 107, 115, 1, 0, 0, 0, 108, 111, 5, 8, 0, 0, 109, 112, 3, 6, 3, 0, 110, 112, 5, 22, 0, 0, 111, 109, 1, 0, 0, 0, 111, 110, 1, 0, 0, 0, 112, 114, 1, 0, 0, 0, 113, 108, 1, 0, 0, 0, 114, 117, 1, 0, 0, 0, 115, 113, 1, 0, 0, 0, 115, 116, 1, 0, 0, 0, 116, 15, 1, 0, 0, 0, 117, 115, 1, 0, 0, 0, 118, 119, 5, 9, 0, 0, 119, 120, 5, 22, 0, 0, 120, 121, 3, 2, 1, 0, 121, 17, 1, 0, 0, 0, 122, 123, 5, 10, 0, 0, 123, 124, 5, 22, 0, 0, 124, 134, 5, 4, 0, 0, 125, 128, 3, 10, 5, 0, 126, 128, 3, 12, 6, 0, 127, 125, 1, 0, 0, 0, 127, 126, 1, 0, 0, 0, 128, 129, 1, 0, 0, 0, 129, 130, 5, 5, 0, 0, 130, 133, 1, 0, 0, 0, 131, 133, 3, 8, 4, 0, 132, 127, 1, 0, 0, 0, 132, 131, 1, 0, 0, 0, 133, 136, 1, 0, 0, 0, 134, 132, 1, 0, 0, 0, 134, 135, 1, 0, 0, 0, 135, 137, 1, 0, 0, 0, 136, 134, 1, 0, 0, 0, 137, 138, 5, 6, 0, 0, 138, 19, 1, 0, 0, 0, 139, 140, 5, 11, 0, 0, 140, 141, 5, 26, 0, 0, 141, 142, 5, 5, 0, 0, 142, 21, 1, 0, 0, 0, 143, 144, 5, 12, 0, 0, 144, 145, 5, 22, 0, 0, 145, 146, 5, 5, 0, 0, 146, 23, 1, 0, 0, 0, 147, 148, 5, 13, 0, 0, 148, 149, 5, 25, 0, 0, 149, 150, 5, 5, 0, 0, 150, 25, 1, 0, 0, 0, 151, 152, 5, 14, 0, 0, 152, 153, 5, 22, 0, 0, 153, 154, 5, 2, 0, 0, 154, 155, 5, 22, 0, 0, 155, 156, 5, 5, 0, 0, 156, 27, 1, 0, 0, 0, 157, 158, 5, 23, 0, 0, 158, 159, 3, 4, 2, 0, 159, 29, 1, 0, 0, 0, 160, 161, 5, 1, 0, 0, 161, 166, 3, 40, 20, 0, 162, 163, 7, 0, 0, 0, 163, 165, 3, 40, 20, 0, 164, 162, 1, 0, 0, 0, 165, 168, 1, 0, 0, 0, 166, 164, 1, 0, 0, 0, 166, 167, 1, 0, 0, 0, 167, 169, 1, 0, 0, 0, 168, 166, 1, 0, 0, 0, 169, 170, 5, 3, 0, 0, 170, 31, 1, 0, 0, 0, 171, 172, 5, 17, 0, 0, 172, 176, 3, 30, 15, 0, 173, 175, 3, 42, 21, 0, 174, 173, 1, 0, 0, 0, 175, 178, 1, 0, 0, 0, 176, 174, 1, 0, 0, 0, 176, 177, 1, 0, 0, 0, 177, 33, 1, 0, 0, 0, 178, 176, 1, 0, 0, 0, 179, 180, 5, 18, 0, 0, 180, 181, 3, 32, 16, 0, 181, 35, 1, 0, 0, 0, 182, 186, 5, 18, 0, 0, 183, 185, 3, 42, 21, 0, 184, 183, 1, 0, 0, 0, 185, 188, 1, 0, 0, 0, 186, 184, 1, 0, 0, 0, 186, 187, 1, 0, 0, 0, 187, 37, 1, 0, 0, 0, 188, 186, 1, 0, 0, 0, 189, 193, 3, 32, 16, 0, 190, 192, 3, 34, 17, 0, 191, 190, 1, 0, 0, 0, 192, 195, 1, 0, 0, 0, 193, 191, 1, 0, 0, 0, 193, 194, 1, 0, 0, 0, 194, 197, 1, 0, 0, 0, 195, 193, 1, 0, 0, 0, 196, 198, 3, 36, 18, 0, 197, 196, 1, 0, 0, 0, 197, 198, 1, 0, 0, 0, 198, 39, 1, 0, 0, 0, 199, 207, 3, 14, 7, 0, 200, 207, 5, 20, 0, 0, 201, 207, 5, 21, 0, 0, 202, 207, 5, 22, 0, 0, 203, 207, 5, 25, 0, 0, 204, 207, 3, 28, 14, 0, 205, 207, 5, 23, 0, 0, 206, 199, 1, 0, 0, 0, 206, 200, 1, 0, 0, 0, 206, 201, 1, 0, 0, 0, 206, 202, 1, 0, 0, 0, 206, 203, 1, 0, 0, 0, 206, 204, 1, 0, 0, 0, 206, 205, 1, 0, 0, 0, 207, 212, 1, 0, 0, 0, 208, 209, 5, 24, 0, 0, 209, 211, 3, 40, 20, 0, 210, 208, 1, 0, 0, 0, 211, 214, 1, 0, 0, 0, 212, 210, 1, 0, 0, 0, 212, 213, 1, 0, 0, 0, 213, 41, 1, 0, 0, 0, 214, 212, 1, 0, 0, 0, 215, 226, 5, 4, 0, 0, 216, 220, 3, 40, 20, 0, 217, 220, 3, 10, 5, 0, 218, 220, 3, 12, 6, 0, 219, 216, 1, 0, 0, 0, 219, 217, 1, 0, 0, 0, 219, 218, 1, 0, 0, 0, 220, 221, 1, 0, 0, 0, 221, 222, 5, 5, 0, 0, 222, 225, 1, 0, 0, 0, 223, 225, 3, 38, 19, 0, 224, 219, 1, 0, 0, 0, 224, 223, 1, 0, 0, 0, 225, 228, 1, 0, 0, 0, 226, 224, 1, 0, 0, 0, 226, 227, 1, 0, 0, 0, 227, 229, 1, 0, 0, 0, 228, 226, 1, 0, 0, 0, 229, 230, 5, 6, 0, 0, 230, 43, 1, 0, 0, 0, 231, 239, 3, 8, 4, 0, 232, 239, 3, 16, 8, 0, 233, 239, 3, 18, 9, 0, 234, 239, 3, 20, 10, 0, 235, 239, 3, 22, 11, 0, 236, 239, 3, 24, 12, 0, 237, 239, 3, 26, 13, 0, 238, 231, 1, 0, 0, 0, 238, 232, 1, 0, 0, 0, 238, 233, 1, 0, 0, 0, 238, 234, 1, 0, 0, 0, 238, 235, 1, 0, 0, 0, 238, 236, 1, 0, 0, 0, 238, 237, 1, 0, 0, 0, 239, 242, 1, 0, 0, 0, 240, 238, 1, 0, 0, 0, 240, 241, 1, 0, 0, 0, 241, 45, 1, 0, 0, 0, 242, 240, 1, 0, 0, 0, 25, 52, 56, 58, 68, 79, 83, 85, 106, 111, 115, 127, 132, 134, 166, 176, 186, 193, 197, 206, 212, 219, 224, 226, 238, 240] \ No newline at end of file diff --git a/parser/Wyst.tokens b/parser/Wyst.tokens index fdf4b67..4e30725 100644 --- a/parser/Wyst.tokens +++ b/parser/Wyst.tokens @@ -10,12 +10,20 @@ T__8=9 T__9=10 T__10=11 T__11=12 -WS=13 -NUMBER=14 -HEX=15 -IDENTIFIER=16 -MATH=17 -STRING=18 +T__12=13 +T__13=14 +T__14=15 +T__15=16 +T__16=17 +T__17=18 +WS=19 +NUMBER=20 +HEX=21 +IDENTIFIER=22 +GOIDENTIFIER=23 +MATH=24 +STRING=25 +MODULE_NAME=26 '('=1 ','=2 ')'=3 @@ -28,3 +36,9 @@ STRING=18 'namespace'=10 'include'=11 'use'=12 +'%import'=13 +'%map'=14 +'&&'=15 +'||'=16 +'if'=17 +'else'=18 diff --git a/parser/WystLexer.interp b/parser/WystLexer.interp index c7e9e0b..e3ea835 100644 --- a/parser/WystLexer.interp +++ b/parser/WystLexer.interp @@ -12,6 +12,14 @@ null 'namespace' 'include' 'use' +'%import' +'%map' +'&&' +'||' +'if' +'else' +null +null null null null @@ -33,12 +41,20 @@ null null null null +null +null +null +null +null +null WS NUMBER HEX IDENTIFIER +GOIDENTIFIER MATH STRING +MODULE_NAME rule names: T__0 @@ -53,13 +69,21 @@ T__8 T__9 T__10 T__11 +T__12 +T__13 +T__14 +T__15 +T__16 +T__17 WS NUMBER HEX IDENTIFIER +GOIDENTIFIER MATH ESC STRING +MODULE_NAME channel names: DEFAULT_TOKEN_CHANNEL @@ -69,4 +93,4 @@ mode names: DEFAULT_MODE atn: -[4, 0, 18, 147, 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, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 11, 1, 12, 4, 12, 86, 8, 12, 11, 12, 12, 12, 87, 1, 12, 1, 12, 1, 13, 1, 13, 5, 13, 94, 8, 13, 10, 13, 12, 13, 97, 9, 13, 1, 13, 3, 13, 100, 8, 13, 1, 14, 1, 14, 1, 14, 1, 14, 5, 14, 106, 8, 14, 10, 14, 12, 14, 109, 9, 14, 1, 15, 1, 15, 5, 15, 113, 8, 15, 10, 15, 12, 15, 116, 9, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 5, 15, 123, 8, 15, 10, 15, 12, 15, 126, 9, 15, 5, 15, 128, 8, 15, 10, 15, 12, 15, 131, 9, 15, 1, 16, 1, 16, 1, 17, 1, 17, 1, 17, 1, 18, 1, 18, 1, 18, 5, 18, 141, 8, 18, 10, 18, 12, 18, 144, 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, 154, 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, 72, 1, 0, 0, 0, 23, 80, 1, 0, 0, 0, 25, 85, 1, 0, 0, 0, 27, 99, 1, 0, 0, 0, 29, 101, 1, 0, 0, 0, 31, 110, 1, 0, 0, 0, 33, 132, 1, 0, 0, 0, 35, 134, 1, 0, 0, 0, 37, 137, 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, 110, 0, 0, 63, 64, 5, 97, 0, 0, 64, 65, 5, 109, 0, 0, 65, 66, 5, 101, 0, 0, 66, 67, 5, 115, 0, 0, 67, 68, 5, 112, 0, 0, 68, 69, 5, 97, 0, 0, 69, 70, 5, 99, 0, 0, 70, 71, 5, 101, 0, 0, 71, 20, 1, 0, 0, 0, 72, 73, 5, 105, 0, 0, 73, 74, 5, 110, 0, 0, 74, 75, 5, 99, 0, 0, 75, 76, 5, 108, 0, 0, 76, 77, 5, 117, 0, 0, 77, 78, 5, 100, 0, 0, 78, 79, 5, 101, 0, 0, 79, 22, 1, 0, 0, 0, 80, 81, 5, 117, 0, 0, 81, 82, 5, 115, 0, 0, 82, 83, 5, 101, 0, 0, 83, 24, 1, 0, 0, 0, 84, 86, 7, 0, 0, 0, 85, 84, 1, 0, 0, 0, 86, 87, 1, 0, 0, 0, 87, 85, 1, 0, 0, 0, 87, 88, 1, 0, 0, 0, 88, 89, 1, 0, 0, 0, 89, 90, 6, 12, 0, 0, 90, 26, 1, 0, 0, 0, 91, 95, 7, 1, 0, 0, 92, 94, 7, 2, 0, 0, 93, 92, 1, 0, 0, 0, 94, 97, 1, 0, 0, 0, 95, 93, 1, 0, 0, 0, 95, 96, 1, 0, 0, 0, 96, 100, 1, 0, 0, 0, 97, 95, 1, 0, 0, 0, 98, 100, 5, 48, 0, 0, 99, 91, 1, 0, 0, 0, 99, 98, 1, 0, 0, 0, 100, 28, 1, 0, 0, 0, 101, 102, 5, 48, 0, 0, 102, 103, 5, 120, 0, 0, 103, 107, 1, 0, 0, 0, 104, 106, 7, 3, 0, 0, 105, 104, 1, 0, 0, 0, 106, 109, 1, 0, 0, 0, 107, 105, 1, 0, 0, 0, 107, 108, 1, 0, 0, 0, 108, 30, 1, 0, 0, 0, 109, 107, 1, 0, 0, 0, 110, 114, 7, 4, 0, 0, 111, 113, 7, 5, 0, 0, 112, 111, 1, 0, 0, 0, 113, 116, 1, 0, 0, 0, 114, 112, 1, 0, 0, 0, 114, 115, 1, 0, 0, 0, 115, 129, 1, 0, 0, 0, 116, 114, 1, 0, 0, 0, 117, 118, 5, 58, 0, 0, 118, 119, 5, 58, 0, 0, 119, 120, 1, 0, 0, 0, 120, 124, 7, 4, 0, 0, 121, 123, 7, 5, 0, 0, 122, 121, 1, 0, 0, 0, 123, 126, 1, 0, 0, 0, 124, 122, 1, 0, 0, 0, 124, 125, 1, 0, 0, 0, 125, 128, 1, 0, 0, 0, 126, 124, 1, 0, 0, 0, 127, 117, 1, 0, 0, 0, 128, 131, 1, 0, 0, 0, 129, 127, 1, 0, 0, 0, 129, 130, 1, 0, 0, 0, 130, 32, 1, 0, 0, 0, 131, 129, 1, 0, 0, 0, 132, 133, 7, 6, 0, 0, 133, 34, 1, 0, 0, 0, 134, 135, 5, 92, 0, 0, 135, 136, 7, 7, 0, 0, 136, 36, 1, 0, 0, 0, 137, 142, 5, 34, 0, 0, 138, 141, 3, 35, 17, 0, 139, 141, 8, 8, 0, 0, 140, 138, 1, 0, 0, 0, 140, 139, 1, 0, 0, 0, 141, 144, 1, 0, 0, 0, 142, 140, 1, 0, 0, 0, 142, 143, 1, 0, 0, 0, 143, 145, 1, 0, 0, 0, 144, 142, 1, 0, 0, 0, 145, 146, 5, 34, 0, 0, 146, 38, 1, 0, 0, 0, 10, 0, 87, 95, 99, 107, 114, 124, 129, 140, 142, 1, 6, 0, 0] \ No newline at end of file +[4, 0, 26, 227, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 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, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 15, 1, 16, 1, 16, 1, 16, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 18, 4, 18, 129, 8, 18, 11, 18, 12, 18, 130, 1, 18, 1, 18, 1, 19, 1, 19, 5, 19, 137, 8, 19, 10, 19, 12, 19, 140, 9, 19, 1, 19, 3, 19, 143, 8, 19, 1, 20, 1, 20, 1, 20, 1, 20, 5, 20, 149, 8, 20, 10, 20, 12, 20, 152, 9, 20, 1, 21, 1, 21, 5, 21, 156, 8, 21, 10, 21, 12, 21, 159, 9, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 5, 21, 166, 8, 21, 10, 21, 12, 21, 169, 9, 21, 5, 21, 171, 8, 21, 10, 21, 12, 21, 174, 9, 21, 1, 22, 1, 22, 1, 22, 5, 22, 179, 8, 22, 10, 22, 12, 22, 182, 9, 22, 1, 22, 1, 22, 1, 22, 5, 22, 187, 8, 22, 10, 22, 12, 22, 190, 9, 22, 5, 22, 192, 8, 22, 10, 22, 12, 22, 195, 9, 22, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 3, 23, 206, 8, 23, 1, 24, 1, 24, 1, 24, 1, 25, 1, 25, 1, 25, 5, 25, 214, 8, 25, 10, 25, 12, 25, 217, 9, 25, 1, 25, 1, 25, 1, 26, 1, 26, 5, 26, 223, 8, 26, 10, 26, 12, 26, 226, 9, 26, 0, 0, 27, 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, 18, 37, 19, 39, 20, 41, 21, 43, 22, 45, 23, 47, 24, 49, 0, 51, 25, 53, 26, 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, 242, 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, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0, 0, 41, 1, 0, 0, 0, 0, 43, 1, 0, 0, 0, 0, 45, 1, 0, 0, 0, 0, 47, 1, 0, 0, 0, 0, 51, 1, 0, 0, 0, 0, 53, 1, 0, 0, 0, 1, 55, 1, 0, 0, 0, 3, 57, 1, 0, 0, 0, 5, 59, 1, 0, 0, 0, 7, 61, 1, 0, 0, 0, 9, 63, 1, 0, 0, 0, 11, 65, 1, 0, 0, 0, 13, 67, 1, 0, 0, 0, 15, 69, 1, 0, 0, 0, 17, 71, 1, 0, 0, 0, 19, 78, 1, 0, 0, 0, 21, 88, 1, 0, 0, 0, 23, 96, 1, 0, 0, 0, 25, 100, 1, 0, 0, 0, 27, 108, 1, 0, 0, 0, 29, 113, 1, 0, 0, 0, 31, 116, 1, 0, 0, 0, 33, 119, 1, 0, 0, 0, 35, 122, 1, 0, 0, 0, 37, 128, 1, 0, 0, 0, 39, 142, 1, 0, 0, 0, 41, 144, 1, 0, 0, 0, 43, 153, 1, 0, 0, 0, 45, 175, 1, 0, 0, 0, 47, 205, 1, 0, 0, 0, 49, 207, 1, 0, 0, 0, 51, 210, 1, 0, 0, 0, 53, 220, 1, 0, 0, 0, 55, 56, 5, 40, 0, 0, 56, 2, 1, 0, 0, 0, 57, 58, 5, 44, 0, 0, 58, 4, 1, 0, 0, 0, 59, 60, 5, 41, 0, 0, 60, 6, 1, 0, 0, 0, 61, 62, 5, 123, 0, 0, 62, 8, 1, 0, 0, 0, 63, 64, 5, 59, 0, 0, 64, 10, 1, 0, 0, 0, 65, 66, 5, 125, 0, 0, 66, 12, 1, 0, 0, 0, 67, 68, 5, 61, 0, 0, 68, 14, 1, 0, 0, 0, 69, 70, 5, 46, 0, 0, 70, 16, 1, 0, 0, 0, 71, 72, 5, 115, 0, 0, 72, 73, 5, 116, 0, 0, 73, 74, 5, 114, 0, 0, 74, 75, 5, 117, 0, 0, 75, 76, 5, 99, 0, 0, 76, 77, 5, 116, 0, 0, 77, 18, 1, 0, 0, 0, 78, 79, 5, 110, 0, 0, 79, 80, 5, 97, 0, 0, 80, 81, 5, 109, 0, 0, 81, 82, 5, 101, 0, 0, 82, 83, 5, 115, 0, 0, 83, 84, 5, 112, 0, 0, 84, 85, 5, 97, 0, 0, 85, 86, 5, 99, 0, 0, 86, 87, 5, 101, 0, 0, 87, 20, 1, 0, 0, 0, 88, 89, 5, 105, 0, 0, 89, 90, 5, 110, 0, 0, 90, 91, 5, 99, 0, 0, 91, 92, 5, 108, 0, 0, 92, 93, 5, 117, 0, 0, 93, 94, 5, 100, 0, 0, 94, 95, 5, 101, 0, 0, 95, 22, 1, 0, 0, 0, 96, 97, 5, 117, 0, 0, 97, 98, 5, 115, 0, 0, 98, 99, 5, 101, 0, 0, 99, 24, 1, 0, 0, 0, 100, 101, 5, 37, 0, 0, 101, 102, 5, 105, 0, 0, 102, 103, 5, 109, 0, 0, 103, 104, 5, 112, 0, 0, 104, 105, 5, 111, 0, 0, 105, 106, 5, 114, 0, 0, 106, 107, 5, 116, 0, 0, 107, 26, 1, 0, 0, 0, 108, 109, 5, 37, 0, 0, 109, 110, 5, 109, 0, 0, 110, 111, 5, 97, 0, 0, 111, 112, 5, 112, 0, 0, 112, 28, 1, 0, 0, 0, 113, 114, 5, 38, 0, 0, 114, 115, 5, 38, 0, 0, 115, 30, 1, 0, 0, 0, 116, 117, 5, 124, 0, 0, 117, 118, 5, 124, 0, 0, 118, 32, 1, 0, 0, 0, 119, 120, 5, 105, 0, 0, 120, 121, 5, 102, 0, 0, 121, 34, 1, 0, 0, 0, 122, 123, 5, 101, 0, 0, 123, 124, 5, 108, 0, 0, 124, 125, 5, 115, 0, 0, 125, 126, 5, 101, 0, 0, 126, 36, 1, 0, 0, 0, 127, 129, 7, 0, 0, 0, 128, 127, 1, 0, 0, 0, 129, 130, 1, 0, 0, 0, 130, 128, 1, 0, 0, 0, 130, 131, 1, 0, 0, 0, 131, 132, 1, 0, 0, 0, 132, 133, 6, 18, 0, 0, 133, 38, 1, 0, 0, 0, 134, 138, 7, 1, 0, 0, 135, 137, 7, 2, 0, 0, 136, 135, 1, 0, 0, 0, 137, 140, 1, 0, 0, 0, 138, 136, 1, 0, 0, 0, 138, 139, 1, 0, 0, 0, 139, 143, 1, 0, 0, 0, 140, 138, 1, 0, 0, 0, 141, 143, 5, 48, 0, 0, 142, 134, 1, 0, 0, 0, 142, 141, 1, 0, 0, 0, 143, 40, 1, 0, 0, 0, 144, 145, 5, 48, 0, 0, 145, 146, 5, 120, 0, 0, 146, 150, 1, 0, 0, 0, 147, 149, 7, 3, 0, 0, 148, 147, 1, 0, 0, 0, 149, 152, 1, 0, 0, 0, 150, 148, 1, 0, 0, 0, 150, 151, 1, 0, 0, 0, 151, 42, 1, 0, 0, 0, 152, 150, 1, 0, 0, 0, 153, 157, 7, 4, 0, 0, 154, 156, 7, 5, 0, 0, 155, 154, 1, 0, 0, 0, 156, 159, 1, 0, 0, 0, 157, 155, 1, 0, 0, 0, 157, 158, 1, 0, 0, 0, 158, 172, 1, 0, 0, 0, 159, 157, 1, 0, 0, 0, 160, 161, 5, 58, 0, 0, 161, 162, 5, 58, 0, 0, 162, 163, 1, 0, 0, 0, 163, 167, 7, 4, 0, 0, 164, 166, 7, 5, 0, 0, 165, 164, 1, 0, 0, 0, 166, 169, 1, 0, 0, 0, 167, 165, 1, 0, 0, 0, 167, 168, 1, 0, 0, 0, 168, 171, 1, 0, 0, 0, 169, 167, 1, 0, 0, 0, 170, 160, 1, 0, 0, 0, 171, 174, 1, 0, 0, 0, 172, 170, 1, 0, 0, 0, 172, 173, 1, 0, 0, 0, 173, 44, 1, 0, 0, 0, 174, 172, 1, 0, 0, 0, 175, 176, 5, 94, 0, 0, 176, 180, 7, 4, 0, 0, 177, 179, 7, 5, 0, 0, 178, 177, 1, 0, 0, 0, 179, 182, 1, 0, 0, 0, 180, 178, 1, 0, 0, 0, 180, 181, 1, 0, 0, 0, 181, 193, 1, 0, 0, 0, 182, 180, 1, 0, 0, 0, 183, 184, 5, 46, 0, 0, 184, 188, 7, 4, 0, 0, 185, 187, 7, 5, 0, 0, 186, 185, 1, 0, 0, 0, 187, 190, 1, 0, 0, 0, 188, 186, 1, 0, 0, 0, 188, 189, 1, 0, 0, 0, 189, 192, 1, 0, 0, 0, 190, 188, 1, 0, 0, 0, 191, 183, 1, 0, 0, 0, 192, 195, 1, 0, 0, 0, 193, 191, 1, 0, 0, 0, 193, 194, 1, 0, 0, 0, 194, 46, 1, 0, 0, 0, 195, 193, 1, 0, 0, 0, 196, 206, 7, 6, 0, 0, 197, 198, 5, 61, 0, 0, 198, 206, 5, 61, 0, 0, 199, 200, 5, 33, 0, 0, 200, 206, 5, 61, 0, 0, 201, 202, 5, 62, 0, 0, 202, 206, 5, 61, 0, 0, 203, 204, 5, 60, 0, 0, 204, 206, 5, 61, 0, 0, 205, 196, 1, 0, 0, 0, 205, 197, 1, 0, 0, 0, 205, 199, 1, 0, 0, 0, 205, 201, 1, 0, 0, 0, 205, 203, 1, 0, 0, 0, 206, 48, 1, 0, 0, 0, 207, 208, 5, 92, 0, 0, 208, 209, 7, 7, 0, 0, 209, 50, 1, 0, 0, 0, 210, 215, 5, 34, 0, 0, 211, 214, 3, 49, 24, 0, 212, 214, 8, 8, 0, 0, 213, 211, 1, 0, 0, 0, 213, 212, 1, 0, 0, 0, 214, 217, 1, 0, 0, 0, 215, 213, 1, 0, 0, 0, 215, 216, 1, 0, 0, 0, 216, 218, 1, 0, 0, 0, 217, 215, 1, 0, 0, 0, 218, 219, 5, 34, 0, 0, 219, 52, 1, 0, 0, 0, 220, 224, 7, 4, 0, 0, 221, 223, 7, 5, 0, 0, 222, 221, 1, 0, 0, 0, 223, 226, 1, 0, 0, 0, 224, 222, 1, 0, 0, 0, 224, 225, 1, 0, 0, 0, 225, 54, 1, 0, 0, 0, 226, 224, 1, 0, 0, 0, 15, 0, 130, 138, 142, 150, 157, 167, 172, 180, 188, 193, 205, 213, 215, 224, 1, 6, 0, 0] \ No newline at end of file diff --git a/parser/WystLexer.tokens b/parser/WystLexer.tokens index fdf4b67..4e30725 100644 --- a/parser/WystLexer.tokens +++ b/parser/WystLexer.tokens @@ -10,12 +10,20 @@ T__8=9 T__9=10 T__10=11 T__11=12 -WS=13 -NUMBER=14 -HEX=15 -IDENTIFIER=16 -MATH=17 -STRING=18 +T__12=13 +T__13=14 +T__14=15 +T__15=16 +T__16=17 +T__17=18 +WS=19 +NUMBER=20 +HEX=21 +IDENTIFIER=22 +GOIDENTIFIER=23 +MATH=24 +STRING=25 +MODULE_NAME=26 '('=1 ','=2 ')'=3 @@ -28,3 +36,9 @@ STRING=18 'namespace'=10 'include'=11 'use'=12 +'%import'=13 +'%map'=14 +'&&'=15 +'||'=16 +'if'=17 +'else'=18 diff --git a/parser/wyst_base_listener.go b/parser/wyst_base_listener.go index 4da8def..69c6ff4 100644 --- a/parser/wyst_base_listener.go +++ b/parser/wyst_base_listener.go @@ -93,6 +93,54 @@ func (s *BaseWystListener) EnterUse_statement(ctx *Use_statementContext) {} // ExitUse_statement is called when production use_statement is exited. func (s *BaseWystListener) ExitUse_statement(ctx *Use_statementContext) {} +// EnterGo_import is called when production go_import is entered. +func (s *BaseWystListener) EnterGo_import(ctx *Go_importContext) {} + +// ExitGo_import is called when production go_import is exited. +func (s *BaseWystListener) ExitGo_import(ctx *Go_importContext) {} + +// EnterMap is called when production map is entered. +func (s *BaseWystListener) EnterMap(ctx *MapContext) {} + +// ExitMap is called when production map is exited. +func (s *BaseWystListener) ExitMap(ctx *MapContext) {} + +// EnterGo_call is called when production go_call is entered. +func (s *BaseWystListener) EnterGo_call(ctx *Go_callContext) {} + +// ExitGo_call is called when production go_call is exited. +func (s *BaseWystListener) ExitGo_call(ctx *Go_callContext) {} + +// EnterIf_expr is called when production if_expr is entered. +func (s *BaseWystListener) EnterIf_expr(ctx *If_exprContext) {} + +// ExitIf_expr is called when production if_expr is exited. +func (s *BaseWystListener) ExitIf_expr(ctx *If_exprContext) {} + +// EnterIf_statement is called when production if_statement is entered. +func (s *BaseWystListener) EnterIf_statement(ctx *If_statementContext) {} + +// ExitIf_statement is called when production if_statement is exited. +func (s *BaseWystListener) ExitIf_statement(ctx *If_statementContext) {} + +// EnterElseif_statement is called when production elseif_statement is entered. +func (s *BaseWystListener) EnterElseif_statement(ctx *Elseif_statementContext) {} + +// ExitElseif_statement is called when production elseif_statement is exited. +func (s *BaseWystListener) ExitElseif_statement(ctx *Elseif_statementContext) {} + +// EnterElse_statement is called when production else_statement is entered. +func (s *BaseWystListener) EnterElse_statement(ctx *Else_statementContext) {} + +// ExitElse_statement is called when production else_statement is exited. +func (s *BaseWystListener) ExitElse_statement(ctx *Else_statementContext) {} + +// EnterIf_tree is called when production if_tree is entered. +func (s *BaseWystListener) EnterIf_tree(ctx *If_treeContext) {} + +// ExitIf_tree is called when production if_tree is exited. +func (s *BaseWystListener) ExitIf_tree(ctx *If_treeContext) {} + // 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 a629fac..7c2f6e4 100644 --- a/parser/wyst_lexer.go +++ b/parser/wyst_lexer.go @@ -44,85 +44,125 @@ func wystlexerLexerInit() { } staticData.LiteralNames = []string{ "", "'('", "','", "')'", "'{'", "';'", "'}'", "'='", "'.'", "'struct'", - "'namespace'", "'include'", "'use'", + "'namespace'", "'include'", "'use'", "'%import'", "'%map'", "'&&'", + "'||'", "'if'", "'else'", } staticData.SymbolicNames = []string{ - "", "", "", "", "", "", "", "", "", "", "", "", "", "WS", "NUMBER", - "HEX", "IDENTIFIER", "MATH", "STRING", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "WS", "NUMBER", "HEX", "IDENTIFIER", "GOIDENTIFIER", "MATH", + "STRING", "MODULE_NAME", } staticData.RuleNames = []string{ "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8", - "T__9", "T__10", "T__11", "WS", "NUMBER", "HEX", "IDENTIFIER", "MATH", - "ESC", "STRING", + "T__9", "T__10", "T__11", "T__12", "T__13", "T__14", "T__15", "T__16", + "T__17", "WS", "NUMBER", "HEX", "IDENTIFIER", "GOIDENTIFIER", "MATH", + "ESC", "STRING", "MODULE_NAME", } staticData.PredictionContextCache = antlr.NewPredictionContextCache() staticData.serializedATN = []int32{ - 4, 0, 18, 147, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, + 4, 0, 26, 227, 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, 9, - 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, - 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 11, 1, 12, 4, 12, 86, 8, 12, 11, - 12, 12, 12, 87, 1, 12, 1, 12, 1, 13, 1, 13, 5, 13, 94, 8, 13, 10, 13, 12, - 13, 97, 9, 13, 1, 13, 3, 13, 100, 8, 13, 1, 14, 1, 14, 1, 14, 1, 14, 5, - 14, 106, 8, 14, 10, 14, 12, 14, 109, 9, 14, 1, 15, 1, 15, 5, 15, 113, 8, - 15, 10, 15, 12, 15, 116, 9, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 5, 15, - 123, 8, 15, 10, 15, 12, 15, 126, 9, 15, 5, 15, 128, 8, 15, 10, 15, 12, - 15, 131, 9, 15, 1, 16, 1, 16, 1, 17, 1, 17, 1, 17, 1, 18, 1, 18, 1, 18, - 5, 18, 141, 8, 18, 10, 18, 12, 18, 144, 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, 154, 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, 72, 1, 0, 0, 0, - 23, 80, 1, 0, 0, 0, 25, 85, 1, 0, 0, 0, 27, 99, 1, 0, 0, 0, 29, 101, 1, - 0, 0, 0, 31, 110, 1, 0, 0, 0, 33, 132, 1, 0, 0, 0, 35, 134, 1, 0, 0, 0, - 37, 137, 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, 110, 0, 0, 63, 64, 5, 97, 0, 0, 64, 65, 5, 109, 0, 0, 65, 66, 5, 101, - 0, 0, 66, 67, 5, 115, 0, 0, 67, 68, 5, 112, 0, 0, 68, 69, 5, 97, 0, 0, - 69, 70, 5, 99, 0, 0, 70, 71, 5, 101, 0, 0, 71, 20, 1, 0, 0, 0, 72, 73, - 5, 105, 0, 0, 73, 74, 5, 110, 0, 0, 74, 75, 5, 99, 0, 0, 75, 76, 5, 108, - 0, 0, 76, 77, 5, 117, 0, 0, 77, 78, 5, 100, 0, 0, 78, 79, 5, 101, 0, 0, - 79, 22, 1, 0, 0, 0, 80, 81, 5, 117, 0, 0, 81, 82, 5, 115, 0, 0, 82, 83, - 5, 101, 0, 0, 83, 24, 1, 0, 0, 0, 84, 86, 7, 0, 0, 0, 85, 84, 1, 0, 0, - 0, 86, 87, 1, 0, 0, 0, 87, 85, 1, 0, 0, 0, 87, 88, 1, 0, 0, 0, 88, 89, - 1, 0, 0, 0, 89, 90, 6, 12, 0, 0, 90, 26, 1, 0, 0, 0, 91, 95, 7, 1, 0, 0, - 92, 94, 7, 2, 0, 0, 93, 92, 1, 0, 0, 0, 94, 97, 1, 0, 0, 0, 95, 93, 1, - 0, 0, 0, 95, 96, 1, 0, 0, 0, 96, 100, 1, 0, 0, 0, 97, 95, 1, 0, 0, 0, 98, - 100, 5, 48, 0, 0, 99, 91, 1, 0, 0, 0, 99, 98, 1, 0, 0, 0, 100, 28, 1, 0, - 0, 0, 101, 102, 5, 48, 0, 0, 102, 103, 5, 120, 0, 0, 103, 107, 1, 0, 0, - 0, 104, 106, 7, 3, 0, 0, 105, 104, 1, 0, 0, 0, 106, 109, 1, 0, 0, 0, 107, - 105, 1, 0, 0, 0, 107, 108, 1, 0, 0, 0, 108, 30, 1, 0, 0, 0, 109, 107, 1, - 0, 0, 0, 110, 114, 7, 4, 0, 0, 111, 113, 7, 5, 0, 0, 112, 111, 1, 0, 0, - 0, 113, 116, 1, 0, 0, 0, 114, 112, 1, 0, 0, 0, 114, 115, 1, 0, 0, 0, 115, - 129, 1, 0, 0, 0, 116, 114, 1, 0, 0, 0, 117, 118, 5, 58, 0, 0, 118, 119, - 5, 58, 0, 0, 119, 120, 1, 0, 0, 0, 120, 124, 7, 4, 0, 0, 121, 123, 7, 5, - 0, 0, 122, 121, 1, 0, 0, 0, 123, 126, 1, 0, 0, 0, 124, 122, 1, 0, 0, 0, - 124, 125, 1, 0, 0, 0, 125, 128, 1, 0, 0, 0, 126, 124, 1, 0, 0, 0, 127, - 117, 1, 0, 0, 0, 128, 131, 1, 0, 0, 0, 129, 127, 1, 0, 0, 0, 129, 130, - 1, 0, 0, 0, 130, 32, 1, 0, 0, 0, 131, 129, 1, 0, 0, 0, 132, 133, 7, 6, - 0, 0, 133, 34, 1, 0, 0, 0, 134, 135, 5, 92, 0, 0, 135, 136, 7, 7, 0, 0, - 136, 36, 1, 0, 0, 0, 137, 142, 5, 34, 0, 0, 138, 141, 3, 35, 17, 0, 139, - 141, 8, 8, 0, 0, 140, 138, 1, 0, 0, 0, 140, 139, 1, 0, 0, 0, 141, 144, - 1, 0, 0, 0, 142, 140, 1, 0, 0, 0, 142, 143, 1, 0, 0, 0, 143, 145, 1, 0, - 0, 0, 144, 142, 1, 0, 0, 0, 145, 146, 5, 34, 0, 0, 146, 38, 1, 0, 0, 0, - 10, 0, 87, 95, 99, 107, 114, 124, 129, 140, 142, 1, 6, 0, 0, + 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, + 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, + 2, 26, 7, 26, 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, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, + 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, + 1, 11, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 13, 1, + 13, 1, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 15, 1, 16, + 1, 16, 1, 16, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 18, 4, 18, 129, 8, + 18, 11, 18, 12, 18, 130, 1, 18, 1, 18, 1, 19, 1, 19, 5, 19, 137, 8, 19, + 10, 19, 12, 19, 140, 9, 19, 1, 19, 3, 19, 143, 8, 19, 1, 20, 1, 20, 1, + 20, 1, 20, 5, 20, 149, 8, 20, 10, 20, 12, 20, 152, 9, 20, 1, 21, 1, 21, + 5, 21, 156, 8, 21, 10, 21, 12, 21, 159, 9, 21, 1, 21, 1, 21, 1, 21, 1, + 21, 1, 21, 5, 21, 166, 8, 21, 10, 21, 12, 21, 169, 9, 21, 5, 21, 171, 8, + 21, 10, 21, 12, 21, 174, 9, 21, 1, 22, 1, 22, 1, 22, 5, 22, 179, 8, 22, + 10, 22, 12, 22, 182, 9, 22, 1, 22, 1, 22, 1, 22, 5, 22, 187, 8, 22, 10, + 22, 12, 22, 190, 9, 22, 5, 22, 192, 8, 22, 10, 22, 12, 22, 195, 9, 22, + 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 3, 23, 206, + 8, 23, 1, 24, 1, 24, 1, 24, 1, 25, 1, 25, 1, 25, 5, 25, 214, 8, 25, 10, + 25, 12, 25, 217, 9, 25, 1, 25, 1, 25, 1, 26, 1, 26, 5, 26, 223, 8, 26, + 10, 26, 12, 26, 226, 9, 26, 0, 0, 27, 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, 18, 37, 19, 39, 20, 41, 21, 43, 22, 45, 23, 47, 24, + 49, 0, 51, 25, 53, 26, 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, 242, 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, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0, + 0, 41, 1, 0, 0, 0, 0, 43, 1, 0, 0, 0, 0, 45, 1, 0, 0, 0, 0, 47, 1, 0, 0, + 0, 0, 51, 1, 0, 0, 0, 0, 53, 1, 0, 0, 0, 1, 55, 1, 0, 0, 0, 3, 57, 1, 0, + 0, 0, 5, 59, 1, 0, 0, 0, 7, 61, 1, 0, 0, 0, 9, 63, 1, 0, 0, 0, 11, 65, + 1, 0, 0, 0, 13, 67, 1, 0, 0, 0, 15, 69, 1, 0, 0, 0, 17, 71, 1, 0, 0, 0, + 19, 78, 1, 0, 0, 0, 21, 88, 1, 0, 0, 0, 23, 96, 1, 0, 0, 0, 25, 100, 1, + 0, 0, 0, 27, 108, 1, 0, 0, 0, 29, 113, 1, 0, 0, 0, 31, 116, 1, 0, 0, 0, + 33, 119, 1, 0, 0, 0, 35, 122, 1, 0, 0, 0, 37, 128, 1, 0, 0, 0, 39, 142, + 1, 0, 0, 0, 41, 144, 1, 0, 0, 0, 43, 153, 1, 0, 0, 0, 45, 175, 1, 0, 0, + 0, 47, 205, 1, 0, 0, 0, 49, 207, 1, 0, 0, 0, 51, 210, 1, 0, 0, 0, 53, 220, + 1, 0, 0, 0, 55, 56, 5, 40, 0, 0, 56, 2, 1, 0, 0, 0, 57, 58, 5, 44, 0, 0, + 58, 4, 1, 0, 0, 0, 59, 60, 5, 41, 0, 0, 60, 6, 1, 0, 0, 0, 61, 62, 5, 123, + 0, 0, 62, 8, 1, 0, 0, 0, 63, 64, 5, 59, 0, 0, 64, 10, 1, 0, 0, 0, 65, 66, + 5, 125, 0, 0, 66, 12, 1, 0, 0, 0, 67, 68, 5, 61, 0, 0, 68, 14, 1, 0, 0, + 0, 69, 70, 5, 46, 0, 0, 70, 16, 1, 0, 0, 0, 71, 72, 5, 115, 0, 0, 72, 73, + 5, 116, 0, 0, 73, 74, 5, 114, 0, 0, 74, 75, 5, 117, 0, 0, 75, 76, 5, 99, + 0, 0, 76, 77, 5, 116, 0, 0, 77, 18, 1, 0, 0, 0, 78, 79, 5, 110, 0, 0, 79, + 80, 5, 97, 0, 0, 80, 81, 5, 109, 0, 0, 81, 82, 5, 101, 0, 0, 82, 83, 5, + 115, 0, 0, 83, 84, 5, 112, 0, 0, 84, 85, 5, 97, 0, 0, 85, 86, 5, 99, 0, + 0, 86, 87, 5, 101, 0, 0, 87, 20, 1, 0, 0, 0, 88, 89, 5, 105, 0, 0, 89, + 90, 5, 110, 0, 0, 90, 91, 5, 99, 0, 0, 91, 92, 5, 108, 0, 0, 92, 93, 5, + 117, 0, 0, 93, 94, 5, 100, 0, 0, 94, 95, 5, 101, 0, 0, 95, 22, 1, 0, 0, + 0, 96, 97, 5, 117, 0, 0, 97, 98, 5, 115, 0, 0, 98, 99, 5, 101, 0, 0, 99, + 24, 1, 0, 0, 0, 100, 101, 5, 37, 0, 0, 101, 102, 5, 105, 0, 0, 102, 103, + 5, 109, 0, 0, 103, 104, 5, 112, 0, 0, 104, 105, 5, 111, 0, 0, 105, 106, + 5, 114, 0, 0, 106, 107, 5, 116, 0, 0, 107, 26, 1, 0, 0, 0, 108, 109, 5, + 37, 0, 0, 109, 110, 5, 109, 0, 0, 110, 111, 5, 97, 0, 0, 111, 112, 5, 112, + 0, 0, 112, 28, 1, 0, 0, 0, 113, 114, 5, 38, 0, 0, 114, 115, 5, 38, 0, 0, + 115, 30, 1, 0, 0, 0, 116, 117, 5, 124, 0, 0, 117, 118, 5, 124, 0, 0, 118, + 32, 1, 0, 0, 0, 119, 120, 5, 105, 0, 0, 120, 121, 5, 102, 0, 0, 121, 34, + 1, 0, 0, 0, 122, 123, 5, 101, 0, 0, 123, 124, 5, 108, 0, 0, 124, 125, 5, + 115, 0, 0, 125, 126, 5, 101, 0, 0, 126, 36, 1, 0, 0, 0, 127, 129, 7, 0, + 0, 0, 128, 127, 1, 0, 0, 0, 129, 130, 1, 0, 0, 0, 130, 128, 1, 0, 0, 0, + 130, 131, 1, 0, 0, 0, 131, 132, 1, 0, 0, 0, 132, 133, 6, 18, 0, 0, 133, + 38, 1, 0, 0, 0, 134, 138, 7, 1, 0, 0, 135, 137, 7, 2, 0, 0, 136, 135, 1, + 0, 0, 0, 137, 140, 1, 0, 0, 0, 138, 136, 1, 0, 0, 0, 138, 139, 1, 0, 0, + 0, 139, 143, 1, 0, 0, 0, 140, 138, 1, 0, 0, 0, 141, 143, 5, 48, 0, 0, 142, + 134, 1, 0, 0, 0, 142, 141, 1, 0, 0, 0, 143, 40, 1, 0, 0, 0, 144, 145, 5, + 48, 0, 0, 145, 146, 5, 120, 0, 0, 146, 150, 1, 0, 0, 0, 147, 149, 7, 3, + 0, 0, 148, 147, 1, 0, 0, 0, 149, 152, 1, 0, 0, 0, 150, 148, 1, 0, 0, 0, + 150, 151, 1, 0, 0, 0, 151, 42, 1, 0, 0, 0, 152, 150, 1, 0, 0, 0, 153, 157, + 7, 4, 0, 0, 154, 156, 7, 5, 0, 0, 155, 154, 1, 0, 0, 0, 156, 159, 1, 0, + 0, 0, 157, 155, 1, 0, 0, 0, 157, 158, 1, 0, 0, 0, 158, 172, 1, 0, 0, 0, + 159, 157, 1, 0, 0, 0, 160, 161, 5, 58, 0, 0, 161, 162, 5, 58, 0, 0, 162, + 163, 1, 0, 0, 0, 163, 167, 7, 4, 0, 0, 164, 166, 7, 5, 0, 0, 165, 164, + 1, 0, 0, 0, 166, 169, 1, 0, 0, 0, 167, 165, 1, 0, 0, 0, 167, 168, 1, 0, + 0, 0, 168, 171, 1, 0, 0, 0, 169, 167, 1, 0, 0, 0, 170, 160, 1, 0, 0, 0, + 171, 174, 1, 0, 0, 0, 172, 170, 1, 0, 0, 0, 172, 173, 1, 0, 0, 0, 173, + 44, 1, 0, 0, 0, 174, 172, 1, 0, 0, 0, 175, 176, 5, 94, 0, 0, 176, 180, + 7, 4, 0, 0, 177, 179, 7, 5, 0, 0, 178, 177, 1, 0, 0, 0, 179, 182, 1, 0, + 0, 0, 180, 178, 1, 0, 0, 0, 180, 181, 1, 0, 0, 0, 181, 193, 1, 0, 0, 0, + 182, 180, 1, 0, 0, 0, 183, 184, 5, 46, 0, 0, 184, 188, 7, 4, 0, 0, 185, + 187, 7, 5, 0, 0, 186, 185, 1, 0, 0, 0, 187, 190, 1, 0, 0, 0, 188, 186, + 1, 0, 0, 0, 188, 189, 1, 0, 0, 0, 189, 192, 1, 0, 0, 0, 190, 188, 1, 0, + 0, 0, 191, 183, 1, 0, 0, 0, 192, 195, 1, 0, 0, 0, 193, 191, 1, 0, 0, 0, + 193, 194, 1, 0, 0, 0, 194, 46, 1, 0, 0, 0, 195, 193, 1, 0, 0, 0, 196, 206, + 7, 6, 0, 0, 197, 198, 5, 61, 0, 0, 198, 206, 5, 61, 0, 0, 199, 200, 5, + 33, 0, 0, 200, 206, 5, 61, 0, 0, 201, 202, 5, 62, 0, 0, 202, 206, 5, 61, + 0, 0, 203, 204, 5, 60, 0, 0, 204, 206, 5, 61, 0, 0, 205, 196, 1, 0, 0, + 0, 205, 197, 1, 0, 0, 0, 205, 199, 1, 0, 0, 0, 205, 201, 1, 0, 0, 0, 205, + 203, 1, 0, 0, 0, 206, 48, 1, 0, 0, 0, 207, 208, 5, 92, 0, 0, 208, 209, + 7, 7, 0, 0, 209, 50, 1, 0, 0, 0, 210, 215, 5, 34, 0, 0, 211, 214, 3, 49, + 24, 0, 212, 214, 8, 8, 0, 0, 213, 211, 1, 0, 0, 0, 213, 212, 1, 0, 0, 0, + 214, 217, 1, 0, 0, 0, 215, 213, 1, 0, 0, 0, 215, 216, 1, 0, 0, 0, 216, + 218, 1, 0, 0, 0, 217, 215, 1, 0, 0, 0, 218, 219, 5, 34, 0, 0, 219, 52, + 1, 0, 0, 0, 220, 224, 7, 4, 0, 0, 221, 223, 7, 5, 0, 0, 222, 221, 1, 0, + 0, 0, 223, 226, 1, 0, 0, 0, 224, 222, 1, 0, 0, 0, 224, 225, 1, 0, 0, 0, + 225, 54, 1, 0, 0, 0, 226, 224, 1, 0, 0, 0, 15, 0, 130, 138, 142, 150, 157, + 167, 172, 180, 188, 193, 205, 213, 215, 224, 1, 6, 0, 0, } deserializer := antlr.NewATNDeserializer(nil) staticData.atn = deserializer.Deserialize(staticData.serializedATN) @@ -163,22 +203,30 @@ func NewWystLexer(input antlr.CharStream) *WystLexer { // WystLexer tokens. const ( - WystLexerT__0 = 1 - WystLexerT__1 = 2 - WystLexerT__2 = 3 - WystLexerT__3 = 4 - WystLexerT__4 = 5 - WystLexerT__5 = 6 - WystLexerT__6 = 7 - WystLexerT__7 = 8 - WystLexerT__8 = 9 - WystLexerT__9 = 10 - WystLexerT__10 = 11 - WystLexerT__11 = 12 - WystLexerWS = 13 - WystLexerNUMBER = 14 - WystLexerHEX = 15 - WystLexerIDENTIFIER = 16 - WystLexerMATH = 17 - WystLexerSTRING = 18 + WystLexerT__0 = 1 + WystLexerT__1 = 2 + WystLexerT__2 = 3 + WystLexerT__3 = 4 + WystLexerT__4 = 5 + WystLexerT__5 = 6 + WystLexerT__6 = 7 + WystLexerT__7 = 8 + WystLexerT__8 = 9 + WystLexerT__9 = 10 + WystLexerT__10 = 11 + WystLexerT__11 = 12 + WystLexerT__12 = 13 + WystLexerT__13 = 14 + WystLexerT__14 = 15 + WystLexerT__15 = 16 + WystLexerT__16 = 17 + WystLexerT__17 = 18 + WystLexerWS = 19 + WystLexerNUMBER = 20 + WystLexerHEX = 21 + WystLexerIDENTIFIER = 22 + WystLexerGOIDENTIFIER = 23 + WystLexerMATH = 24 + WystLexerSTRING = 25 + WystLexerMODULE_NAME = 26 ) diff --git a/parser/wyst_listener.go b/parser/wyst_listener.go index 55c1d21..6c6f06c 100644 --- a/parser/wyst_listener.go +++ b/parser/wyst_listener.go @@ -44,6 +44,30 @@ type WystListener interface { // EnterUse_statement is called when entering the use_statement production. EnterUse_statement(c *Use_statementContext) + // EnterGo_import is called when entering the go_import production. + EnterGo_import(c *Go_importContext) + + // EnterMap is called when entering the map production. + EnterMap(c *MapContext) + + // EnterGo_call is called when entering the go_call production. + EnterGo_call(c *Go_callContext) + + // EnterIf_expr is called when entering the if_expr production. + EnterIf_expr(c *If_exprContext) + + // EnterIf_statement is called when entering the if_statement production. + EnterIf_statement(c *If_statementContext) + + // EnterElseif_statement is called when entering the elseif_statement production. + EnterElseif_statement(c *Elseif_statementContext) + + // EnterElse_statement is called when entering the else_statement production. + EnterElse_statement(c *Else_statementContext) + + // EnterIf_tree is called when entering the if_tree production. + EnterIf_tree(c *If_treeContext) + // EnterExpr is called when entering the expr production. EnterExpr(c *ExprContext) @@ -89,6 +113,30 @@ type WystListener interface { // ExitUse_statement is called when exiting the use_statement production. ExitUse_statement(c *Use_statementContext) + // ExitGo_import is called when exiting the go_import production. + ExitGo_import(c *Go_importContext) + + // ExitMap is called when exiting the map production. + ExitMap(c *MapContext) + + // ExitGo_call is called when exiting the go_call production. + ExitGo_call(c *Go_callContext) + + // ExitIf_expr is called when exiting the if_expr production. + ExitIf_expr(c *If_exprContext) + + // ExitIf_statement is called when exiting the if_statement production. + ExitIf_statement(c *If_statementContext) + + // ExitElseif_statement is called when exiting the elseif_statement production. + ExitElseif_statement(c *Elseif_statementContext) + + // ExitElse_statement is called when exiting the else_statement production. + ExitElse_statement(c *Else_statementContext) + + // ExitIf_tree is called when exiting the if_tree production. + ExitIf_tree(c *If_treeContext) + // ExitExpr is called when exiting the expr production. ExitExpr(c *ExprContext) diff --git a/parser/wyst_parser.go b/parser/wyst_parser.go index 03d0b76..06ec700 100644 --- a/parser/wyst_parser.go +++ b/parser/wyst_parser.go @@ -34,92 +34,128 @@ func wystParserInit() { staticData := &WystParserStaticData staticData.LiteralNames = []string{ "", "'('", "','", "')'", "'{'", "';'", "'}'", "'='", "'.'", "'struct'", - "'namespace'", "'include'", "'use'", + "'namespace'", "'include'", "'use'", "'%import'", "'%map'", "'&&'", + "'||'", "'if'", "'else'", } staticData.SymbolicNames = []string{ - "", "", "", "", "", "", "", "", "", "", "", "", "", "WS", "NUMBER", - "HEX", "IDENTIFIER", "MATH", "STRING", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "WS", "NUMBER", "HEX", "IDENTIFIER", "GOIDENTIFIER", "MATH", + "STRING", "MODULE_NAME", } staticData.RuleNames = []string{ "round_def", "enum_curly", "round_call", "fn_call", "func_def", "var_def", "var_def_set", "call_tree", "struct_def", "namespace", "import_statement", - "use_statement", "expr", "code_block", "top", + "use_statement", "go_import", "map", "go_call", "if_expr", "if_statement", + "elseif_statement", "else_statement", "if_tree", "expr", "code_block", + "top", } staticData.PredictionContextCache = antlr.NewPredictionContextCache() staticData.serializedATN = []int32{ - 4, 1, 18, 171, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, + 4, 1, 26, 244, 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, 9, 1, 9, 1, 9, 3, 9, 112, 8, 9, 1, 9, 1, 9, 1, 9, - 5, 9, 117, 8, 9, 10, 9, 12, 9, 120, 9, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, - 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, - 3, 12, 137, 8, 12, 1, 12, 1, 12, 5, 12, 141, 8, 12, 10, 12, 12, 12, 144, - 9, 12, 1, 13, 1, 13, 1, 13, 1, 13, 3, 13, 150, 8, 13, 1, 13, 1, 13, 5, - 13, 154, 8, 13, 10, 13, 12, 13, 157, 9, 13, 1, 13, 1, 13, 1, 14, 1, 14, - 1, 14, 1, 14, 1, 14, 5, 14, 166, 8, 14, 10, 14, 12, 14, 169, 9, 14, 1, - 14, 0, 0, 15, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 0, - 0, 181, 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, 123, - 1, 0, 0, 0, 22, 127, 1, 0, 0, 0, 24, 136, 1, 0, 0, 0, 26, 145, 1, 0, 0, - 0, 28, 167, 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, 108, 5, 16, 0, 0, - 108, 118, 5, 4, 0, 0, 109, 112, 3, 10, 5, 0, 110, 112, 3, 12, 6, 0, 111, - 109, 1, 0, 0, 0, 111, 110, 1, 0, 0, 0, 112, 113, 1, 0, 0, 0, 113, 114, - 5, 5, 0, 0, 114, 117, 1, 0, 0, 0, 115, 117, 3, 8, 4, 0, 116, 111, 1, 0, - 0, 0, 116, 115, 1, 0, 0, 0, 117, 120, 1, 0, 0, 0, 118, 116, 1, 0, 0, 0, - 118, 119, 1, 0, 0, 0, 119, 121, 1, 0, 0, 0, 120, 118, 1, 0, 0, 0, 121, - 122, 5, 6, 0, 0, 122, 19, 1, 0, 0, 0, 123, 124, 5, 11, 0, 0, 124, 125, - 5, 16, 0, 0, 125, 126, 5, 5, 0, 0, 126, 21, 1, 0, 0, 0, 127, 128, 5, 12, - 0, 0, 128, 129, 5, 16, 0, 0, 129, 130, 5, 5, 0, 0, 130, 23, 1, 0, 0, 0, - 131, 137, 3, 14, 7, 0, 132, 137, 5, 14, 0, 0, 133, 137, 5, 15, 0, 0, 134, - 137, 5, 16, 0, 0, 135, 137, 5, 18, 0, 0, 136, 131, 1, 0, 0, 0, 136, 132, - 1, 0, 0, 0, 136, 133, 1, 0, 0, 0, 136, 134, 1, 0, 0, 0, 136, 135, 1, 0, - 0, 0, 137, 142, 1, 0, 0, 0, 138, 139, 5, 17, 0, 0, 139, 141, 3, 24, 12, - 0, 140, 138, 1, 0, 0, 0, 141, 144, 1, 0, 0, 0, 142, 140, 1, 0, 0, 0, 142, - 143, 1, 0, 0, 0, 143, 25, 1, 0, 0, 0, 144, 142, 1, 0, 0, 0, 145, 155, 5, - 4, 0, 0, 146, 150, 3, 24, 12, 0, 147, 150, 3, 10, 5, 0, 148, 150, 3, 12, - 6, 0, 149, 146, 1, 0, 0, 0, 149, 147, 1, 0, 0, 0, 149, 148, 1, 0, 0, 0, - 150, 151, 1, 0, 0, 0, 151, 152, 5, 5, 0, 0, 152, 154, 1, 0, 0, 0, 153, - 149, 1, 0, 0, 0, 154, 157, 1, 0, 0, 0, 155, 153, 1, 0, 0, 0, 155, 156, - 1, 0, 0, 0, 156, 158, 1, 0, 0, 0, 157, 155, 1, 0, 0, 0, 158, 159, 5, 6, - 0, 0, 159, 27, 1, 0, 0, 0, 160, 166, 3, 8, 4, 0, 161, 166, 3, 16, 8, 0, - 162, 166, 3, 18, 9, 0, 163, 166, 3, 20, 10, 0, 164, 166, 3, 22, 11, 0, - 165, 160, 1, 0, 0, 0, 165, 161, 1, 0, 0, 0, 165, 162, 1, 0, 0, 0, 165, - 163, 1, 0, 0, 0, 165, 164, 1, 0, 0, 0, 166, 169, 1, 0, 0, 0, 167, 165, - 1, 0, 0, 0, 167, 168, 1, 0, 0, 0, 168, 29, 1, 0, 0, 0, 169, 167, 1, 0, - 0, 0, 19, 36, 40, 42, 52, 63, 67, 69, 90, 95, 99, 111, 116, 118, 136, 142, - 149, 155, 165, 167, + 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, + 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, + 21, 7, 21, 2, 22, 7, 22, 1, 0, 1, 0, 1, 0, 1, 0, 5, 0, 51, 8, 0, 10, 0, + 12, 0, 54, 9, 0, 1, 0, 3, 0, 57, 8, 0, 3, 0, 59, 8, 0, 1, 0, 1, 0, 1, 1, + 1, 1, 1, 1, 1, 1, 5, 1, 67, 8, 1, 10, 1, 12, 1, 70, 9, 1, 1, 1, 1, 1, 1, + 2, 1, 2, 1, 2, 1, 2, 5, 2, 78, 8, 2, 10, 2, 12, 2, 81, 9, 2, 1, 2, 3, 2, + 84, 8, 2, 3, 2, 86, 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, 107, 8, 7, 1, 7, 1, 7, 1, 7, 3, 7, 112, 8, 7, 5, 7, 114, 8, 7, 10, 7, + 12, 7, 117, 9, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, + 3, 9, 128, 8, 9, 1, 9, 1, 9, 1, 9, 5, 9, 133, 8, 9, 10, 9, 12, 9, 136, + 9, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 11, + 1, 12, 1, 12, 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, + 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 15, 1, 15, 5, 15, 165, 8, 15, 10, 15, + 12, 15, 168, 9, 15, 1, 15, 1, 15, 1, 16, 1, 16, 1, 16, 5, 16, 175, 8, 16, + 10, 16, 12, 16, 178, 9, 16, 1, 17, 1, 17, 1, 17, 1, 18, 1, 18, 5, 18, 185, + 8, 18, 10, 18, 12, 18, 188, 9, 18, 1, 19, 1, 19, 5, 19, 192, 8, 19, 10, + 19, 12, 19, 195, 9, 19, 1, 19, 3, 19, 198, 8, 19, 1, 20, 1, 20, 1, 20, + 1, 20, 1, 20, 1, 20, 1, 20, 3, 20, 207, 8, 20, 1, 20, 1, 20, 5, 20, 211, + 8, 20, 10, 20, 12, 20, 214, 9, 20, 1, 21, 1, 21, 1, 21, 1, 21, 3, 21, 220, + 8, 21, 1, 21, 1, 21, 1, 21, 5, 21, 225, 8, 21, 10, 21, 12, 21, 228, 9, + 21, 1, 21, 1, 21, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 5, 22, + 239, 8, 22, 10, 22, 12, 22, 242, 9, 22, 1, 22, 0, 0, 23, 0, 2, 4, 6, 8, + 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, + 0, 1, 1, 0, 15, 16, 256, 0, 46, 1, 0, 0, 0, 2, 62, 1, 0, 0, 0, 4, 73, 1, + 0, 0, 0, 6, 89, 1, 0, 0, 0, 8, 92, 1, 0, 0, 0, 10, 97, 1, 0, 0, 0, 12, + 100, 1, 0, 0, 0, 14, 106, 1, 0, 0, 0, 16, 118, 1, 0, 0, 0, 18, 122, 1, + 0, 0, 0, 20, 139, 1, 0, 0, 0, 22, 143, 1, 0, 0, 0, 24, 147, 1, 0, 0, 0, + 26, 151, 1, 0, 0, 0, 28, 157, 1, 0, 0, 0, 30, 160, 1, 0, 0, 0, 32, 171, + 1, 0, 0, 0, 34, 179, 1, 0, 0, 0, 36, 182, 1, 0, 0, 0, 38, 189, 1, 0, 0, + 0, 40, 206, 1, 0, 0, 0, 42, 215, 1, 0, 0, 0, 44, 240, 1, 0, 0, 0, 46, 58, + 5, 1, 0, 0, 47, 52, 3, 10, 5, 0, 48, 49, 5, 2, 0, 0, 49, 51, 3, 10, 5, + 0, 50, 48, 1, 0, 0, 0, 51, 54, 1, 0, 0, 0, 52, 50, 1, 0, 0, 0, 52, 53, + 1, 0, 0, 0, 53, 56, 1, 0, 0, 0, 54, 52, 1, 0, 0, 0, 55, 57, 5, 2, 0, 0, + 56, 55, 1, 0, 0, 0, 56, 57, 1, 0, 0, 0, 57, 59, 1, 0, 0, 0, 58, 47, 1, + 0, 0, 0, 58, 59, 1, 0, 0, 0, 59, 60, 1, 0, 0, 0, 60, 61, 5, 3, 0, 0, 61, + 1, 1, 0, 0, 0, 62, 68, 5, 4, 0, 0, 63, 64, 3, 10, 5, 0, 64, 65, 5, 5, 0, + 0, 65, 67, 1, 0, 0, 0, 66, 63, 1, 0, 0, 0, 67, 70, 1, 0, 0, 0, 68, 66, + 1, 0, 0, 0, 68, 69, 1, 0, 0, 0, 69, 71, 1, 0, 0, 0, 70, 68, 1, 0, 0, 0, + 71, 72, 5, 6, 0, 0, 72, 3, 1, 0, 0, 0, 73, 85, 5, 1, 0, 0, 74, 79, 3, 40, + 20, 0, 75, 76, 5, 2, 0, 0, 76, 78, 3, 40, 20, 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, 83, 1, 0, 0, + 0, 81, 79, 1, 0, 0, 0, 82, 84, 5, 2, 0, 0, 83, 82, 1, 0, 0, 0, 83, 84, + 1, 0, 0, 0, 84, 86, 1, 0, 0, 0, 85, 74, 1, 0, 0, 0, 85, 86, 1, 0, 0, 0, + 86, 87, 1, 0, 0, 0, 87, 88, 5, 3, 0, 0, 88, 5, 1, 0, 0, 0, 89, 90, 5, 22, + 0, 0, 90, 91, 3, 4, 2, 0, 91, 7, 1, 0, 0, 0, 92, 93, 5, 22, 0, 0, 93, 94, + 5, 22, 0, 0, 94, 95, 3, 0, 0, 0, 95, 96, 3, 42, 21, 0, 96, 9, 1, 0, 0, + 0, 97, 98, 5, 22, 0, 0, 98, 99, 5, 22, 0, 0, 99, 11, 1, 0, 0, 0, 100, 101, + 3, 10, 5, 0, 101, 102, 5, 7, 0, 0, 102, 103, 3, 40, 20, 0, 103, 13, 1, + 0, 0, 0, 104, 107, 3, 6, 3, 0, 105, 107, 5, 22, 0, 0, 106, 104, 1, 0, 0, + 0, 106, 105, 1, 0, 0, 0, 107, 115, 1, 0, 0, 0, 108, 111, 5, 8, 0, 0, 109, + 112, 3, 6, 3, 0, 110, 112, 5, 22, 0, 0, 111, 109, 1, 0, 0, 0, 111, 110, + 1, 0, 0, 0, 112, 114, 1, 0, 0, 0, 113, 108, 1, 0, 0, 0, 114, 117, 1, 0, + 0, 0, 115, 113, 1, 0, 0, 0, 115, 116, 1, 0, 0, 0, 116, 15, 1, 0, 0, 0, + 117, 115, 1, 0, 0, 0, 118, 119, 5, 9, 0, 0, 119, 120, 5, 22, 0, 0, 120, + 121, 3, 2, 1, 0, 121, 17, 1, 0, 0, 0, 122, 123, 5, 10, 0, 0, 123, 124, + 5, 22, 0, 0, 124, 134, 5, 4, 0, 0, 125, 128, 3, 10, 5, 0, 126, 128, 3, + 12, 6, 0, 127, 125, 1, 0, 0, 0, 127, 126, 1, 0, 0, 0, 128, 129, 1, 0, 0, + 0, 129, 130, 5, 5, 0, 0, 130, 133, 1, 0, 0, 0, 131, 133, 3, 8, 4, 0, 132, + 127, 1, 0, 0, 0, 132, 131, 1, 0, 0, 0, 133, 136, 1, 0, 0, 0, 134, 132, + 1, 0, 0, 0, 134, 135, 1, 0, 0, 0, 135, 137, 1, 0, 0, 0, 136, 134, 1, 0, + 0, 0, 137, 138, 5, 6, 0, 0, 138, 19, 1, 0, 0, 0, 139, 140, 5, 11, 0, 0, + 140, 141, 5, 26, 0, 0, 141, 142, 5, 5, 0, 0, 142, 21, 1, 0, 0, 0, 143, + 144, 5, 12, 0, 0, 144, 145, 5, 22, 0, 0, 145, 146, 5, 5, 0, 0, 146, 23, + 1, 0, 0, 0, 147, 148, 5, 13, 0, 0, 148, 149, 5, 25, 0, 0, 149, 150, 5, + 5, 0, 0, 150, 25, 1, 0, 0, 0, 151, 152, 5, 14, 0, 0, 152, 153, 5, 22, 0, + 0, 153, 154, 5, 2, 0, 0, 154, 155, 5, 22, 0, 0, 155, 156, 5, 5, 0, 0, 156, + 27, 1, 0, 0, 0, 157, 158, 5, 23, 0, 0, 158, 159, 3, 4, 2, 0, 159, 29, 1, + 0, 0, 0, 160, 161, 5, 1, 0, 0, 161, 166, 3, 40, 20, 0, 162, 163, 7, 0, + 0, 0, 163, 165, 3, 40, 20, 0, 164, 162, 1, 0, 0, 0, 165, 168, 1, 0, 0, + 0, 166, 164, 1, 0, 0, 0, 166, 167, 1, 0, 0, 0, 167, 169, 1, 0, 0, 0, 168, + 166, 1, 0, 0, 0, 169, 170, 5, 3, 0, 0, 170, 31, 1, 0, 0, 0, 171, 172, 5, + 17, 0, 0, 172, 176, 3, 30, 15, 0, 173, 175, 3, 42, 21, 0, 174, 173, 1, + 0, 0, 0, 175, 178, 1, 0, 0, 0, 176, 174, 1, 0, 0, 0, 176, 177, 1, 0, 0, + 0, 177, 33, 1, 0, 0, 0, 178, 176, 1, 0, 0, 0, 179, 180, 5, 18, 0, 0, 180, + 181, 3, 32, 16, 0, 181, 35, 1, 0, 0, 0, 182, 186, 5, 18, 0, 0, 183, 185, + 3, 42, 21, 0, 184, 183, 1, 0, 0, 0, 185, 188, 1, 0, 0, 0, 186, 184, 1, + 0, 0, 0, 186, 187, 1, 0, 0, 0, 187, 37, 1, 0, 0, 0, 188, 186, 1, 0, 0, + 0, 189, 193, 3, 32, 16, 0, 190, 192, 3, 34, 17, 0, 191, 190, 1, 0, 0, 0, + 192, 195, 1, 0, 0, 0, 193, 191, 1, 0, 0, 0, 193, 194, 1, 0, 0, 0, 194, + 197, 1, 0, 0, 0, 195, 193, 1, 0, 0, 0, 196, 198, 3, 36, 18, 0, 197, 196, + 1, 0, 0, 0, 197, 198, 1, 0, 0, 0, 198, 39, 1, 0, 0, 0, 199, 207, 3, 14, + 7, 0, 200, 207, 5, 20, 0, 0, 201, 207, 5, 21, 0, 0, 202, 207, 5, 22, 0, + 0, 203, 207, 5, 25, 0, 0, 204, 207, 3, 28, 14, 0, 205, 207, 5, 23, 0, 0, + 206, 199, 1, 0, 0, 0, 206, 200, 1, 0, 0, 0, 206, 201, 1, 0, 0, 0, 206, + 202, 1, 0, 0, 0, 206, 203, 1, 0, 0, 0, 206, 204, 1, 0, 0, 0, 206, 205, + 1, 0, 0, 0, 207, 212, 1, 0, 0, 0, 208, 209, 5, 24, 0, 0, 209, 211, 3, 40, + 20, 0, 210, 208, 1, 0, 0, 0, 211, 214, 1, 0, 0, 0, 212, 210, 1, 0, 0, 0, + 212, 213, 1, 0, 0, 0, 213, 41, 1, 0, 0, 0, 214, 212, 1, 0, 0, 0, 215, 226, + 5, 4, 0, 0, 216, 220, 3, 40, 20, 0, 217, 220, 3, 10, 5, 0, 218, 220, 3, + 12, 6, 0, 219, 216, 1, 0, 0, 0, 219, 217, 1, 0, 0, 0, 219, 218, 1, 0, 0, + 0, 220, 221, 1, 0, 0, 0, 221, 222, 5, 5, 0, 0, 222, 225, 1, 0, 0, 0, 223, + 225, 3, 38, 19, 0, 224, 219, 1, 0, 0, 0, 224, 223, 1, 0, 0, 0, 225, 228, + 1, 0, 0, 0, 226, 224, 1, 0, 0, 0, 226, 227, 1, 0, 0, 0, 227, 229, 1, 0, + 0, 0, 228, 226, 1, 0, 0, 0, 229, 230, 5, 6, 0, 0, 230, 43, 1, 0, 0, 0, + 231, 239, 3, 8, 4, 0, 232, 239, 3, 16, 8, 0, 233, 239, 3, 18, 9, 0, 234, + 239, 3, 20, 10, 0, 235, 239, 3, 22, 11, 0, 236, 239, 3, 24, 12, 0, 237, + 239, 3, 26, 13, 0, 238, 231, 1, 0, 0, 0, 238, 232, 1, 0, 0, 0, 238, 233, + 1, 0, 0, 0, 238, 234, 1, 0, 0, 0, 238, 235, 1, 0, 0, 0, 238, 236, 1, 0, + 0, 0, 238, 237, 1, 0, 0, 0, 239, 242, 1, 0, 0, 0, 240, 238, 1, 0, 0, 0, + 240, 241, 1, 0, 0, 0, 241, 45, 1, 0, 0, 0, 242, 240, 1, 0, 0, 0, 25, 52, + 56, 58, 68, 79, 83, 85, 106, 111, 115, 127, 132, 134, 166, 176, 186, 193, + 197, 206, 212, 219, 224, 226, 238, 240, } deserializer := antlr.NewATNDeserializer(nil) staticData.atn = deserializer.Deserialize(staticData.serializedATN) @@ -157,25 +193,33 @@ func NewWystParser(input antlr.TokenStream) *WystParser { // WystParser tokens. const ( - WystParserEOF = antlr.TokenEOF - WystParserT__0 = 1 - WystParserT__1 = 2 - WystParserT__2 = 3 - WystParserT__3 = 4 - WystParserT__4 = 5 - WystParserT__5 = 6 - WystParserT__6 = 7 - WystParserT__7 = 8 - WystParserT__8 = 9 - WystParserT__9 = 10 - WystParserT__10 = 11 - WystParserT__11 = 12 - WystParserWS = 13 - WystParserNUMBER = 14 - WystParserHEX = 15 - WystParserIDENTIFIER = 16 - WystParserMATH = 17 - WystParserSTRING = 18 + WystParserEOF = antlr.TokenEOF + WystParserT__0 = 1 + WystParserT__1 = 2 + WystParserT__2 = 3 + WystParserT__3 = 4 + WystParserT__4 = 5 + WystParserT__5 = 6 + WystParserT__6 = 7 + WystParserT__7 = 8 + WystParserT__8 = 9 + WystParserT__9 = 10 + WystParserT__10 = 11 + WystParserT__11 = 12 + WystParserT__12 = 13 + WystParserT__13 = 14 + WystParserT__14 = 15 + WystParserT__15 = 16 + WystParserT__16 = 17 + WystParserT__17 = 18 + WystParserWS = 19 + WystParserNUMBER = 20 + WystParserHEX = 21 + WystParserIDENTIFIER = 22 + WystParserGOIDENTIFIER = 23 + WystParserMATH = 24 + WystParserSTRING = 25 + WystParserMODULE_NAME = 26 ) // WystParser rules. @@ -192,9 +236,17 @@ const ( WystParserRULE_namespace = 9 WystParserRULE_import_statement = 10 WystParserRULE_use_statement = 11 - WystParserRULE_expr = 12 - WystParserRULE_code_block = 13 - WystParserRULE_top = 14 + WystParserRULE_go_import = 12 + WystParserRULE_map = 13 + WystParserRULE_go_call = 14 + WystParserRULE_if_expr = 15 + WystParserRULE_if_statement = 16 + WystParserRULE_elseif_statement = 17 + WystParserRULE_else_statement = 18 + WystParserRULE_if_tree = 19 + WystParserRULE_expr = 20 + WystParserRULE_code_block = 21 + WystParserRULE_top = 22 ) // IRound_defContext is an interface to support dynamic dispatch. @@ -314,14 +366,14 @@ func (p *WystParser) Round_def() (localctx IRound_defContext) { p.EnterOuterAlt(localctx, 1) { - p.SetState(30) + p.SetState(46) p.Match(WystParserT__0) if p.HasError() { // Recognition error - abort rule goto errorExit } } - p.SetState(42) + p.SetState(58) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -330,10 +382,10 @@ func (p *WystParser) Round_def() (localctx IRound_defContext) { if _la == WystParserIDENTIFIER { { - p.SetState(31) + p.SetState(47) p.Var_def() } - p.SetState(36) + p.SetState(52) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -345,7 +397,7 @@ func (p *WystParser) Round_def() (localctx IRound_defContext) { for _alt != 2 && _alt != antlr.ATNInvalidAltNumber { if _alt == 1 { { - p.SetState(32) + p.SetState(48) p.Match(WystParserT__1) if p.HasError() { // Recognition error - abort rule @@ -353,12 +405,12 @@ func (p *WystParser) Round_def() (localctx IRound_defContext) { } } { - p.SetState(33) + p.SetState(49) p.Var_def() } } - p.SetState(38) + p.SetState(54) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -368,7 +420,7 @@ func (p *WystParser) Round_def() (localctx IRound_defContext) { goto errorExit } } - p.SetState(40) + p.SetState(56) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -377,7 +429,7 @@ func (p *WystParser) Round_def() (localctx IRound_defContext) { if _la == WystParserT__1 { { - p.SetState(39) + p.SetState(55) p.Match(WystParserT__1) if p.HasError() { // Recognition error - abort rule @@ -389,7 +441,7 @@ func (p *WystParser) Round_def() (localctx IRound_defContext) { } { - p.SetState(44) + p.SetState(60) p.Match(WystParserT__2) if p.HasError() { // Recognition error - abort rule @@ -525,14 +577,14 @@ func (p *WystParser) Enum_curly() (localctx IEnum_curlyContext) { p.EnterOuterAlt(localctx, 1) { - p.SetState(46) + p.SetState(62) p.Match(WystParserT__3) if p.HasError() { // Recognition error - abort rule goto errorExit } } - p.SetState(52) + p.SetState(68) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -541,11 +593,11 @@ func (p *WystParser) Enum_curly() (localctx IEnum_curlyContext) { for _la == WystParserIDENTIFIER { { - p.SetState(47) + p.SetState(63) p.Var_def() } { - p.SetState(48) + p.SetState(64) p.Match(WystParserT__4) if p.HasError() { // Recognition error - abort rule @@ -553,7 +605,7 @@ func (p *WystParser) Enum_curly() (localctx IEnum_curlyContext) { } } - p.SetState(54) + p.SetState(70) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -561,7 +613,7 @@ func (p *WystParser) Enum_curly() (localctx IEnum_curlyContext) { _la = p.GetTokenStream().LA(1) } { - p.SetState(55) + p.SetState(71) p.Match(WystParserT__5) if p.HasError() { // Recognition error - abort rule @@ -699,26 +751,26 @@ func (p *WystParser) Round_call() (localctx IRound_callContext) { p.EnterOuterAlt(localctx, 1) { - p.SetState(57) + p.SetState(73) p.Match(WystParserT__0) if p.HasError() { // Recognition error - abort rule goto errorExit } } - p.SetState(69) + p.SetState(85) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } _la = p.GetTokenStream().LA(1) - if (int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&376832) != 0 { + if (int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&49283072) != 0 { { - p.SetState(58) + p.SetState(74) p.Expr() } - p.SetState(63) + p.SetState(79) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -730,7 +782,7 @@ func (p *WystParser) Round_call() (localctx IRound_callContext) { for _alt != 2 && _alt != antlr.ATNInvalidAltNumber { if _alt == 1 { { - p.SetState(59) + p.SetState(75) p.Match(WystParserT__1) if p.HasError() { // Recognition error - abort rule @@ -738,12 +790,12 @@ func (p *WystParser) Round_call() (localctx IRound_callContext) { } } { - p.SetState(60) + p.SetState(76) p.Expr() } } - p.SetState(65) + p.SetState(81) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -753,7 +805,7 @@ func (p *WystParser) Round_call() (localctx IRound_callContext) { goto errorExit } } - p.SetState(67) + p.SetState(83) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -762,7 +814,7 @@ func (p *WystParser) Round_call() (localctx IRound_callContext) { if _la == WystParserT__1 { { - p.SetState(66) + p.SetState(82) p.Match(WystParserT__1) if p.HasError() { // Recognition error - abort rule @@ -774,7 +826,7 @@ func (p *WystParser) Round_call() (localctx IRound_callContext) { } { - p.SetState(71) + p.SetState(87) p.Match(WystParserT__2) if p.HasError() { // Recognition error - abort rule @@ -887,7 +939,7 @@ func (p *WystParser) Fn_call() (localctx IFn_callContext) { p.EnterRule(localctx, 6, WystParserRULE_fn_call) p.EnterOuterAlt(localctx, 1) { - p.SetState(73) + p.SetState(89) p.Match(WystParserIDENTIFIER) if p.HasError() { // Recognition error - abort rule @@ -895,7 +947,7 @@ func (p *WystParser) Fn_call() (localctx IFn_callContext) { } } { - p.SetState(74) + p.SetState(90) p.Round_call() } @@ -1026,7 +1078,7 @@ func (p *WystParser) Func_def() (localctx IFunc_defContext) { p.EnterRule(localctx, 8, WystParserRULE_func_def) p.EnterOuterAlt(localctx, 1) { - p.SetState(76) + p.SetState(92) p.Match(WystParserIDENTIFIER) if p.HasError() { // Recognition error - abort rule @@ -1034,7 +1086,7 @@ func (p *WystParser) Func_def() (localctx IFunc_defContext) { } } { - p.SetState(77) + p.SetState(93) p.Match(WystParserIDENTIFIER) if p.HasError() { // Recognition error - abort rule @@ -1042,11 +1094,11 @@ func (p *WystParser) Func_def() (localctx IFunc_defContext) { } } { - p.SetState(78) + p.SetState(94) p.Round_def() } { - p.SetState(79) + p.SetState(95) p.Code_block() } @@ -1143,7 +1195,7 @@ func (p *WystParser) Var_def() (localctx IVar_defContext) { p.EnterRule(localctx, 10, WystParserRULE_var_def) p.EnterOuterAlt(localctx, 1) { - p.SetState(81) + p.SetState(97) p.Match(WystParserIDENTIFIER) if p.HasError() { // Recognition error - abort rule @@ -1151,7 +1203,7 @@ func (p *WystParser) Var_def() (localctx IVar_defContext) { } } { - p.SetState(82) + p.SetState(98) p.Match(WystParserIDENTIFIER) if p.HasError() { // Recognition error - abort rule @@ -1276,11 +1328,11 @@ func (p *WystParser) Var_def_set() (localctx IVar_def_setContext) { p.EnterRule(localctx, 12, WystParserRULE_var_def_set) p.EnterOuterAlt(localctx, 1) { - p.SetState(84) + p.SetState(100) p.Var_def() } { - p.SetState(85) + p.SetState(101) p.Match(WystParserT__6) if p.HasError() { // Recognition error - abort rule @@ -1288,7 +1340,7 @@ func (p *WystParser) Var_def_set() (localctx IVar_def_setContext) { } } { - p.SetState(86) + p.SetState(102) p.Expr() } @@ -1429,7 +1481,7 @@ func (p *WystParser) Call_tree() (localctx ICall_treeContext) { var _la int p.EnterOuterAlt(localctx, 1) - p.SetState(90) + p.SetState(106) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -1438,13 +1490,13 @@ func (p *WystParser) Call_tree() (localctx ICall_treeContext) { switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 7, p.GetParserRuleContext()) { case 1: { - p.SetState(88) + p.SetState(104) p.Fn_call() } case 2: { - p.SetState(89) + p.SetState(105) p.Match(WystParserIDENTIFIER) if p.HasError() { // Recognition error - abort rule @@ -1455,7 +1507,7 @@ func (p *WystParser) Call_tree() (localctx ICall_treeContext) { case antlr.ATNInvalidAltNumber: goto errorExit } - p.SetState(99) + p.SetState(115) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -1464,14 +1516,14 @@ func (p *WystParser) Call_tree() (localctx ICall_treeContext) { for _la == WystParserT__7 { { - p.SetState(92) + p.SetState(108) p.Match(WystParserT__7) if p.HasError() { // Recognition error - abort rule goto errorExit } } - p.SetState(95) + p.SetState(111) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -1480,13 +1532,13 @@ func (p *WystParser) Call_tree() (localctx ICall_treeContext) { switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 8, p.GetParserRuleContext()) { case 1: { - p.SetState(93) + p.SetState(109) p.Fn_call() } case 2: { - p.SetState(94) + p.SetState(110) p.Match(WystParserIDENTIFIER) if p.HasError() { // Recognition error - abort rule @@ -1498,7 +1550,7 @@ func (p *WystParser) Call_tree() (localctx ICall_treeContext) { goto errorExit } - p.SetState(101) + p.SetState(117) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -1611,7 +1663,7 @@ func (p *WystParser) Struct_def() (localctx IStruct_defContext) { p.EnterRule(localctx, 16, WystParserRULE_struct_def) p.EnterOuterAlt(localctx, 1) { - p.SetState(102) + p.SetState(118) p.Match(WystParserT__8) if p.HasError() { // Recognition error - abort rule @@ -1619,7 +1671,7 @@ func (p *WystParser) Struct_def() (localctx IStruct_defContext) { } } { - p.SetState(103) + p.SetState(119) p.Match(WystParserIDENTIFIER) if p.HasError() { // Recognition error - abort rule @@ -1627,7 +1679,7 @@ func (p *WystParser) Struct_def() (localctx IStruct_defContext) { } } { - p.SetState(104) + p.SetState(120) p.Enum_curly() } @@ -1850,7 +1902,7 @@ func (p *WystParser) Namespace() (localctx INamespaceContext) { p.EnterOuterAlt(localctx, 1) { - p.SetState(106) + p.SetState(122) p.Match(WystParserT__9) if p.HasError() { // Recognition error - abort rule @@ -1858,7 +1910,7 @@ func (p *WystParser) Namespace() (localctx INamespaceContext) { } } { - p.SetState(107) + p.SetState(123) p.Match(WystParserIDENTIFIER) if p.HasError() { // Recognition error - abort rule @@ -1866,14 +1918,14 @@ func (p *WystParser) Namespace() (localctx INamespaceContext) { } } { - p.SetState(108) + p.SetState(124) p.Match(WystParserT__3) if p.HasError() { // Recognition error - abort rule goto errorExit } } - p.SetState(118) + p.SetState(134) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -1881,7 +1933,7 @@ func (p *WystParser) Namespace() (localctx INamespaceContext) { _la = p.GetTokenStream().LA(1) for _la == WystParserIDENTIFIER { - p.SetState(116) + p.SetState(132) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -1889,7 +1941,7 @@ func (p *WystParser) Namespace() (localctx INamespaceContext) { switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 11, p.GetParserRuleContext()) { case 1: - p.SetState(111) + p.SetState(127) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -1898,13 +1950,13 @@ func (p *WystParser) Namespace() (localctx INamespaceContext) { switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 10, p.GetParserRuleContext()) { case 1: { - p.SetState(109) + p.SetState(125) p.Var_def() } case 2: { - p.SetState(110) + p.SetState(126) p.Var_def_set() } @@ -1912,7 +1964,7 @@ func (p *WystParser) Namespace() (localctx INamespaceContext) { goto errorExit } { - p.SetState(113) + p.SetState(129) p.Match(WystParserT__4) if p.HasError() { // Recognition error - abort rule @@ -1922,7 +1974,7 @@ func (p *WystParser) Namespace() (localctx INamespaceContext) { case 2: { - p.SetState(115) + p.SetState(131) p.Func_def() } @@ -1930,7 +1982,7 @@ func (p *WystParser) Namespace() (localctx INamespaceContext) { goto errorExit } - p.SetState(120) + p.SetState(136) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -1938,7 +1990,7 @@ func (p *WystParser) Namespace() (localctx INamespaceContext) { _la = p.GetTokenStream().LA(1) } { - p.SetState(121) + p.SetState(137) p.Match(WystParserT__5) if p.HasError() { // Recognition error - abort rule @@ -1967,7 +2019,7 @@ type IImport_statementContext interface { GetParser() antlr.Parser // Getter signatures - IDENTIFIER() antlr.TerminalNode + MODULE_NAME() antlr.TerminalNode // IsImport_statementContext differentiates from other interfaces. IsImport_statementContext() @@ -2005,8 +2057,8 @@ func NewImport_statementContext(parser antlr.Parser, parent antlr.ParserRuleCont func (s *Import_statementContext) GetParser() antlr.Parser { return s.parser } -func (s *Import_statementContext) IDENTIFIER() antlr.TerminalNode { - return s.GetToken(WystParserIDENTIFIER, 0) +func (s *Import_statementContext) MODULE_NAME() antlr.TerminalNode { + return s.GetToken(WystParserMODULE_NAME, 0) } func (s *Import_statementContext) GetRuleContext() antlr.RuleContext { @@ -2034,7 +2086,7 @@ func (p *WystParser) Import_statement() (localctx IImport_statementContext) { p.EnterRule(localctx, 20, WystParserRULE_import_statement) p.EnterOuterAlt(localctx, 1) { - p.SetState(123) + p.SetState(139) p.Match(WystParserT__10) if p.HasError() { // Recognition error - abort rule @@ -2042,15 +2094,15 @@ func (p *WystParser) Import_statement() (localctx IImport_statementContext) { } } { - p.SetState(124) - p.Match(WystParserIDENTIFIER) + p.SetState(140) + p.Match(WystParserMODULE_NAME) if p.HasError() { // Recognition error - abort rule goto errorExit } } { - p.SetState(125) + p.SetState(141) p.Match(WystParserT__4) if p.HasError() { // Recognition error - abort rule @@ -2146,7 +2198,7 @@ func (p *WystParser) Use_statement() (localctx IUse_statementContext) { p.EnterRule(localctx, 22, WystParserRULE_use_statement) p.EnterOuterAlt(localctx, 1) { - p.SetState(127) + p.SetState(143) p.Match(WystParserT__11) if p.HasError() { // Recognition error - abort rule @@ -2154,7 +2206,7 @@ func (p *WystParser) Use_statement() (localctx IUse_statementContext) { } } { - p.SetState(128) + p.SetState(144) p.Match(WystParserIDENTIFIER) if p.HasError() { // Recognition error - abort rule @@ -2162,7 +2214,7 @@ func (p *WystParser) Use_statement() (localctx IUse_statementContext) { } } { - p.SetState(129) + p.SetState(145) p.Match(WystParserT__4) if p.HasError() { // Recognition error - abort rule @@ -2183,6 +2235,1201 @@ errorExit: goto errorExit // Trick to prevent compiler error if the label is not used } +// IGo_importContext is an interface to support dynamic dispatch. +type IGo_importContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + + // Getter signatures + STRING() antlr.TerminalNode + + // IsGo_importContext differentiates from other interfaces. + IsGo_importContext() +} + +type Go_importContext struct { + antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyGo_importContext() *Go_importContext { + var p = new(Go_importContext) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = WystParserRULE_go_import + return p +} + +func InitEmptyGo_importContext(p *Go_importContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = WystParserRULE_go_import +} + +func (*Go_importContext) IsGo_importContext() {} + +func NewGo_importContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *Go_importContext { + var p = new(Go_importContext) + + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) + + p.parser = parser + p.RuleIndex = WystParserRULE_go_import + + return p +} + +func (s *Go_importContext) GetParser() antlr.Parser { return s.parser } + +func (s *Go_importContext) STRING() antlr.TerminalNode { + return s.GetToken(WystParserSTRING, 0) +} + +func (s *Go_importContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *Go_importContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +func (s *Go_importContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(WystListener); ok { + listenerT.EnterGo_import(s) + } +} + +func (s *Go_importContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(WystListener); ok { + listenerT.ExitGo_import(s) + } +} + +func (p *WystParser) Go_import() (localctx IGo_importContext) { + localctx = NewGo_importContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 24, WystParserRULE_go_import) + p.EnterOuterAlt(localctx, 1) + { + p.SetState(147) + p.Match(WystParserT__12) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + { + p.SetState(148) + p.Match(WystParserSTRING) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + { + p.SetState(149) + 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 +} + +// IMapContext is an interface to support dynamic dispatch. +type IMapContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + + // Getter signatures + AllIDENTIFIER() []antlr.TerminalNode + IDENTIFIER(i int) antlr.TerminalNode + + // IsMapContext differentiates from other interfaces. + IsMapContext() +} + +type MapContext struct { + antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyMapContext() *MapContext { + var p = new(MapContext) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = WystParserRULE_map + return p +} + +func InitEmptyMapContext(p *MapContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = WystParserRULE_map +} + +func (*MapContext) IsMapContext() {} + +func NewMapContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *MapContext { + var p = new(MapContext) + + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) + + p.parser = parser + p.RuleIndex = WystParserRULE_map + + return p +} + +func (s *MapContext) GetParser() antlr.Parser { return s.parser } + +func (s *MapContext) AllIDENTIFIER() []antlr.TerminalNode { + return s.GetTokens(WystParserIDENTIFIER) +} + +func (s *MapContext) IDENTIFIER(i int) antlr.TerminalNode { + return s.GetToken(WystParserIDENTIFIER, i) +} + +func (s *MapContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *MapContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +func (s *MapContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(WystListener); ok { + listenerT.EnterMap(s) + } +} + +func (s *MapContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(WystListener); ok { + listenerT.ExitMap(s) + } +} + +func (p *WystParser) Map_() (localctx IMapContext) { + localctx = NewMapContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 26, WystParserRULE_map) + p.EnterOuterAlt(localctx, 1) + { + p.SetState(151) + p.Match(WystParserT__13) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + { + p.SetState(152) + p.Match(WystParserIDENTIFIER) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + { + p.SetState(153) + p.Match(WystParserT__1) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + { + p.SetState(154) + p.Match(WystParserIDENTIFIER) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + { + p.SetState(155) + 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 +} + +// IGo_callContext is an interface to support dynamic dispatch. +type IGo_callContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + + // Getter signatures + GOIDENTIFIER() antlr.TerminalNode + Round_call() IRound_callContext + + // IsGo_callContext differentiates from other interfaces. + IsGo_callContext() +} + +type Go_callContext struct { + antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyGo_callContext() *Go_callContext { + var p = new(Go_callContext) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = WystParserRULE_go_call + return p +} + +func InitEmptyGo_callContext(p *Go_callContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = WystParserRULE_go_call +} + +func (*Go_callContext) IsGo_callContext() {} + +func NewGo_callContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *Go_callContext { + var p = new(Go_callContext) + + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) + + p.parser = parser + p.RuleIndex = WystParserRULE_go_call + + return p +} + +func (s *Go_callContext) GetParser() antlr.Parser { return s.parser } + +func (s *Go_callContext) GOIDENTIFIER() antlr.TerminalNode { + return s.GetToken(WystParserGOIDENTIFIER, 0) +} + +func (s *Go_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 *Go_callContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *Go_callContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +func (s *Go_callContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(WystListener); ok { + listenerT.EnterGo_call(s) + } +} + +func (s *Go_callContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(WystListener); ok { + listenerT.ExitGo_call(s) + } +} + +func (p *WystParser) Go_call() (localctx IGo_callContext) { + localctx = NewGo_callContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 28, WystParserRULE_go_call) + p.EnterOuterAlt(localctx, 1) + { + p.SetState(157) + p.Match(WystParserGOIDENTIFIER) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + { + p.SetState(158) + 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 +} + +// IIf_exprContext is an interface to support dynamic dispatch. +type IIf_exprContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + + // Getter signatures + AllExpr() []IExprContext + Expr(i int) IExprContext + + // IsIf_exprContext differentiates from other interfaces. + IsIf_exprContext() +} + +type If_exprContext struct { + antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyIf_exprContext() *If_exprContext { + var p = new(If_exprContext) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = WystParserRULE_if_expr + return p +} + +func InitEmptyIf_exprContext(p *If_exprContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = WystParserRULE_if_expr +} + +func (*If_exprContext) IsIf_exprContext() {} + +func NewIf_exprContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *If_exprContext { + var p = new(If_exprContext) + + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) + + p.parser = parser + p.RuleIndex = WystParserRULE_if_expr + + return p +} + +func (s *If_exprContext) GetParser() antlr.Parser { return s.parser } + +func (s *If_exprContext) 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 *If_exprContext) 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 *If_exprContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *If_exprContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +func (s *If_exprContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(WystListener); ok { + listenerT.EnterIf_expr(s) + } +} + +func (s *If_exprContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(WystListener); ok { + listenerT.ExitIf_expr(s) + } +} + +func (p *WystParser) If_expr() (localctx IIf_exprContext) { + localctx = NewIf_exprContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 30, WystParserRULE_if_expr) + var _la int + + p.EnterOuterAlt(localctx, 1) + { + p.SetState(160) + p.Match(WystParserT__0) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + { + p.SetState(161) + p.Expr() + } + p.SetState(166) + p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } + _la = p.GetTokenStream().LA(1) + + for _la == WystParserT__14 || _la == WystParserT__15 { + { + p.SetState(162) + _la = p.GetTokenStream().LA(1) + + if !(_la == WystParserT__14 || _la == WystParserT__15) { + p.GetErrorHandler().RecoverInline(p) + } else { + p.GetErrorHandler().ReportMatch(p) + p.Consume() + } + } + { + p.SetState(163) + p.Expr() + } + + p.SetState(168) + p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(169) + 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 +} + +// IIf_statementContext is an interface to support dynamic dispatch. +type IIf_statementContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + + // Getter signatures + If_expr() IIf_exprContext + AllCode_block() []ICode_blockContext + Code_block(i int) ICode_blockContext + + // IsIf_statementContext differentiates from other interfaces. + IsIf_statementContext() +} + +type If_statementContext struct { + antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyIf_statementContext() *If_statementContext { + var p = new(If_statementContext) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = WystParserRULE_if_statement + return p +} + +func InitEmptyIf_statementContext(p *If_statementContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = WystParserRULE_if_statement +} + +func (*If_statementContext) IsIf_statementContext() {} + +func NewIf_statementContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *If_statementContext { + var p = new(If_statementContext) + + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) + + p.parser = parser + p.RuleIndex = WystParserRULE_if_statement + + return p +} + +func (s *If_statementContext) GetParser() antlr.Parser { return s.parser } + +func (s *If_statementContext) If_expr() IIf_exprContext { + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IIf_exprContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } + + if t == nil { + return nil + } + + return t.(IIf_exprContext) +} + +func (s *If_statementContext) AllCode_block() []ICode_blockContext { + children := s.GetChildren() + len := 0 + for _, ctx := range children { + if _, ok := ctx.(ICode_blockContext); ok { + len++ + } + } + + tst := make([]ICode_blockContext, len) + i := 0 + for _, ctx := range children { + if t, ok := ctx.(ICode_blockContext); ok { + tst[i] = t.(ICode_blockContext) + i++ + } + } + + return tst +} + +func (s *If_statementContext) Code_block(i int) ICode_blockContext { + var t antlr.RuleContext + j := 0 + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(ICode_blockContext); ok { + if j == i { + t = ctx.(antlr.RuleContext) + break + } + j++ + } + } + + if t == nil { + return nil + } + + return t.(ICode_blockContext) +} + +func (s *If_statementContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *If_statementContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +func (s *If_statementContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(WystListener); ok { + listenerT.EnterIf_statement(s) + } +} + +func (s *If_statementContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(WystListener); ok { + listenerT.ExitIf_statement(s) + } +} + +func (p *WystParser) If_statement() (localctx IIf_statementContext) { + localctx = NewIf_statementContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 32, WystParserRULE_if_statement) + var _la int + + p.EnterOuterAlt(localctx, 1) + { + p.SetState(171) + p.Match(WystParserT__16) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + { + p.SetState(172) + p.If_expr() + } + p.SetState(176) + p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } + _la = p.GetTokenStream().LA(1) + + for _la == WystParserT__3 { + { + p.SetState(173) + p.Code_block() + } + + p.SetState(178) + 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 +} + +// IElseif_statementContext is an interface to support dynamic dispatch. +type IElseif_statementContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + + // Getter signatures + If_statement() IIf_statementContext + + // IsElseif_statementContext differentiates from other interfaces. + IsElseif_statementContext() +} + +type Elseif_statementContext struct { + antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyElseif_statementContext() *Elseif_statementContext { + var p = new(Elseif_statementContext) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = WystParserRULE_elseif_statement + return p +} + +func InitEmptyElseif_statementContext(p *Elseif_statementContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = WystParserRULE_elseif_statement +} + +func (*Elseif_statementContext) IsElseif_statementContext() {} + +func NewElseif_statementContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *Elseif_statementContext { + var p = new(Elseif_statementContext) + + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) + + p.parser = parser + p.RuleIndex = WystParserRULE_elseif_statement + + return p +} + +func (s *Elseif_statementContext) GetParser() antlr.Parser { return s.parser } + +func (s *Elseif_statementContext) If_statement() IIf_statementContext { + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IIf_statementContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } + + if t == nil { + return nil + } + + return t.(IIf_statementContext) +} + +func (s *Elseif_statementContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *Elseif_statementContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +func (s *Elseif_statementContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(WystListener); ok { + listenerT.EnterElseif_statement(s) + } +} + +func (s *Elseif_statementContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(WystListener); ok { + listenerT.ExitElseif_statement(s) + } +} + +func (p *WystParser) Elseif_statement() (localctx IElseif_statementContext) { + localctx = NewElseif_statementContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 34, WystParserRULE_elseif_statement) + p.EnterOuterAlt(localctx, 1) + { + p.SetState(179) + p.Match(WystParserT__17) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + { + p.SetState(180) + p.If_statement() + } + +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 +} + +// IElse_statementContext is an interface to support dynamic dispatch. +type IElse_statementContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + + // Getter signatures + AllCode_block() []ICode_blockContext + Code_block(i int) ICode_blockContext + + // IsElse_statementContext differentiates from other interfaces. + IsElse_statementContext() +} + +type Else_statementContext struct { + antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyElse_statementContext() *Else_statementContext { + var p = new(Else_statementContext) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = WystParserRULE_else_statement + return p +} + +func InitEmptyElse_statementContext(p *Else_statementContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = WystParserRULE_else_statement +} + +func (*Else_statementContext) IsElse_statementContext() {} + +func NewElse_statementContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *Else_statementContext { + var p = new(Else_statementContext) + + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) + + p.parser = parser + p.RuleIndex = WystParserRULE_else_statement + + return p +} + +func (s *Else_statementContext) GetParser() antlr.Parser { return s.parser } + +func (s *Else_statementContext) AllCode_block() []ICode_blockContext { + children := s.GetChildren() + len := 0 + for _, ctx := range children { + if _, ok := ctx.(ICode_blockContext); ok { + len++ + } + } + + tst := make([]ICode_blockContext, len) + i := 0 + for _, ctx := range children { + if t, ok := ctx.(ICode_blockContext); ok { + tst[i] = t.(ICode_blockContext) + i++ + } + } + + return tst +} + +func (s *Else_statementContext) Code_block(i int) ICode_blockContext { + var t antlr.RuleContext + j := 0 + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(ICode_blockContext); ok { + if j == i { + t = ctx.(antlr.RuleContext) + break + } + j++ + } + } + + if t == nil { + return nil + } + + return t.(ICode_blockContext) +} + +func (s *Else_statementContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *Else_statementContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +func (s *Else_statementContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(WystListener); ok { + listenerT.EnterElse_statement(s) + } +} + +func (s *Else_statementContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(WystListener); ok { + listenerT.ExitElse_statement(s) + } +} + +func (p *WystParser) Else_statement() (localctx IElse_statementContext) { + localctx = NewElse_statementContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 36, WystParserRULE_else_statement) + var _la int + + p.EnterOuterAlt(localctx, 1) + { + p.SetState(182) + p.Match(WystParserT__17) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + p.SetState(186) + p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } + _la = p.GetTokenStream().LA(1) + + for _la == WystParserT__3 { + { + p.SetState(183) + p.Code_block() + } + + p.SetState(188) + 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 +} + +// IIf_treeContext is an interface to support dynamic dispatch. +type IIf_treeContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + + // Getter signatures + If_statement() IIf_statementContext + AllElseif_statement() []IElseif_statementContext + Elseif_statement(i int) IElseif_statementContext + Else_statement() IElse_statementContext + + // IsIf_treeContext differentiates from other interfaces. + IsIf_treeContext() +} + +type If_treeContext struct { + antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyIf_treeContext() *If_treeContext { + var p = new(If_treeContext) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = WystParserRULE_if_tree + return p +} + +func InitEmptyIf_treeContext(p *If_treeContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = WystParserRULE_if_tree +} + +func (*If_treeContext) IsIf_treeContext() {} + +func NewIf_treeContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *If_treeContext { + var p = new(If_treeContext) + + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) + + p.parser = parser + p.RuleIndex = WystParserRULE_if_tree + + return p +} + +func (s *If_treeContext) GetParser() antlr.Parser { return s.parser } + +func (s *If_treeContext) If_statement() IIf_statementContext { + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IIf_statementContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } + + if t == nil { + return nil + } + + return t.(IIf_statementContext) +} + +func (s *If_treeContext) AllElseif_statement() []IElseif_statementContext { + children := s.GetChildren() + len := 0 + for _, ctx := range children { + if _, ok := ctx.(IElseif_statementContext); ok { + len++ + } + } + + tst := make([]IElseif_statementContext, len) + i := 0 + for _, ctx := range children { + if t, ok := ctx.(IElseif_statementContext); ok { + tst[i] = t.(IElseif_statementContext) + i++ + } + } + + return tst +} + +func (s *If_treeContext) Elseif_statement(i int) IElseif_statementContext { + var t antlr.RuleContext + j := 0 + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IElseif_statementContext); ok { + if j == i { + t = ctx.(antlr.RuleContext) + break + } + j++ + } + } + + if t == nil { + return nil + } + + return t.(IElseif_statementContext) +} + +func (s *If_treeContext) Else_statement() IElse_statementContext { + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IElse_statementContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } + + if t == nil { + return nil + } + + return t.(IElse_statementContext) +} + +func (s *If_treeContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *If_treeContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +func (s *If_treeContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(WystListener); ok { + listenerT.EnterIf_tree(s) + } +} + +func (s *If_treeContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(WystListener); ok { + listenerT.ExitIf_tree(s) + } +} + +func (p *WystParser) If_tree() (localctx IIf_treeContext) { + localctx = NewIf_treeContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 38, WystParserRULE_if_tree) + var _la int + + var _alt int + + p.EnterOuterAlt(localctx, 1) + { + p.SetState(189) + p.If_statement() + } + p.SetState(193) + p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } + _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 16, p.GetParserRuleContext()) + if p.HasError() { + goto errorExit + } + for _alt != 2 && _alt != antlr.ATNInvalidAltNumber { + if _alt == 1 { + { + p.SetState(190) + p.Elseif_statement() + } + + } + p.SetState(195) + p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } + _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 16, p.GetParserRuleContext()) + if p.HasError() { + goto errorExit + } + } + p.SetState(197) + p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } + _la = p.GetTokenStream().LA(1) + + if _la == WystParserT__17 { + { + p.SetState(196) + p.Else_statement() + } + + } + +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 +} + // IExprContext is an interface to support dynamic dispatch. type IExprContext interface { antlr.ParserRuleContext @@ -2196,6 +3443,8 @@ type IExprContext interface { HEX() antlr.TerminalNode IDENTIFIER() antlr.TerminalNode STRING() antlr.TerminalNode + Go_call() IGo_callContext + GOIDENTIFIER() antlr.TerminalNode AllMATH() []antlr.TerminalNode MATH(i int) antlr.TerminalNode AllExpr() []IExprContext @@ -2269,6 +3518,26 @@ func (s *ExprContext) STRING() antlr.TerminalNode { return s.GetToken(WystParserSTRING, 0) } +func (s *ExprContext) Go_call() IGo_callContext { + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IGo_callContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } + + if t == nil { + return nil + } + + return t.(IGo_callContext) +} + +func (s *ExprContext) GOIDENTIFIER() antlr.TerminalNode { + return s.GetToken(WystParserGOIDENTIFIER, 0) +} + func (s *ExprContext) AllMATH() []antlr.TerminalNode { return s.GetTokens(WystParserMATH) } @@ -2340,26 +3609,26 @@ func (s *ExprContext) ExitRule(listener antlr.ParseTreeListener) { func (p *WystParser) Expr() (localctx IExprContext) { localctx = NewExprContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 24, WystParserRULE_expr) + p.EnterRule(localctx, 40, WystParserRULE_expr) var _alt int p.EnterOuterAlt(localctx, 1) - p.SetState(136) + p.SetState(206) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } - switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 13, p.GetParserRuleContext()) { + switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 18, p.GetParserRuleContext()) { case 1: { - p.SetState(131) + p.SetState(199) p.Call_tree() } case 2: { - p.SetState(132) + p.SetState(200) p.Match(WystParserNUMBER) if p.HasError() { // Recognition error - abort rule @@ -2369,7 +3638,7 @@ func (p *WystParser) Expr() (localctx IExprContext) { case 3: { - p.SetState(133) + p.SetState(201) p.Match(WystParserHEX) if p.HasError() { // Recognition error - abort rule @@ -2379,7 +3648,7 @@ func (p *WystParser) Expr() (localctx IExprContext) { case 4: { - p.SetState(134) + p.SetState(202) p.Match(WystParserIDENTIFIER) if p.HasError() { // Recognition error - abort rule @@ -2389,7 +3658,7 @@ func (p *WystParser) Expr() (localctx IExprContext) { case 5: { - p.SetState(135) + p.SetState(203) p.Match(WystParserSTRING) if p.HasError() { // Recognition error - abort rule @@ -2397,22 +3666,38 @@ func (p *WystParser) Expr() (localctx IExprContext) { } } + case 6: + { + p.SetState(204) + p.Go_call() + } + + case 7: + { + p.SetState(205) + p.Match(WystParserGOIDENTIFIER) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + case antlr.ATNInvalidAltNumber: goto errorExit } - p.SetState(142) + p.SetState(212) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } - _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 14, p.GetParserRuleContext()) + _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 19, p.GetParserRuleContext()) if p.HasError() { goto errorExit } for _alt != 2 && _alt != antlr.ATNInvalidAltNumber { if _alt == 1 { { - p.SetState(138) + p.SetState(208) p.Match(WystParserMATH) if p.HasError() { // Recognition error - abort rule @@ -2420,17 +3705,17 @@ func (p *WystParser) Expr() (localctx IExprContext) { } } { - p.SetState(139) + p.SetState(209) p.Expr() } } - p.SetState(144) + p.SetState(214) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } - _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 14, p.GetParserRuleContext()) + _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 19, p.GetParserRuleContext()) if p.HasError() { goto errorExit } @@ -2457,6 +3742,8 @@ type ICode_blockContext interface { GetParser() antlr.Parser // Getter signatures + AllIf_tree() []IIf_treeContext + If_tree(i int) IIf_treeContext AllExpr() []IExprContext Expr(i int) IExprContext AllVar_def() []IVar_defContext @@ -2500,6 +3787,47 @@ func NewCode_blockContext(parser antlr.Parser, parent antlr.ParserRuleContext, i func (s *Code_blockContext) GetParser() antlr.Parser { return s.parser } +func (s *Code_blockContext) AllIf_tree() []IIf_treeContext { + children := s.GetChildren() + len := 0 + for _, ctx := range children { + if _, ok := ctx.(IIf_treeContext); ok { + len++ + } + } + + tst := make([]IIf_treeContext, len) + i := 0 + for _, ctx := range children { + if t, ok := ctx.(IIf_treeContext); ok { + tst[i] = t.(IIf_treeContext) + i++ + } + } + + return tst +} + +func (s *Code_blockContext) If_tree(i int) IIf_treeContext { + var t antlr.RuleContext + j := 0 + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IIf_treeContext); ok { + if j == i { + t = ctx.(antlr.RuleContext) + break + } + j++ + } + } + + if t == nil { + return nil + } + + return t.(IIf_treeContext) +} + func (s *Code_blockContext) AllExpr() []IExprContext { children := s.GetChildren() len := 0 @@ -2645,64 +3973,83 @@ 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, 26, WystParserRULE_code_block) + p.EnterRule(localctx, 42, WystParserRULE_code_block) var _la int p.EnterOuterAlt(localctx, 1) { - p.SetState(145) + p.SetState(215) p.Match(WystParserT__3) if p.HasError() { // Recognition error - abort rule goto errorExit } } - p.SetState(155) + p.SetState(226) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } _la = p.GetTokenStream().LA(1) - for (int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&376832) != 0 { - p.SetState(149) + for (int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&49414144) != 0 { + p.SetState(224) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } - switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 15, p.GetParserRuleContext()) { - case 1: - { - p.SetState(146) - p.Expr() - } - - case 2: - { - p.SetState(147) - p.Var_def() - } - - case 3: - { - p.SetState(148) - p.Var_def_set() - } - - case antlr.ATNInvalidAltNumber: - goto errorExit - } - { - p.SetState(151) - p.Match(WystParserT__4) + switch p.GetTokenStream().LA(1) { + case WystParserNUMBER, WystParserHEX, WystParserIDENTIFIER, WystParserGOIDENTIFIER, WystParserSTRING: + p.SetState(219) + p.GetErrorHandler().Sync(p) if p.HasError() { - // Recognition error - abort rule goto errorExit } + + switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 20, p.GetParserRuleContext()) { + case 1: + { + p.SetState(216) + p.Expr() + } + + case 2: + { + p.SetState(217) + p.Var_def() + } + + case 3: + { + p.SetState(218) + p.Var_def_set() + } + + case antlr.ATNInvalidAltNumber: + goto errorExit + } + { + p.SetState(221) + p.Match(WystParserT__4) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + + case WystParserT__16: + { + p.SetState(223) + p.If_tree() + } + + default: + p.SetError(antlr.NewNoViableAltException(p, nil, nil, nil, nil, nil)) + goto errorExit } - p.SetState(157) + p.SetState(228) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -2710,7 +4057,7 @@ func (p *WystParser) Code_block() (localctx ICode_blockContext) { _la = p.GetTokenStream().LA(1) } { - p.SetState(158) + p.SetState(229) p.Match(WystParserT__5) if p.HasError() { // Recognition error - abort rule @@ -2749,6 +4096,10 @@ type ITopContext interface { Import_statement(i int) IImport_statementContext AllUse_statement() []IUse_statementContext Use_statement(i int) IUse_statementContext + AllGo_import() []IGo_importContext + Go_import(i int) IGo_importContext + AllMap_() []IMapContext + Map_(i int) IMapContext // IsTopContext differentiates from other interfaces. IsTopContext() @@ -2991,6 +4342,88 @@ func (s *TopContext) Use_statement(i int) IUse_statementContext { return t.(IUse_statementContext) } +func (s *TopContext) AllGo_import() []IGo_importContext { + children := s.GetChildren() + len := 0 + for _, ctx := range children { + if _, ok := ctx.(IGo_importContext); ok { + len++ + } + } + + tst := make([]IGo_importContext, len) + i := 0 + for _, ctx := range children { + if t, ok := ctx.(IGo_importContext); ok { + tst[i] = t.(IGo_importContext) + i++ + } + } + + return tst +} + +func (s *TopContext) Go_import(i int) IGo_importContext { + var t antlr.RuleContext + j := 0 + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IGo_importContext); ok { + if j == i { + t = ctx.(antlr.RuleContext) + break + } + j++ + } + } + + if t == nil { + return nil + } + + return t.(IGo_importContext) +} + +func (s *TopContext) AllMap_() []IMapContext { + children := s.GetChildren() + len := 0 + for _, ctx := range children { + if _, ok := ctx.(IMapContext); ok { + len++ + } + } + + tst := make([]IMapContext, len) + i := 0 + for _, ctx := range children { + if t, ok := ctx.(IMapContext); ok { + tst[i] = t.(IMapContext) + i++ + } + } + + return tst +} + +func (s *TopContext) Map_(i int) IMapContext { + var t antlr.RuleContext + j := 0 + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IMapContext); ok { + if j == i { + t = ctx.(antlr.RuleContext) + break + } + j++ + } + } + + if t == nil { + return nil + } + + return t.(IMapContext) +} + func (s *TopContext) GetRuleContext() antlr.RuleContext { return s } @@ -3013,19 +4446,19 @@ func (s *TopContext) ExitRule(listener antlr.ParseTreeListener) { func (p *WystParser) Top() (localctx ITopContext) { localctx = NewTopContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 28, WystParserRULE_top) + p.EnterRule(localctx, 44, WystParserRULE_top) var _la int p.EnterOuterAlt(localctx, 1) - p.SetState(167) + p.SetState(240) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } _la = p.GetTokenStream().LA(1) - for (int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&73216) != 0 { - p.SetState(165) + for (int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&4226560) != 0 { + p.SetState(238) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -3034,40 +4467,52 @@ func (p *WystParser) Top() (localctx ITopContext) { switch p.GetTokenStream().LA(1) { case WystParserIDENTIFIER: { - p.SetState(160) + p.SetState(231) p.Func_def() } case WystParserT__8: { - p.SetState(161) + p.SetState(232) p.Struct_def() } case WystParserT__9: { - p.SetState(162) + p.SetState(233) p.Namespace() } case WystParserT__10: { - p.SetState(163) + p.SetState(234) p.Import_statement() } case WystParserT__11: { - p.SetState(164) + p.SetState(235) p.Use_statement() } + case WystParserT__12: + { + p.SetState(236) + p.Go_import() + } + + case WystParserT__13: + { + p.SetState(237) + p.Map_() + } + default: p.SetError(antlr.NewNoViableAltException(p, nil, nil, nil, nil, nil)) goto errorExit } - p.SetState(169) + p.SetState(242) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit diff --git a/src/transpiler.go b/src/transpiler.go index b520762..e1cfffd 100644 --- a/src/transpiler.go +++ b/src/transpiler.go @@ -7,7 +7,7 @@ import ( type wmap [2]string -var wyst_map []wmap = []wmap{{"int", "int"}, {"void", "void"}, {"main", "main"}} +var wyst_map []wmap = []wmap{{"int", "int"}, {"void", "void"}, {"main", "main"}, {"string", "string"}, {"true", "true"}, {"false", "false"}} func TranspileToken(node ASTNode) string { res := "" @@ -42,6 +42,8 @@ func TranspileToken(node ASTNode) string { res += ", " case "IDENT": res += fmt.Sprintf("_%#x", node.Text) + case "GOIDENTIFIER": + res += strings.TrimPrefix(node.Text, "^") default: fmt.Printf("\x1b[33mDEV NOTICE:\x1b[0m Missing token case for '%s'\n", node.Rule) @@ -83,9 +85,6 @@ func (m *Module) TranspileNode(node ASTNode) string { res += m.TranspileNode(node.Inner[0]) res += m.TranspileNode(node.Inner[1]) - case "round_call": - res += fmt.Sprintf("(%s)", m.TranspileNodes(node.Inner)) - case "struct_def": res += fmt.Sprintf("type %s struct %s\n", m.TranspileNode(node.Inner[0]), m.TranspileNode(node.Inner[1])) @@ -126,14 +125,45 @@ func (m *Module) TranspileNode(node ASTNode) string { res += fmt.Sprintf("import . \"%s\"\n", m.ImportModule(node.Inner[0].Text)) case "use_statement": - ident := strings.Split(node.Inner[0].Text, ".") + ident := strings.Split(node.Inner[0].Text, "::") + ident2 := strings.Split(m.TranspileNode(node.Inner[0]), ".") modname := m.ImportModule(ident[0]) - m := strings.Split(modname, "/") - res += fmt.Sprintf("import %s \"%s\"\n", m[len(m)-1], modname) + md := strings.Split(modname, "/") + res += fmt.Sprintf("import %s \"%s\"\n", md[len(md)-1], modname) if len(ident) > 1 { - res += fmt.Sprintf("var %s = %s\n", ident[len(ident)-1], strings.Join(ident, ".")) + res += fmt.Sprintf("var %s = %s\n", ident2[len(ident2)-1], m.TranspileNode(node.Inner[0])) } + case "go_import": + res += "import " + m.TranspileNode(node.Inner[0]) + "\n" + + case "map": + wyst_map = append(wyst_map, wmap{node.Inner[0].Text, node.Inner[2].Text}) + + case "go_call": + res += m.TranspileNode(node.Inner[0]) + res += m.TranspileNode(node.Inner[1]) + + case "round_call": + res += "(" + m.TranspileNodes(node.Inner) + ")" + + case "if_tree": + res += m.TranspileNodes(node.Inner) + + case "if_statement": + res += "if " + m.TranspileNodes(node.Inner) + + case "if_expr": + res += m.TranspileNodes(node.Inner) + + case "else_statement": + res += "else " + res += m.TranspileNodes(node.Inner) + + case "elseif_statement": + res += "else " + res += m.TranspileNodes(node.Inner) + default: fmt.Printf("\x1b[33mDEV NOTICE:\x1b[0m Missing case for '%s'\n", node.Rule) diff --git a/src/utils.go b/src/utils.go index 7a2e285..a70e706 100644 --- a/src/utils.go +++ b/src/utils.go @@ -4,8 +4,11 @@ import ( "fmt" "os" "path" + "strings" ) +const OUT_FOLDER = "build/" + func FileExists(filename string) bool { _, err := os.Stat(filename) return err == nil || !os.IsNotExist(err) @@ -43,7 +46,7 @@ func NewRoot(file_path string) Module { root := Module{} root.Path = file_path - root.Out = "out/main.go" + root.Out = OUT_FOLDER+"main.go" root.Name = "root" root.Code = root.Transpile(readFile(file_path)) @@ -53,16 +56,15 @@ func NewRoot(file_path string) Module { func (root *Module) ImportModule(modname string) string { module := Module{Name: modname} module.Path = path.Join(path.Dir(root.Path), module.Name+".wyst") - if FileExists(module.Path) { - module.Code = "package " + fmt.Sprintf("_%#x", modname) + "\n" + module.Transpile(readFile(module.Path)) - } else { + if !FileExists(module.Path) { module.Path = path.Join(path.Dir(root.Path), module.Name, "mod.wyst") - if FileExists(module.Path) { - module.Code = "package " + fmt.Sprintf("_%#x", modname) + "\n" + module.Transpile(readFile(module.Path)) - } } - module.Out = fmt.Sprintf("%s/I%#x/%s.go", path.Dir(root.Out), module.Name, module.Name) - root.Inner = append(root.Inner, module) + + if FileExists(module.Path) { + module.Out = fmt.Sprintf("%s/I%#x/%s.go", path.Dir(root.Out), module.Name, module.Name) + module.Code = "package " + fmt.Sprintf("_%#x", modname) + "\n" + module.Transpile(readFile(module.Path)) + root.Inner = append(root.Inner, module) + } return fmt.Sprintf("%s/I%#x", path.Dir(root.Out), module.Name) } @@ -74,7 +76,7 @@ func WriteModules(root Module) { } func WriteRoot(root Module) { - writeFile("out/main.go", "package main\n"+root.Code) - writeFile("out/go.mod", "module out\n") + writeFile(OUT_FOLDER+"main.go", "package main\n"+root.Code) + writeFile(OUT_FOLDER+"go.mod", "module "+strings.ReplaceAll(OUT_FOLDER, "/", "")+"\n") WriteModules(root) }