diff --git a/Wyst.g4 b/Wyst.g4 index 5b58256..acacff7 100644 --- a/Wyst.g4 +++ b/Wyst.g4 @@ -3,7 +3,7 @@ grammar Wyst; WS: [ \t\r\n]+ -> skip; NUMBER: [1-9][0-9]* | '0'; HEX: '0x' [a-fA-F0-9]*; -IDENTIFIER: [a-zA-Z_] ([a-zA-Z0-9_] | '::')*; +IDENTIFIER: [a-zA-Z_] [a-zA-Z0-9_]* ('::' [a-zA-Z_] [a-zA-Z0-9_]*)*; MATH: '+' | '-' | '*' | '/'; fragment ESC: '\\' ['"\\] ; STRING: '"' (ESC | ~["\\])* '"'; @@ -16,9 +16,9 @@ var_def: IDENTIFIER IDENTIFIER; var_def_set: var_def '=' expr; call_tree: (fn_call|IDENTIFIER) ('.' (fn_call|IDENTIFIER))*; struct_def: 'struct' IDENTIFIER enum_curly; -power_keyword: 'map'; -power_keyword_call: '#' power_keyword expr (',' expr)* ';'; namespace: 'namespace' IDENTIFIER '{' (((var_def|var_def_set) ';')|func_def)* '}'; +import_statement: 'include' IDENTIFIER ';'; +use_statement: 'use' IDENTIFIER ';'; expr: ( @@ -34,9 +34,11 @@ code_block: '{' (( var_def | var_def_set ) ';')* '}'; + top: ( - power_keyword_call | func_def | struct_def | - namespace + namespace | + import_statement | + use_statement )*; \ No newline at end of file diff --git a/parser/Wyst.interp b/parser/Wyst.interp index 413b691..a091a7f 100644 --- a/parser/Wyst.interp +++ b/parser/Wyst.interp @@ -9,9 +9,9 @@ null '=' '.' 'struct' -'map' -'#' 'namespace' +'include' +'use' null null null @@ -50,13 +50,13 @@ var_def var_def_set call_tree struct_def -power_keyword -power_keyword_call namespace +import_statement +use_statement expr code_block top atn: -[4, 1, 18, 176, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 1, 0, 1, 0, 1, 0, 1, 0, 5, 0, 35, 8, 0, 10, 0, 12, 0, 38, 9, 0, 1, 0, 3, 0, 41, 8, 0, 3, 0, 43, 8, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 51, 8, 1, 10, 1, 12, 1, 54, 9, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 5, 2, 62, 8, 2, 10, 2, 12, 2, 65, 9, 2, 1, 2, 3, 2, 68, 8, 2, 3, 2, 70, 8, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 3, 7, 91, 8, 7, 1, 7, 1, 7, 1, 7, 3, 7, 96, 8, 7, 5, 7, 98, 8, 7, 10, 7, 12, 7, 101, 9, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 5, 10, 114, 8, 10, 10, 10, 12, 10, 117, 9, 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 3, 11, 126, 8, 11, 1, 11, 1, 11, 1, 11, 5, 11, 131, 8, 11, 10, 11, 12, 11, 134, 9, 11, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 3, 12, 143, 8, 12, 1, 12, 1, 12, 5, 12, 147, 8, 12, 10, 12, 12, 12, 150, 9, 12, 1, 13, 1, 13, 1, 13, 1, 13, 3, 13, 156, 8, 13, 1, 13, 1, 13, 5, 13, 160, 8, 13, 10, 13, 12, 13, 163, 9, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 14, 5, 14, 171, 8, 14, 10, 14, 12, 14, 174, 9, 14, 1, 14, 0, 0, 15, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 0, 0, 186, 0, 30, 1, 0, 0, 0, 2, 46, 1, 0, 0, 0, 4, 57, 1, 0, 0, 0, 6, 73, 1, 0, 0, 0, 8, 76, 1, 0, 0, 0, 10, 81, 1, 0, 0, 0, 12, 84, 1, 0, 0, 0, 14, 90, 1, 0, 0, 0, 16, 102, 1, 0, 0, 0, 18, 106, 1, 0, 0, 0, 20, 108, 1, 0, 0, 0, 22, 120, 1, 0, 0, 0, 24, 142, 1, 0, 0, 0, 26, 151, 1, 0, 0, 0, 28, 172, 1, 0, 0, 0, 30, 42, 5, 1, 0, 0, 31, 36, 3, 10, 5, 0, 32, 33, 5, 2, 0, 0, 33, 35, 3, 10, 5, 0, 34, 32, 1, 0, 0, 0, 35, 38, 1, 0, 0, 0, 36, 34, 1, 0, 0, 0, 36, 37, 1, 0, 0, 0, 37, 40, 1, 0, 0, 0, 38, 36, 1, 0, 0, 0, 39, 41, 5, 2, 0, 0, 40, 39, 1, 0, 0, 0, 40, 41, 1, 0, 0, 0, 41, 43, 1, 0, 0, 0, 42, 31, 1, 0, 0, 0, 42, 43, 1, 0, 0, 0, 43, 44, 1, 0, 0, 0, 44, 45, 5, 3, 0, 0, 45, 1, 1, 0, 0, 0, 46, 52, 5, 4, 0, 0, 47, 48, 3, 10, 5, 0, 48, 49, 5, 5, 0, 0, 49, 51, 1, 0, 0, 0, 50, 47, 1, 0, 0, 0, 51, 54, 1, 0, 0, 0, 52, 50, 1, 0, 0, 0, 52, 53, 1, 0, 0, 0, 53, 55, 1, 0, 0, 0, 54, 52, 1, 0, 0, 0, 55, 56, 5, 6, 0, 0, 56, 3, 1, 0, 0, 0, 57, 69, 5, 1, 0, 0, 58, 63, 3, 24, 12, 0, 59, 60, 5, 2, 0, 0, 60, 62, 3, 24, 12, 0, 61, 59, 1, 0, 0, 0, 62, 65, 1, 0, 0, 0, 63, 61, 1, 0, 0, 0, 63, 64, 1, 0, 0, 0, 64, 67, 1, 0, 0, 0, 65, 63, 1, 0, 0, 0, 66, 68, 5, 2, 0, 0, 67, 66, 1, 0, 0, 0, 67, 68, 1, 0, 0, 0, 68, 70, 1, 0, 0, 0, 69, 58, 1, 0, 0, 0, 69, 70, 1, 0, 0, 0, 70, 71, 1, 0, 0, 0, 71, 72, 5, 3, 0, 0, 72, 5, 1, 0, 0, 0, 73, 74, 5, 16, 0, 0, 74, 75, 3, 4, 2, 0, 75, 7, 1, 0, 0, 0, 76, 77, 5, 16, 0, 0, 77, 78, 5, 16, 0, 0, 78, 79, 3, 0, 0, 0, 79, 80, 3, 26, 13, 0, 80, 9, 1, 0, 0, 0, 81, 82, 5, 16, 0, 0, 82, 83, 5, 16, 0, 0, 83, 11, 1, 0, 0, 0, 84, 85, 3, 10, 5, 0, 85, 86, 5, 7, 0, 0, 86, 87, 3, 24, 12, 0, 87, 13, 1, 0, 0, 0, 88, 91, 3, 6, 3, 0, 89, 91, 5, 16, 0, 0, 90, 88, 1, 0, 0, 0, 90, 89, 1, 0, 0, 0, 91, 99, 1, 0, 0, 0, 92, 95, 5, 8, 0, 0, 93, 96, 3, 6, 3, 0, 94, 96, 5, 16, 0, 0, 95, 93, 1, 0, 0, 0, 95, 94, 1, 0, 0, 0, 96, 98, 1, 0, 0, 0, 97, 92, 1, 0, 0, 0, 98, 101, 1, 0, 0, 0, 99, 97, 1, 0, 0, 0, 99, 100, 1, 0, 0, 0, 100, 15, 1, 0, 0, 0, 101, 99, 1, 0, 0, 0, 102, 103, 5, 9, 0, 0, 103, 104, 5, 16, 0, 0, 104, 105, 3, 2, 1, 0, 105, 17, 1, 0, 0, 0, 106, 107, 5, 10, 0, 0, 107, 19, 1, 0, 0, 0, 108, 109, 5, 11, 0, 0, 109, 110, 3, 18, 9, 0, 110, 115, 3, 24, 12, 0, 111, 112, 5, 2, 0, 0, 112, 114, 3, 24, 12, 0, 113, 111, 1, 0, 0, 0, 114, 117, 1, 0, 0, 0, 115, 113, 1, 0, 0, 0, 115, 116, 1, 0, 0, 0, 116, 118, 1, 0, 0, 0, 117, 115, 1, 0, 0, 0, 118, 119, 5, 5, 0, 0, 119, 21, 1, 0, 0, 0, 120, 121, 5, 12, 0, 0, 121, 122, 5, 16, 0, 0, 122, 132, 5, 4, 0, 0, 123, 126, 3, 10, 5, 0, 124, 126, 3, 12, 6, 0, 125, 123, 1, 0, 0, 0, 125, 124, 1, 0, 0, 0, 126, 127, 1, 0, 0, 0, 127, 128, 5, 5, 0, 0, 128, 131, 1, 0, 0, 0, 129, 131, 3, 8, 4, 0, 130, 125, 1, 0, 0, 0, 130, 129, 1, 0, 0, 0, 131, 134, 1, 0, 0, 0, 132, 130, 1, 0, 0, 0, 132, 133, 1, 0, 0, 0, 133, 135, 1, 0, 0, 0, 134, 132, 1, 0, 0, 0, 135, 136, 5, 6, 0, 0, 136, 23, 1, 0, 0, 0, 137, 143, 3, 14, 7, 0, 138, 143, 5, 14, 0, 0, 139, 143, 5, 15, 0, 0, 140, 143, 5, 16, 0, 0, 141, 143, 5, 18, 0, 0, 142, 137, 1, 0, 0, 0, 142, 138, 1, 0, 0, 0, 142, 139, 1, 0, 0, 0, 142, 140, 1, 0, 0, 0, 142, 141, 1, 0, 0, 0, 143, 148, 1, 0, 0, 0, 144, 145, 5, 17, 0, 0, 145, 147, 3, 24, 12, 0, 146, 144, 1, 0, 0, 0, 147, 150, 1, 0, 0, 0, 148, 146, 1, 0, 0, 0, 148, 149, 1, 0, 0, 0, 149, 25, 1, 0, 0, 0, 150, 148, 1, 0, 0, 0, 151, 161, 5, 4, 0, 0, 152, 156, 3, 24, 12, 0, 153, 156, 3, 10, 5, 0, 154, 156, 3, 12, 6, 0, 155, 152, 1, 0, 0, 0, 155, 153, 1, 0, 0, 0, 155, 154, 1, 0, 0, 0, 156, 157, 1, 0, 0, 0, 157, 158, 5, 5, 0, 0, 158, 160, 1, 0, 0, 0, 159, 155, 1, 0, 0, 0, 160, 163, 1, 0, 0, 0, 161, 159, 1, 0, 0, 0, 161, 162, 1, 0, 0, 0, 162, 164, 1, 0, 0, 0, 163, 161, 1, 0, 0, 0, 164, 165, 5, 6, 0, 0, 165, 27, 1, 0, 0, 0, 166, 171, 3, 20, 10, 0, 167, 171, 3, 8, 4, 0, 168, 171, 3, 16, 8, 0, 169, 171, 3, 22, 11, 0, 170, 166, 1, 0, 0, 0, 170, 167, 1, 0, 0, 0, 170, 168, 1, 0, 0, 0, 170, 169, 1, 0, 0, 0, 171, 174, 1, 0, 0, 0, 172, 170, 1, 0, 0, 0, 172, 173, 1, 0, 0, 0, 173, 29, 1, 0, 0, 0, 174, 172, 1, 0, 0, 0, 20, 36, 40, 42, 52, 63, 67, 69, 90, 95, 99, 115, 125, 130, 132, 142, 148, 155, 161, 170, 172] \ No newline at end of file +[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 diff --git a/parser/Wyst.tokens b/parser/Wyst.tokens index 603d454..fdf4b67 100644 --- a/parser/Wyst.tokens +++ b/parser/Wyst.tokens @@ -25,6 +25,6 @@ STRING=18 '='=7 '.'=8 'struct'=9 -'map'=10 -'#'=11 -'namespace'=12 +'namespace'=10 +'include'=11 +'use'=12 diff --git a/parser/WystLexer.interp b/parser/WystLexer.interp index 0394788..c7e9e0b 100644 --- a/parser/WystLexer.interp +++ b/parser/WystLexer.interp @@ -9,9 +9,9 @@ null '=' '.' 'struct' -'map' -'#' 'namespace' +'include' +'use' null null null @@ -69,4 +69,4 @@ mode names: DEFAULT_MODE atn: -[4, 0, 18, 128, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 1, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 12, 4, 12, 80, 8, 12, 11, 12, 12, 12, 81, 1, 12, 1, 12, 1, 13, 1, 13, 5, 13, 88, 8, 13, 10, 13, 12, 13, 91, 9, 13, 1, 13, 3, 13, 94, 8, 13, 1, 14, 1, 14, 1, 14, 1, 14, 5, 14, 100, 8, 14, 10, 14, 12, 14, 103, 9, 14, 1, 15, 1, 15, 1, 15, 1, 15, 5, 15, 109, 8, 15, 10, 15, 12, 15, 112, 9, 15, 1, 16, 1, 16, 1, 17, 1, 17, 1, 17, 1, 18, 1, 18, 1, 18, 5, 18, 122, 8, 18, 10, 18, 12, 18, 125, 9, 18, 1, 18, 1, 18, 0, 0, 19, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15, 31, 16, 33, 17, 35, 0, 37, 18, 1, 0, 9, 3, 0, 9, 10, 13, 13, 32, 32, 1, 0, 49, 57, 1, 0, 48, 57, 3, 0, 48, 57, 65, 70, 97, 102, 3, 0, 65, 90, 95, 95, 97, 122, 4, 0, 48, 57, 65, 90, 95, 95, 97, 122, 3, 0, 42, 43, 45, 45, 47, 47, 3, 0, 34, 34, 39, 39, 92, 92, 2, 0, 34, 34, 92, 92, 134, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 1, 39, 1, 0, 0, 0, 3, 41, 1, 0, 0, 0, 5, 43, 1, 0, 0, 0, 7, 45, 1, 0, 0, 0, 9, 47, 1, 0, 0, 0, 11, 49, 1, 0, 0, 0, 13, 51, 1, 0, 0, 0, 15, 53, 1, 0, 0, 0, 17, 55, 1, 0, 0, 0, 19, 62, 1, 0, 0, 0, 21, 66, 1, 0, 0, 0, 23, 68, 1, 0, 0, 0, 25, 79, 1, 0, 0, 0, 27, 93, 1, 0, 0, 0, 29, 95, 1, 0, 0, 0, 31, 104, 1, 0, 0, 0, 33, 113, 1, 0, 0, 0, 35, 115, 1, 0, 0, 0, 37, 118, 1, 0, 0, 0, 39, 40, 5, 40, 0, 0, 40, 2, 1, 0, 0, 0, 41, 42, 5, 44, 0, 0, 42, 4, 1, 0, 0, 0, 43, 44, 5, 41, 0, 0, 44, 6, 1, 0, 0, 0, 45, 46, 5, 123, 0, 0, 46, 8, 1, 0, 0, 0, 47, 48, 5, 59, 0, 0, 48, 10, 1, 0, 0, 0, 49, 50, 5, 125, 0, 0, 50, 12, 1, 0, 0, 0, 51, 52, 5, 61, 0, 0, 52, 14, 1, 0, 0, 0, 53, 54, 5, 46, 0, 0, 54, 16, 1, 0, 0, 0, 55, 56, 5, 115, 0, 0, 56, 57, 5, 116, 0, 0, 57, 58, 5, 114, 0, 0, 58, 59, 5, 117, 0, 0, 59, 60, 5, 99, 0, 0, 60, 61, 5, 116, 0, 0, 61, 18, 1, 0, 0, 0, 62, 63, 5, 109, 0, 0, 63, 64, 5, 97, 0, 0, 64, 65, 5, 112, 0, 0, 65, 20, 1, 0, 0, 0, 66, 67, 5, 35, 0, 0, 67, 22, 1, 0, 0, 0, 68, 69, 5, 110, 0, 0, 69, 70, 5, 97, 0, 0, 70, 71, 5, 109, 0, 0, 71, 72, 5, 101, 0, 0, 72, 73, 5, 115, 0, 0, 73, 74, 5, 112, 0, 0, 74, 75, 5, 97, 0, 0, 75, 76, 5, 99, 0, 0, 76, 77, 5, 101, 0, 0, 77, 24, 1, 0, 0, 0, 78, 80, 7, 0, 0, 0, 79, 78, 1, 0, 0, 0, 80, 81, 1, 0, 0, 0, 81, 79, 1, 0, 0, 0, 81, 82, 1, 0, 0, 0, 82, 83, 1, 0, 0, 0, 83, 84, 6, 12, 0, 0, 84, 26, 1, 0, 0, 0, 85, 89, 7, 1, 0, 0, 86, 88, 7, 2, 0, 0, 87, 86, 1, 0, 0, 0, 88, 91, 1, 0, 0, 0, 89, 87, 1, 0, 0, 0, 89, 90, 1, 0, 0, 0, 90, 94, 1, 0, 0, 0, 91, 89, 1, 0, 0, 0, 92, 94, 5, 48, 0, 0, 93, 85, 1, 0, 0, 0, 93, 92, 1, 0, 0, 0, 94, 28, 1, 0, 0, 0, 95, 96, 5, 48, 0, 0, 96, 97, 5, 120, 0, 0, 97, 101, 1, 0, 0, 0, 98, 100, 7, 3, 0, 0, 99, 98, 1, 0, 0, 0, 100, 103, 1, 0, 0, 0, 101, 99, 1, 0, 0, 0, 101, 102, 1, 0, 0, 0, 102, 30, 1, 0, 0, 0, 103, 101, 1, 0, 0, 0, 104, 110, 7, 4, 0, 0, 105, 109, 7, 5, 0, 0, 106, 107, 5, 58, 0, 0, 107, 109, 5, 58, 0, 0, 108, 105, 1, 0, 0, 0, 108, 106, 1, 0, 0, 0, 109, 112, 1, 0, 0, 0, 110, 108, 1, 0, 0, 0, 110, 111, 1, 0, 0, 0, 111, 32, 1, 0, 0, 0, 112, 110, 1, 0, 0, 0, 113, 114, 7, 6, 0, 0, 114, 34, 1, 0, 0, 0, 115, 116, 5, 92, 0, 0, 116, 117, 7, 7, 0, 0, 117, 36, 1, 0, 0, 0, 118, 123, 5, 34, 0, 0, 119, 122, 3, 35, 17, 0, 120, 122, 8, 8, 0, 0, 121, 119, 1, 0, 0, 0, 121, 120, 1, 0, 0, 0, 122, 125, 1, 0, 0, 0, 123, 121, 1, 0, 0, 0, 123, 124, 1, 0, 0, 0, 124, 126, 1, 0, 0, 0, 125, 123, 1, 0, 0, 0, 126, 127, 5, 34, 0, 0, 127, 38, 1, 0, 0, 0, 9, 0, 81, 89, 93, 101, 108, 110, 121, 123, 1, 6, 0, 0] \ No newline at end of file +[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 diff --git a/parser/WystLexer.tokens b/parser/WystLexer.tokens index 603d454..fdf4b67 100644 --- a/parser/WystLexer.tokens +++ b/parser/WystLexer.tokens @@ -25,6 +25,6 @@ STRING=18 '='=7 '.'=8 'struct'=9 -'map'=10 -'#'=11 -'namespace'=12 +'namespace'=10 +'include'=11 +'use'=12 diff --git a/parser/wyst_base_listener.go b/parser/wyst_base_listener.go index 386403c..4da8def 100644 --- a/parser/wyst_base_listener.go +++ b/parser/wyst_base_listener.go @@ -75,24 +75,24 @@ func (s *BaseWystListener) EnterStruct_def(ctx *Struct_defContext) {} // ExitStruct_def is called when production struct_def is exited. func (s *BaseWystListener) ExitStruct_def(ctx *Struct_defContext) {} -// EnterPower_keyword is called when production power_keyword is entered. -func (s *BaseWystListener) EnterPower_keyword(ctx *Power_keywordContext) {} - -// ExitPower_keyword is called when production power_keyword is exited. -func (s *BaseWystListener) ExitPower_keyword(ctx *Power_keywordContext) {} - -// EnterPower_keyword_call is called when production power_keyword_call is entered. -func (s *BaseWystListener) EnterPower_keyword_call(ctx *Power_keyword_callContext) {} - -// ExitPower_keyword_call is called when production power_keyword_call is exited. -func (s *BaseWystListener) ExitPower_keyword_call(ctx *Power_keyword_callContext) {} - // EnterNamespace is called when production namespace is entered. func (s *BaseWystListener) EnterNamespace(ctx *NamespaceContext) {} // ExitNamespace is called when production namespace is exited. func (s *BaseWystListener) ExitNamespace(ctx *NamespaceContext) {} +// EnterImport_statement is called when production import_statement is entered. +func (s *BaseWystListener) EnterImport_statement(ctx *Import_statementContext) {} + +// ExitImport_statement is called when production import_statement is exited. +func (s *BaseWystListener) ExitImport_statement(ctx *Import_statementContext) {} + +// EnterUse_statement is called when production use_statement is entered. +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) {} + // 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 5e97cb6..a629fac 100644 --- a/parser/wyst_lexer.go +++ b/parser/wyst_lexer.go @@ -44,7 +44,7 @@ func wystlexerLexerInit() { } staticData.LiteralNames = []string{ "", "'('", "','", "')'", "'{'", "';'", "'}'", "'='", "'.'", "'struct'", - "'map'", "'#'", "'namespace'", + "'namespace'", "'include'", "'use'", } staticData.SymbolicNames = []string{ "", "", "", "", "", "", "", "", "", "", "", "", "", "WS", "NUMBER", @@ -57,64 +57,72 @@ func wystlexerLexerInit() { } staticData.PredictionContextCache = antlr.NewPredictionContextCache() staticData.serializedATN = []int32{ - 4, 0, 18, 128, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, + 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, 10, - 1, 10, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, - 11, 1, 12, 4, 12, 80, 8, 12, 11, 12, 12, 12, 81, 1, 12, 1, 12, 1, 13, 1, - 13, 5, 13, 88, 8, 13, 10, 13, 12, 13, 91, 9, 13, 1, 13, 3, 13, 94, 8, 13, - 1, 14, 1, 14, 1, 14, 1, 14, 5, 14, 100, 8, 14, 10, 14, 12, 14, 103, 9, - 14, 1, 15, 1, 15, 1, 15, 1, 15, 5, 15, 109, 8, 15, 10, 15, 12, 15, 112, - 9, 15, 1, 16, 1, 16, 1, 17, 1, 17, 1, 17, 1, 18, 1, 18, 1, 18, 5, 18, 122, - 8, 18, 10, 18, 12, 18, 125, 9, 18, 1, 18, 1, 18, 0, 0, 19, 1, 1, 3, 2, - 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, - 13, 27, 14, 29, 15, 31, 16, 33, 17, 35, 0, 37, 18, 1, 0, 9, 3, 0, 9, 10, - 13, 13, 32, 32, 1, 0, 49, 57, 1, 0, 48, 57, 3, 0, 48, 57, 65, 70, 97, 102, - 3, 0, 65, 90, 95, 95, 97, 122, 4, 0, 48, 57, 65, 90, 95, 95, 97, 122, 3, - 0, 42, 43, 45, 45, 47, 47, 3, 0, 34, 34, 39, 39, 92, 92, 2, 0, 34, 34, - 92, 92, 134, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, - 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, - 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, - 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, - 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 1, 39, 1, 0, - 0, 0, 3, 41, 1, 0, 0, 0, 5, 43, 1, 0, 0, 0, 7, 45, 1, 0, 0, 0, 9, 47, 1, - 0, 0, 0, 11, 49, 1, 0, 0, 0, 13, 51, 1, 0, 0, 0, 15, 53, 1, 0, 0, 0, 17, - 55, 1, 0, 0, 0, 19, 62, 1, 0, 0, 0, 21, 66, 1, 0, 0, 0, 23, 68, 1, 0, 0, - 0, 25, 79, 1, 0, 0, 0, 27, 93, 1, 0, 0, 0, 29, 95, 1, 0, 0, 0, 31, 104, - 1, 0, 0, 0, 33, 113, 1, 0, 0, 0, 35, 115, 1, 0, 0, 0, 37, 118, 1, 0, 0, - 0, 39, 40, 5, 40, 0, 0, 40, 2, 1, 0, 0, 0, 41, 42, 5, 44, 0, 0, 42, 4, - 1, 0, 0, 0, 43, 44, 5, 41, 0, 0, 44, 6, 1, 0, 0, 0, 45, 46, 5, 123, 0, - 0, 46, 8, 1, 0, 0, 0, 47, 48, 5, 59, 0, 0, 48, 10, 1, 0, 0, 0, 49, 50, - 5, 125, 0, 0, 50, 12, 1, 0, 0, 0, 51, 52, 5, 61, 0, 0, 52, 14, 1, 0, 0, - 0, 53, 54, 5, 46, 0, 0, 54, 16, 1, 0, 0, 0, 55, 56, 5, 115, 0, 0, 56, 57, - 5, 116, 0, 0, 57, 58, 5, 114, 0, 0, 58, 59, 5, 117, 0, 0, 59, 60, 5, 99, - 0, 0, 60, 61, 5, 116, 0, 0, 61, 18, 1, 0, 0, 0, 62, 63, 5, 109, 0, 0, 63, - 64, 5, 97, 0, 0, 64, 65, 5, 112, 0, 0, 65, 20, 1, 0, 0, 0, 66, 67, 5, 35, - 0, 0, 67, 22, 1, 0, 0, 0, 68, 69, 5, 110, 0, 0, 69, 70, 5, 97, 0, 0, 70, - 71, 5, 109, 0, 0, 71, 72, 5, 101, 0, 0, 72, 73, 5, 115, 0, 0, 73, 74, 5, - 112, 0, 0, 74, 75, 5, 97, 0, 0, 75, 76, 5, 99, 0, 0, 76, 77, 5, 101, 0, - 0, 77, 24, 1, 0, 0, 0, 78, 80, 7, 0, 0, 0, 79, 78, 1, 0, 0, 0, 80, 81, - 1, 0, 0, 0, 81, 79, 1, 0, 0, 0, 81, 82, 1, 0, 0, 0, 82, 83, 1, 0, 0, 0, - 83, 84, 6, 12, 0, 0, 84, 26, 1, 0, 0, 0, 85, 89, 7, 1, 0, 0, 86, 88, 7, - 2, 0, 0, 87, 86, 1, 0, 0, 0, 88, 91, 1, 0, 0, 0, 89, 87, 1, 0, 0, 0, 89, - 90, 1, 0, 0, 0, 90, 94, 1, 0, 0, 0, 91, 89, 1, 0, 0, 0, 92, 94, 5, 48, - 0, 0, 93, 85, 1, 0, 0, 0, 93, 92, 1, 0, 0, 0, 94, 28, 1, 0, 0, 0, 95, 96, - 5, 48, 0, 0, 96, 97, 5, 120, 0, 0, 97, 101, 1, 0, 0, 0, 98, 100, 7, 3, - 0, 0, 99, 98, 1, 0, 0, 0, 100, 103, 1, 0, 0, 0, 101, 99, 1, 0, 0, 0, 101, - 102, 1, 0, 0, 0, 102, 30, 1, 0, 0, 0, 103, 101, 1, 0, 0, 0, 104, 110, 7, - 4, 0, 0, 105, 109, 7, 5, 0, 0, 106, 107, 5, 58, 0, 0, 107, 109, 5, 58, - 0, 0, 108, 105, 1, 0, 0, 0, 108, 106, 1, 0, 0, 0, 109, 112, 1, 0, 0, 0, - 110, 108, 1, 0, 0, 0, 110, 111, 1, 0, 0, 0, 111, 32, 1, 0, 0, 0, 112, 110, - 1, 0, 0, 0, 113, 114, 7, 6, 0, 0, 114, 34, 1, 0, 0, 0, 115, 116, 5, 92, - 0, 0, 116, 117, 7, 7, 0, 0, 117, 36, 1, 0, 0, 0, 118, 123, 5, 34, 0, 0, - 119, 122, 3, 35, 17, 0, 120, 122, 8, 8, 0, 0, 121, 119, 1, 0, 0, 0, 121, - 120, 1, 0, 0, 0, 122, 125, 1, 0, 0, 0, 123, 121, 1, 0, 0, 0, 123, 124, - 1, 0, 0, 0, 124, 126, 1, 0, 0, 0, 125, 123, 1, 0, 0, 0, 126, 127, 5, 34, - 0, 0, 127, 38, 1, 0, 0, 0, 9, 0, 81, 89, 93, 101, 108, 110, 121, 123, 1, - 6, 0, 0, + 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, } deserializer := antlr.NewATNDeserializer(nil) staticData.atn = deserializer.Deserialize(staticData.serializedATN) diff --git a/parser/wyst_listener.go b/parser/wyst_listener.go index baa2c5b..55c1d21 100644 --- a/parser/wyst_listener.go +++ b/parser/wyst_listener.go @@ -35,15 +35,15 @@ type WystListener interface { // EnterStruct_def is called when entering the struct_def production. EnterStruct_def(c *Struct_defContext) - // EnterPower_keyword is called when entering the power_keyword production. - EnterPower_keyword(c *Power_keywordContext) - - // EnterPower_keyword_call is called when entering the power_keyword_call production. - EnterPower_keyword_call(c *Power_keyword_callContext) - // EnterNamespace is called when entering the namespace production. EnterNamespace(c *NamespaceContext) + // EnterImport_statement is called when entering the import_statement production. + EnterImport_statement(c *Import_statementContext) + + // EnterUse_statement is called when entering the use_statement production. + EnterUse_statement(c *Use_statementContext) + // EnterExpr is called when entering the expr production. EnterExpr(c *ExprContext) @@ -80,15 +80,15 @@ type WystListener interface { // ExitStruct_def is called when exiting the struct_def production. ExitStruct_def(c *Struct_defContext) - // ExitPower_keyword is called when exiting the power_keyword production. - ExitPower_keyword(c *Power_keywordContext) - - // ExitPower_keyword_call is called when exiting the power_keyword_call production. - ExitPower_keyword_call(c *Power_keyword_callContext) - // ExitNamespace is called when exiting the namespace production. ExitNamespace(c *NamespaceContext) + // ExitImport_statement is called when exiting the import_statement production. + ExitImport_statement(c *Import_statementContext) + + // ExitUse_statement is called when exiting the use_statement production. + ExitUse_statement(c *Use_statementContext) + // ExitExpr is called when exiting the expr production. ExitExpr(c *ExprContext) diff --git a/parser/wyst_parser.go b/parser/wyst_parser.go index 79a3095..03d0b76 100644 --- a/parser/wyst_parser.go +++ b/parser/wyst_parser.go @@ -34,7 +34,7 @@ func wystParserInit() { staticData := &WystParserStaticData staticData.LiteralNames = []string{ "", "'('", "','", "')'", "'{'", "';'", "'}'", "'='", "'.'", "'struct'", - "'map'", "'#'", "'namespace'", + "'namespace'", "'include'", "'use'", } staticData.SymbolicNames = []string{ "", "", "", "", "", "", "", "", "", "", "", "", "", "WS", "NUMBER", @@ -42,12 +42,12 @@ func wystParserInit() { } staticData.RuleNames = []string{ "round_def", "enum_curly", "round_call", "fn_call", "func_def", "var_def", - "var_def_set", "call_tree", "struct_def", "power_keyword", "power_keyword_call", - "namespace", "expr", "code_block", "top", + "var_def_set", "call_tree", "struct_def", "namespace", "import_statement", + "use_statement", "expr", "code_block", "top", } staticData.PredictionContextCache = antlr.NewPredictionContextCache() staticData.serializedATN = []int32{ - 4, 1, 18, 176, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, + 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, @@ -57,71 +57,69 @@ func wystParserInit() { 1, 2, 1, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 3, 7, 91, 8, 7, 1, 7, 1, 7, 1, 7, 3, 7, 96, 8, 7, 5, 7, 98, 8, 7, 10, 7, 12, 7, 101, 9, 7, 1, 8, 1, 8, 1, 8, - 1, 8, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 5, 10, 114, 8, 10, - 10, 10, 12, 10, 117, 9, 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 11, 1, - 11, 3, 11, 126, 8, 11, 1, 11, 1, 11, 1, 11, 5, 11, 131, 8, 11, 10, 11, - 12, 11, 134, 9, 11, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 3, - 12, 143, 8, 12, 1, 12, 1, 12, 5, 12, 147, 8, 12, 10, 12, 12, 12, 150, 9, - 12, 1, 13, 1, 13, 1, 13, 1, 13, 3, 13, 156, 8, 13, 1, 13, 1, 13, 5, 13, - 160, 8, 13, 10, 13, 12, 13, 163, 9, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, - 14, 1, 14, 5, 14, 171, 8, 14, 10, 14, 12, 14, 174, 9, 14, 1, 14, 0, 0, - 15, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 0, 0, 186, 0, - 30, 1, 0, 0, 0, 2, 46, 1, 0, 0, 0, 4, 57, 1, 0, 0, 0, 6, 73, 1, 0, 0, 0, - 8, 76, 1, 0, 0, 0, 10, 81, 1, 0, 0, 0, 12, 84, 1, 0, 0, 0, 14, 90, 1, 0, - 0, 0, 16, 102, 1, 0, 0, 0, 18, 106, 1, 0, 0, 0, 20, 108, 1, 0, 0, 0, 22, - 120, 1, 0, 0, 0, 24, 142, 1, 0, 0, 0, 26, 151, 1, 0, 0, 0, 28, 172, 1, - 0, 0, 0, 30, 42, 5, 1, 0, 0, 31, 36, 3, 10, 5, 0, 32, 33, 5, 2, 0, 0, 33, - 35, 3, 10, 5, 0, 34, 32, 1, 0, 0, 0, 35, 38, 1, 0, 0, 0, 36, 34, 1, 0, - 0, 0, 36, 37, 1, 0, 0, 0, 37, 40, 1, 0, 0, 0, 38, 36, 1, 0, 0, 0, 39, 41, - 5, 2, 0, 0, 40, 39, 1, 0, 0, 0, 40, 41, 1, 0, 0, 0, 41, 43, 1, 0, 0, 0, - 42, 31, 1, 0, 0, 0, 42, 43, 1, 0, 0, 0, 43, 44, 1, 0, 0, 0, 44, 45, 5, - 3, 0, 0, 45, 1, 1, 0, 0, 0, 46, 52, 5, 4, 0, 0, 47, 48, 3, 10, 5, 0, 48, - 49, 5, 5, 0, 0, 49, 51, 1, 0, 0, 0, 50, 47, 1, 0, 0, 0, 51, 54, 1, 0, 0, - 0, 52, 50, 1, 0, 0, 0, 52, 53, 1, 0, 0, 0, 53, 55, 1, 0, 0, 0, 54, 52, - 1, 0, 0, 0, 55, 56, 5, 6, 0, 0, 56, 3, 1, 0, 0, 0, 57, 69, 5, 1, 0, 0, - 58, 63, 3, 24, 12, 0, 59, 60, 5, 2, 0, 0, 60, 62, 3, 24, 12, 0, 61, 59, - 1, 0, 0, 0, 62, 65, 1, 0, 0, 0, 63, 61, 1, 0, 0, 0, 63, 64, 1, 0, 0, 0, - 64, 67, 1, 0, 0, 0, 65, 63, 1, 0, 0, 0, 66, 68, 5, 2, 0, 0, 67, 66, 1, - 0, 0, 0, 67, 68, 1, 0, 0, 0, 68, 70, 1, 0, 0, 0, 69, 58, 1, 0, 0, 0, 69, - 70, 1, 0, 0, 0, 70, 71, 1, 0, 0, 0, 71, 72, 5, 3, 0, 0, 72, 5, 1, 0, 0, - 0, 73, 74, 5, 16, 0, 0, 74, 75, 3, 4, 2, 0, 75, 7, 1, 0, 0, 0, 76, 77, - 5, 16, 0, 0, 77, 78, 5, 16, 0, 0, 78, 79, 3, 0, 0, 0, 79, 80, 3, 26, 13, - 0, 80, 9, 1, 0, 0, 0, 81, 82, 5, 16, 0, 0, 82, 83, 5, 16, 0, 0, 83, 11, - 1, 0, 0, 0, 84, 85, 3, 10, 5, 0, 85, 86, 5, 7, 0, 0, 86, 87, 3, 24, 12, - 0, 87, 13, 1, 0, 0, 0, 88, 91, 3, 6, 3, 0, 89, 91, 5, 16, 0, 0, 90, 88, - 1, 0, 0, 0, 90, 89, 1, 0, 0, 0, 91, 99, 1, 0, 0, 0, 92, 95, 5, 8, 0, 0, - 93, 96, 3, 6, 3, 0, 94, 96, 5, 16, 0, 0, 95, 93, 1, 0, 0, 0, 95, 94, 1, - 0, 0, 0, 96, 98, 1, 0, 0, 0, 97, 92, 1, 0, 0, 0, 98, 101, 1, 0, 0, 0, 99, - 97, 1, 0, 0, 0, 99, 100, 1, 0, 0, 0, 100, 15, 1, 0, 0, 0, 101, 99, 1, 0, - 0, 0, 102, 103, 5, 9, 0, 0, 103, 104, 5, 16, 0, 0, 104, 105, 3, 2, 1, 0, - 105, 17, 1, 0, 0, 0, 106, 107, 5, 10, 0, 0, 107, 19, 1, 0, 0, 0, 108, 109, - 5, 11, 0, 0, 109, 110, 3, 18, 9, 0, 110, 115, 3, 24, 12, 0, 111, 112, 5, - 2, 0, 0, 112, 114, 3, 24, 12, 0, 113, 111, 1, 0, 0, 0, 114, 117, 1, 0, - 0, 0, 115, 113, 1, 0, 0, 0, 115, 116, 1, 0, 0, 0, 116, 118, 1, 0, 0, 0, - 117, 115, 1, 0, 0, 0, 118, 119, 5, 5, 0, 0, 119, 21, 1, 0, 0, 0, 120, 121, - 5, 12, 0, 0, 121, 122, 5, 16, 0, 0, 122, 132, 5, 4, 0, 0, 123, 126, 3, - 10, 5, 0, 124, 126, 3, 12, 6, 0, 125, 123, 1, 0, 0, 0, 125, 124, 1, 0, - 0, 0, 126, 127, 1, 0, 0, 0, 127, 128, 5, 5, 0, 0, 128, 131, 1, 0, 0, 0, - 129, 131, 3, 8, 4, 0, 130, 125, 1, 0, 0, 0, 130, 129, 1, 0, 0, 0, 131, - 134, 1, 0, 0, 0, 132, 130, 1, 0, 0, 0, 132, 133, 1, 0, 0, 0, 133, 135, - 1, 0, 0, 0, 134, 132, 1, 0, 0, 0, 135, 136, 5, 6, 0, 0, 136, 23, 1, 0, - 0, 0, 137, 143, 3, 14, 7, 0, 138, 143, 5, 14, 0, 0, 139, 143, 5, 15, 0, - 0, 140, 143, 5, 16, 0, 0, 141, 143, 5, 18, 0, 0, 142, 137, 1, 0, 0, 0, - 142, 138, 1, 0, 0, 0, 142, 139, 1, 0, 0, 0, 142, 140, 1, 0, 0, 0, 142, - 141, 1, 0, 0, 0, 143, 148, 1, 0, 0, 0, 144, 145, 5, 17, 0, 0, 145, 147, - 3, 24, 12, 0, 146, 144, 1, 0, 0, 0, 147, 150, 1, 0, 0, 0, 148, 146, 1, - 0, 0, 0, 148, 149, 1, 0, 0, 0, 149, 25, 1, 0, 0, 0, 150, 148, 1, 0, 0, - 0, 151, 161, 5, 4, 0, 0, 152, 156, 3, 24, 12, 0, 153, 156, 3, 10, 5, 0, - 154, 156, 3, 12, 6, 0, 155, 152, 1, 0, 0, 0, 155, 153, 1, 0, 0, 0, 155, - 154, 1, 0, 0, 0, 156, 157, 1, 0, 0, 0, 157, 158, 5, 5, 0, 0, 158, 160, - 1, 0, 0, 0, 159, 155, 1, 0, 0, 0, 160, 163, 1, 0, 0, 0, 161, 159, 1, 0, - 0, 0, 161, 162, 1, 0, 0, 0, 162, 164, 1, 0, 0, 0, 163, 161, 1, 0, 0, 0, - 164, 165, 5, 6, 0, 0, 165, 27, 1, 0, 0, 0, 166, 171, 3, 20, 10, 0, 167, - 171, 3, 8, 4, 0, 168, 171, 3, 16, 8, 0, 169, 171, 3, 22, 11, 0, 170, 166, - 1, 0, 0, 0, 170, 167, 1, 0, 0, 0, 170, 168, 1, 0, 0, 0, 170, 169, 1, 0, - 0, 0, 171, 174, 1, 0, 0, 0, 172, 170, 1, 0, 0, 0, 172, 173, 1, 0, 0, 0, - 173, 29, 1, 0, 0, 0, 174, 172, 1, 0, 0, 0, 20, 36, 40, 42, 52, 63, 67, - 69, 90, 95, 99, 115, 125, 130, 132, 142, 148, 155, 161, 170, 172, + 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, } deserializer := antlr.NewATNDeserializer(nil) staticData.atn = deserializer.Deserialize(staticData.serializedATN) @@ -182,21 +180,21 @@ const ( // WystParser rules. const ( - WystParserRULE_round_def = 0 - WystParserRULE_enum_curly = 1 - WystParserRULE_round_call = 2 - WystParserRULE_fn_call = 3 - WystParserRULE_func_def = 4 - WystParserRULE_var_def = 5 - WystParserRULE_var_def_set = 6 - WystParserRULE_call_tree = 7 - WystParserRULE_struct_def = 8 - WystParserRULE_power_keyword = 9 - WystParserRULE_power_keyword_call = 10 - WystParserRULE_namespace = 11 - WystParserRULE_expr = 12 - WystParserRULE_code_block = 13 - WystParserRULE_top = 14 + WystParserRULE_round_def = 0 + WystParserRULE_enum_curly = 1 + WystParserRULE_round_call = 2 + WystParserRULE_fn_call = 3 + WystParserRULE_func_def = 4 + WystParserRULE_var_def = 5 + WystParserRULE_var_def_set = 6 + WystParserRULE_call_tree = 7 + WystParserRULE_struct_def = 8 + WystParserRULE_namespace = 9 + WystParserRULE_import_statement = 10 + WystParserRULE_use_statement = 11 + WystParserRULE_expr = 12 + WystParserRULE_code_block = 13 + WystParserRULE_top = 14 ) // IRound_defContext is an interface to support dynamic dispatch. @@ -1646,290 +1644,6 @@ errorExit: goto errorExit // Trick to prevent compiler error if the label is not used } -// IPower_keywordContext is an interface to support dynamic dispatch. -type IPower_keywordContext interface { - antlr.ParserRuleContext - - // GetParser returns the parser. - GetParser() antlr.Parser - // IsPower_keywordContext differentiates from other interfaces. - IsPower_keywordContext() -} - -type Power_keywordContext struct { - antlr.BaseParserRuleContext - parser antlr.Parser -} - -func NewEmptyPower_keywordContext() *Power_keywordContext { - var p = new(Power_keywordContext) - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = WystParserRULE_power_keyword - return p -} - -func InitEmptyPower_keywordContext(p *Power_keywordContext) { - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = WystParserRULE_power_keyword -} - -func (*Power_keywordContext) IsPower_keywordContext() {} - -func NewPower_keywordContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *Power_keywordContext { - var p = new(Power_keywordContext) - - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) - - p.parser = parser - p.RuleIndex = WystParserRULE_power_keyword - - return p -} - -func (s *Power_keywordContext) GetParser() antlr.Parser { return s.parser } -func (s *Power_keywordContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *Power_keywordContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { - return antlr.TreesStringTree(s, ruleNames, recog) -} - -func (s *Power_keywordContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(WystListener); ok { - listenerT.EnterPower_keyword(s) - } -} - -func (s *Power_keywordContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(WystListener); ok { - listenerT.ExitPower_keyword(s) - } -} - -func (p *WystParser) Power_keyword() (localctx IPower_keywordContext) { - localctx = NewPower_keywordContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 18, WystParserRULE_power_keyword) - p.EnterOuterAlt(localctx, 1) - { - p.SetState(106) - p.Match(WystParserT__9) - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - -errorExit: - if p.HasError() { - v := p.GetError() - localctx.SetException(v) - p.GetErrorHandler().ReportError(p, v) - p.GetErrorHandler().Recover(p, v) - p.SetError(nil) - } - p.ExitRule() - return localctx - goto errorExit // Trick to prevent compiler error if the label is not used -} - -// IPower_keyword_callContext is an interface to support dynamic dispatch. -type IPower_keyword_callContext interface { - antlr.ParserRuleContext - - // GetParser returns the parser. - GetParser() antlr.Parser - - // Getter signatures - Power_keyword() IPower_keywordContext - AllExpr() []IExprContext - Expr(i int) IExprContext - - // IsPower_keyword_callContext differentiates from other interfaces. - IsPower_keyword_callContext() -} - -type Power_keyword_callContext struct { - antlr.BaseParserRuleContext - parser antlr.Parser -} - -func NewEmptyPower_keyword_callContext() *Power_keyword_callContext { - var p = new(Power_keyword_callContext) - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = WystParserRULE_power_keyword_call - return p -} - -func InitEmptyPower_keyword_callContext(p *Power_keyword_callContext) { - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = WystParserRULE_power_keyword_call -} - -func (*Power_keyword_callContext) IsPower_keyword_callContext() {} - -func NewPower_keyword_callContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *Power_keyword_callContext { - var p = new(Power_keyword_callContext) - - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) - - p.parser = parser - p.RuleIndex = WystParserRULE_power_keyword_call - - return p -} - -func (s *Power_keyword_callContext) GetParser() antlr.Parser { return s.parser } - -func (s *Power_keyword_callContext) Power_keyword() IPower_keywordContext { - var t antlr.RuleContext - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(IPower_keywordContext); ok { - t = ctx.(antlr.RuleContext) - break - } - } - - if t == nil { - return nil - } - - return t.(IPower_keywordContext) -} - -func (s *Power_keyword_callContext) AllExpr() []IExprContext { - children := s.GetChildren() - len := 0 - for _, ctx := range children { - 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 *Power_keyword_callContext) Expr(i int) IExprContext { - var t antlr.RuleContext - j := 0 - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(IExprContext); ok { - if j == i { - t = ctx.(antlr.RuleContext) - break - } - j++ - } - } - - if t == nil { - return nil - } - - return t.(IExprContext) -} - -func (s *Power_keyword_callContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *Power_keyword_callContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { - return antlr.TreesStringTree(s, ruleNames, recog) -} - -func (s *Power_keyword_callContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(WystListener); ok { - listenerT.EnterPower_keyword_call(s) - } -} - -func (s *Power_keyword_callContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(WystListener); ok { - listenerT.ExitPower_keyword_call(s) - } -} - -func (p *WystParser) Power_keyword_call() (localctx IPower_keyword_callContext) { - localctx = NewPower_keyword_callContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 20, WystParserRULE_power_keyword_call) - var _la int - - p.EnterOuterAlt(localctx, 1) - { - p.SetState(108) - p.Match(WystParserT__10) - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - { - p.SetState(109) - p.Power_keyword() - } - { - p.SetState(110) - p.Expr() - } - p.SetState(115) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - - for _la == WystParserT__1 { - { - p.SetState(111) - p.Match(WystParserT__1) - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - { - p.SetState(112) - p.Expr() - } - - p.SetState(117) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(118) - p.Match(WystParserT__4) - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - -errorExit: - if p.HasError() { - v := p.GetError() - localctx.SetException(v) - p.GetErrorHandler().ReportError(p, v) - p.GetErrorHandler().Recover(p, v) - p.SetError(nil) - } - p.ExitRule() - return localctx - goto errorExit // Trick to prevent compiler error if the label is not used -} - // INamespaceContext is an interface to support dynamic dispatch. type INamespaceContext interface { antlr.ParserRuleContext @@ -2131,20 +1845,20 @@ func (s *NamespaceContext) ExitRule(listener antlr.ParseTreeListener) { func (p *WystParser) Namespace() (localctx INamespaceContext) { localctx = NewNamespaceContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 22, WystParserRULE_namespace) + p.EnterRule(localctx, 18, WystParserRULE_namespace) var _la int p.EnterOuterAlt(localctx, 1) { - p.SetState(120) - p.Match(WystParserT__11) + p.SetState(106) + p.Match(WystParserT__9) if p.HasError() { // Recognition error - abort rule goto errorExit } } { - p.SetState(121) + p.SetState(107) p.Match(WystParserIDENTIFIER) if p.HasError() { // Recognition error - abort rule @@ -2152,14 +1866,14 @@ func (p *WystParser) Namespace() (localctx INamespaceContext) { } } { - p.SetState(122) + p.SetState(108) p.Match(WystParserT__3) if p.HasError() { // Recognition error - abort rule goto errorExit } } - p.SetState(132) + p.SetState(118) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -2167,30 +1881,30 @@ func (p *WystParser) Namespace() (localctx INamespaceContext) { _la = p.GetTokenStream().LA(1) for _la == WystParserIDENTIFIER { - p.SetState(130) + p.SetState(116) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } - switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 12, p.GetParserRuleContext()) { + switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 11, p.GetParserRuleContext()) { case 1: - p.SetState(125) + p.SetState(111) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } - switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 11, p.GetParserRuleContext()) { + switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 10, p.GetParserRuleContext()) { case 1: { - p.SetState(123) + p.SetState(109) p.Var_def() } case 2: { - p.SetState(124) + p.SetState(110) p.Var_def_set() } @@ -2198,7 +1912,7 @@ func (p *WystParser) Namespace() (localctx INamespaceContext) { goto errorExit } { - p.SetState(127) + p.SetState(113) p.Match(WystParserT__4) if p.HasError() { // Recognition error - abort rule @@ -2208,7 +1922,7 @@ func (p *WystParser) Namespace() (localctx INamespaceContext) { case 2: { - p.SetState(129) + p.SetState(115) p.Func_def() } @@ -2216,7 +1930,7 @@ func (p *WystParser) Namespace() (localctx INamespaceContext) { goto errorExit } - p.SetState(134) + p.SetState(120) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -2224,7 +1938,7 @@ func (p *WystParser) Namespace() (localctx INamespaceContext) { _la = p.GetTokenStream().LA(1) } { - p.SetState(135) + p.SetState(121) p.Match(WystParserT__5) if p.HasError() { // Recognition error - abort rule @@ -2245,6 +1959,230 @@ errorExit: goto errorExit // Trick to prevent compiler error if the label is not used } +// IImport_statementContext is an interface to support dynamic dispatch. +type IImport_statementContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + + // Getter signatures + IDENTIFIER() antlr.TerminalNode + + // IsImport_statementContext differentiates from other interfaces. + IsImport_statementContext() +} + +type Import_statementContext struct { + antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyImport_statementContext() *Import_statementContext { + var p = new(Import_statementContext) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = WystParserRULE_import_statement + return p +} + +func InitEmptyImport_statementContext(p *Import_statementContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = WystParserRULE_import_statement +} + +func (*Import_statementContext) IsImport_statementContext() {} + +func NewImport_statementContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *Import_statementContext { + var p = new(Import_statementContext) + + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) + + p.parser = parser + p.RuleIndex = WystParserRULE_import_statement + + return p +} + +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) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *Import_statementContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +func (s *Import_statementContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(WystListener); ok { + listenerT.EnterImport_statement(s) + } +} + +func (s *Import_statementContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(WystListener); ok { + listenerT.ExitImport_statement(s) + } +} + +func (p *WystParser) Import_statement() (localctx IImport_statementContext) { + localctx = NewImport_statementContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 20, WystParserRULE_import_statement) + p.EnterOuterAlt(localctx, 1) + { + p.SetState(123) + p.Match(WystParserT__10) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + { + p.SetState(124) + p.Match(WystParserIDENTIFIER) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + { + p.SetState(125) + 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 +} + +// IUse_statementContext is an interface to support dynamic dispatch. +type IUse_statementContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + + // Getter signatures + IDENTIFIER() antlr.TerminalNode + + // IsUse_statementContext differentiates from other interfaces. + IsUse_statementContext() +} + +type Use_statementContext struct { + antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyUse_statementContext() *Use_statementContext { + var p = new(Use_statementContext) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = WystParserRULE_use_statement + return p +} + +func InitEmptyUse_statementContext(p *Use_statementContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = WystParserRULE_use_statement +} + +func (*Use_statementContext) IsUse_statementContext() {} + +func NewUse_statementContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *Use_statementContext { + var p = new(Use_statementContext) + + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) + + p.parser = parser + p.RuleIndex = WystParserRULE_use_statement + + return p +} + +func (s *Use_statementContext) GetParser() antlr.Parser { return s.parser } + +func (s *Use_statementContext) IDENTIFIER() antlr.TerminalNode { + return s.GetToken(WystParserIDENTIFIER, 0) +} + +func (s *Use_statementContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *Use_statementContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +func (s *Use_statementContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(WystListener); ok { + listenerT.EnterUse_statement(s) + } +} + +func (s *Use_statementContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(WystListener); ok { + listenerT.ExitUse_statement(s) + } +} + +func (p *WystParser) Use_statement() (localctx IUse_statementContext) { + localctx = NewUse_statementContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 22, WystParserRULE_use_statement) + p.EnterOuterAlt(localctx, 1) + { + p.SetState(127) + p.Match(WystParserT__11) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + { + p.SetState(128) + p.Match(WystParserIDENTIFIER) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + { + p.SetState(129) + 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 +} + // IExprContext is an interface to support dynamic dispatch. type IExprContext interface { antlr.ParserRuleContext @@ -2406,22 +2344,22 @@ func (p *WystParser) Expr() (localctx IExprContext) { var _alt int p.EnterOuterAlt(localctx, 1) - p.SetState(142) + p.SetState(136) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } - switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 14, p.GetParserRuleContext()) { + switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 13, p.GetParserRuleContext()) { case 1: { - p.SetState(137) + p.SetState(131) p.Call_tree() } case 2: { - p.SetState(138) + p.SetState(132) p.Match(WystParserNUMBER) if p.HasError() { // Recognition error - abort rule @@ -2431,7 +2369,7 @@ func (p *WystParser) Expr() (localctx IExprContext) { case 3: { - p.SetState(139) + p.SetState(133) p.Match(WystParserHEX) if p.HasError() { // Recognition error - abort rule @@ -2441,7 +2379,7 @@ func (p *WystParser) Expr() (localctx IExprContext) { case 4: { - p.SetState(140) + p.SetState(134) p.Match(WystParserIDENTIFIER) if p.HasError() { // Recognition error - abort rule @@ -2451,7 +2389,7 @@ func (p *WystParser) Expr() (localctx IExprContext) { case 5: { - p.SetState(141) + p.SetState(135) p.Match(WystParserSTRING) if p.HasError() { // Recognition error - abort rule @@ -2462,19 +2400,19 @@ func (p *WystParser) Expr() (localctx IExprContext) { case antlr.ATNInvalidAltNumber: goto errorExit } - p.SetState(148) + p.SetState(142) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } - _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 15, p.GetParserRuleContext()) + _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 14, p.GetParserRuleContext()) if p.HasError() { goto errorExit } for _alt != 2 && _alt != antlr.ATNInvalidAltNumber { if _alt == 1 { { - p.SetState(144) + p.SetState(138) p.Match(WystParserMATH) if p.HasError() { // Recognition error - abort rule @@ -2482,17 +2420,17 @@ func (p *WystParser) Expr() (localctx IExprContext) { } } { - p.SetState(145) + p.SetState(139) p.Expr() } } - p.SetState(150) + p.SetState(144) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } - _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 15, p.GetParserRuleContext()) + _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 14, p.GetParserRuleContext()) if p.HasError() { goto errorExit } @@ -2712,14 +2650,14 @@ func (p *WystParser) Code_block() (localctx ICode_blockContext) { p.EnterOuterAlt(localctx, 1) { - p.SetState(151) + p.SetState(145) p.Match(WystParserT__3) if p.HasError() { // Recognition error - abort rule goto errorExit } } - p.SetState(161) + p.SetState(155) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -2727,28 +2665,28 @@ func (p *WystParser) Code_block() (localctx ICode_blockContext) { _la = p.GetTokenStream().LA(1) for (int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&376832) != 0 { - p.SetState(155) + p.SetState(149) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } - switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 16, p.GetParserRuleContext()) { + switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 15, p.GetParserRuleContext()) { case 1: { - p.SetState(152) + p.SetState(146) p.Expr() } case 2: { - p.SetState(153) + p.SetState(147) p.Var_def() } case 3: { - p.SetState(154) + p.SetState(148) p.Var_def_set() } @@ -2756,7 +2694,7 @@ func (p *WystParser) Code_block() (localctx ICode_blockContext) { goto errorExit } { - p.SetState(157) + p.SetState(151) p.Match(WystParserT__4) if p.HasError() { // Recognition error - abort rule @@ -2764,7 +2702,7 @@ func (p *WystParser) Code_block() (localctx ICode_blockContext) { } } - p.SetState(163) + p.SetState(157) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -2772,7 +2710,7 @@ func (p *WystParser) Code_block() (localctx ICode_blockContext) { _la = p.GetTokenStream().LA(1) } { - p.SetState(164) + p.SetState(158) p.Match(WystParserT__5) if p.HasError() { // Recognition error - abort rule @@ -2801,14 +2739,16 @@ type ITopContext interface { GetParser() antlr.Parser // Getter signatures - AllPower_keyword_call() []IPower_keyword_callContext - Power_keyword_call(i int) IPower_keyword_callContext AllFunc_def() []IFunc_defContext Func_def(i int) IFunc_defContext AllStruct_def() []IStruct_defContext Struct_def(i int) IStruct_defContext AllNamespace() []INamespaceContext Namespace(i int) INamespaceContext + AllImport_statement() []IImport_statementContext + Import_statement(i int) IImport_statementContext + AllUse_statement() []IUse_statementContext + Use_statement(i int) IUse_statementContext // IsTopContext differentiates from other interfaces. IsTopContext() @@ -2846,47 +2786,6 @@ func NewTopContext(parser antlr.Parser, parent antlr.ParserRuleContext, invoking func (s *TopContext) GetParser() antlr.Parser { return s.parser } -func (s *TopContext) AllPower_keyword_call() []IPower_keyword_callContext { - children := s.GetChildren() - len := 0 - for _, ctx := range children { - if _, ok := ctx.(IPower_keyword_callContext); ok { - len++ - } - } - - tst := make([]IPower_keyword_callContext, len) - i := 0 - for _, ctx := range children { - if t, ok := ctx.(IPower_keyword_callContext); ok { - tst[i] = t.(IPower_keyword_callContext) - i++ - } - } - - return tst -} - -func (s *TopContext) Power_keyword_call(i int) IPower_keyword_callContext { - var t antlr.RuleContext - j := 0 - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(IPower_keyword_callContext); ok { - if j == i { - t = ctx.(antlr.RuleContext) - break - } - j++ - } - } - - if t == nil { - return nil - } - - return t.(IPower_keyword_callContext) -} - func (s *TopContext) AllFunc_def() []IFunc_defContext { children := s.GetChildren() len := 0 @@ -3010,6 +2909,88 @@ func (s *TopContext) Namespace(i int) INamespaceContext { return t.(INamespaceContext) } +func (s *TopContext) AllImport_statement() []IImport_statementContext { + children := s.GetChildren() + len := 0 + for _, ctx := range children { + if _, ok := ctx.(IImport_statementContext); ok { + len++ + } + } + + tst := make([]IImport_statementContext, len) + i := 0 + for _, ctx := range children { + if t, ok := ctx.(IImport_statementContext); ok { + tst[i] = t.(IImport_statementContext) + i++ + } + } + + return tst +} + +func (s *TopContext) Import_statement(i int) IImport_statementContext { + var t antlr.RuleContext + j := 0 + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IImport_statementContext); ok { + if j == i { + t = ctx.(antlr.RuleContext) + break + } + j++ + } + } + + if t == nil { + return nil + } + + return t.(IImport_statementContext) +} + +func (s *TopContext) AllUse_statement() []IUse_statementContext { + children := s.GetChildren() + len := 0 + for _, ctx := range children { + if _, ok := ctx.(IUse_statementContext); ok { + len++ + } + } + + tst := make([]IUse_statementContext, len) + i := 0 + for _, ctx := range children { + if t, ok := ctx.(IUse_statementContext); ok { + tst[i] = t.(IUse_statementContext) + i++ + } + } + + return tst +} + +func (s *TopContext) Use_statement(i int) IUse_statementContext { + var t antlr.RuleContext + j := 0 + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IUse_statementContext); ok { + if j == i { + t = ctx.(antlr.RuleContext) + break + } + j++ + } + } + + if t == nil { + return nil + } + + return t.(IUse_statementContext) +} + func (s *TopContext) GetRuleContext() antlr.RuleContext { return s } @@ -3036,43 +3017,49 @@ func (p *WystParser) Top() (localctx ITopContext) { var _la int p.EnterOuterAlt(localctx, 1) - p.SetState(172) + p.SetState(167) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } _la = p.GetTokenStream().LA(1) - for (int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&72192) != 0 { - p.SetState(170) + for (int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&73216) != 0 { + p.SetState(165) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } switch p.GetTokenStream().LA(1) { - case WystParserT__10: - { - p.SetState(166) - p.Power_keyword_call() - } - case WystParserIDENTIFIER: { - p.SetState(167) + p.SetState(160) p.Func_def() } case WystParserT__8: { - p.SetState(168) + p.SetState(161) p.Struct_def() } + case WystParserT__9: + { + p.SetState(162) + p.Namespace() + } + + case WystParserT__10: + { + p.SetState(163) + p.Import_statement() + } + case WystParserT__11: { - p.SetState(169) - p.Namespace() + p.SetState(164) + p.Use_statement() } default: @@ -3080,7 +3067,7 @@ func (p *WystParser) Top() (localctx ITopContext) { goto errorExit } - p.SetState(174) + p.SetState(169) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit diff --git a/src/transpiler.go b/src/transpiler.go index 6a8ae26..5909320 100644 --- a/src/transpiler.go +++ b/src/transpiler.go @@ -29,7 +29,7 @@ func TranspileToken(node ASTNode) string { res += fmt.Sprintf("%x", c) } } - res = strings.ReplaceAll(res, "::", "::_0x") + res = strings.ReplaceAll(res, "::", "._0x") case "HEX": res += node.Text case "MATH": @@ -40,6 +40,8 @@ func TranspileToken(node ASTNode) string { res += "\n " case "','": res += ", " + case "IDENT": + res += fmt.Sprintf("_%#x", node.Text) default: fmt.Printf("\x1b[33mDEV NOTICE:\x1b[0m Missing token case for '%s'\n", node.Rule) @@ -56,7 +58,11 @@ func TranspileNode(node ASTNode) string { switch node.Rule { case "func_def": - res += fmt.Sprintf("func %s%s %s %s", TranspileNode(node.Inner[1]), TranspileNode(node.Inner[2]), TranspileNode(node.Inner[0]), TranspileNode(node.Inner[3])) + return_type := TranspileNode(node.Inner[0]) + if return_type == "_0x766f6964" { + return_type = "" + } + res += fmt.Sprintf("func %s%s %s %s", TranspileNode(node.Inner[1]), TranspileNode(node.Inner[2]), return_type, TranspileNode(node.Inner[3])) case "expr": res += TranspileNodes(node.Inner) case "code_block": @@ -64,11 +70,7 @@ func TranspileNode(node ASTNode) string { case "var_def": res += fmt.Sprintf("var %s %s", TranspileNode(node.Inner[1]), TranspileNode(node.Inner[0])) case "round_def": - fmt.Sprintf("(%s)", strings.TrimSuffix(strings.ReplaceAll(TranspileNodes(node.Inner), "var ", ""), " ")) - case "power_keyword_call": - if node.Inner[0].Text == "map" && len(node.Inner) == 4 { - wyst_map = append(wyst_map, wmap{node.Inner[1].Text, node.Inner[2].Text}) - } + res += fmt.Sprintf("(%s)", strings.TrimSuffix(strings.ReplaceAll(TranspileNodes(node.Inner), "var ", ""), " ")) case "call_tree": for i, c := range node.Inner { res += TranspileNode(c) @@ -112,10 +114,20 @@ func TranspileNode(node ASTNode) string { } } res += fmt.Sprintf("var %s %s = %s{%s}", TranspileNode(node.Inner[0]), namespace_name, namespace_name, vals) - + case "var_def_set": res += fmt.Sprintf("%s = %s", TranspileNode(node.Inner[0]), TranspileNode(node.Inner[1])) + case "import_statement": + res += fmt.Sprintf("import . \"%s\"\n", TranspileNode(node.Inner[0])) + + case "use_statement": + ident := strings.Split(TranspileNode(node.Inner[0]), ".") + res += fmt.Sprintf("import \"%s\"\n", ident[0]) + if len(ident) > 1 { + res += fmt.Sprintf("var %s = %s\n", ident[len(ident)-1], strings.Join(ident, ".")) + } + default: fmt.Printf("\x1b[33mDEV NOTICE:\x1b[0m Missing case for '%s'\n", node.Rule) diff --git a/test/main.wst b/test/main.wst index a2d368d..a22d5ba 100644 --- a/test/main.wst +++ b/test/main.wst @@ -1,5 +1,5 @@ -#map _, _; +include io; -int main() { - int x = 20; +void main() { + } \ No newline at end of file