fixed a few mod system bugs
This commit is contained in:
@@ -4,7 +4,8 @@ WS: [ \t\r\n]+ -> skip;
|
|||||||
NUMBER: [1-9][0-9]* | '0';
|
NUMBER: [1-9][0-9]* | '0';
|
||||||
HEX: '0x' [a-fA-F0-9]*;
|
HEX: '0x' [a-fA-F0-9]*;
|
||||||
IDENTIFIER: [a-zA-Z_] [a-zA-Z0-9_]* ('::' [a-zA-Z_] [a-zA-Z0-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: '\\' ['"\\] ;
|
fragment ESC: '\\' ['"\\] ;
|
||||||
STRING: '"' (ESC | ~["\\])* '"';
|
STRING: '"' (ESC | ~["\\])* '"';
|
||||||
MODULE_NAME: [a-zA-Z_] [a-zA-Z0-9_]*;
|
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)* '}';
|
namespace: 'namespace' IDENTIFIER '{' (((var_def|var_def_set) ';')|func_def)* '}';
|
||||||
import_statement: 'include' MODULE_NAME ';';
|
import_statement: 'include' MODULE_NAME ';';
|
||||||
use_statement: 'use' IDENTIFIER ';';
|
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:
|
expr:
|
||||||
(
|
(
|
||||||
@@ -29,19 +40,25 @@ expr:
|
|||||||
NUMBER |
|
NUMBER |
|
||||||
HEX |
|
HEX |
|
||||||
IDENTIFIER |
|
IDENTIFIER |
|
||||||
STRING
|
STRING |
|
||||||
|
go_call |
|
||||||
|
GOIDENTIFIER
|
||||||
) (MATH expr)*;
|
) (MATH expr)*;
|
||||||
|
|
||||||
code_block: '{' ((
|
code_block: '{' (((
|
||||||
expr |
|
expr |
|
||||||
var_def |
|
var_def |
|
||||||
var_def_set
|
var_def_set
|
||||||
) ';')* '}';
|
) ';') | (
|
||||||
|
if_tree
|
||||||
|
))* '}';
|
||||||
|
|
||||||
top: (
|
top: (
|
||||||
func_def |
|
func_def |
|
||||||
struct_def |
|
struct_def |
|
||||||
namespace |
|
namespace |
|
||||||
import_statement |
|
import_statement |
|
||||||
use_statement
|
use_statement |
|
||||||
|
go_import |
|
||||||
|
map
|
||||||
)*;
|
)*;
|
||||||
+25
-1
File diff suppressed because one or more lines are too long
+20
-6
@@ -10,12 +10,20 @@ T__8=9
|
|||||||
T__9=10
|
T__9=10
|
||||||
T__10=11
|
T__10=11
|
||||||
T__11=12
|
T__11=12
|
||||||
WS=13
|
T__12=13
|
||||||
NUMBER=14
|
T__13=14
|
||||||
HEX=15
|
T__14=15
|
||||||
IDENTIFIER=16
|
T__15=16
|
||||||
MATH=17
|
T__16=17
|
||||||
STRING=18
|
T__17=18
|
||||||
|
WS=19
|
||||||
|
NUMBER=20
|
||||||
|
HEX=21
|
||||||
|
IDENTIFIER=22
|
||||||
|
GOIDENTIFIER=23
|
||||||
|
MATH=24
|
||||||
|
STRING=25
|
||||||
|
MODULE_NAME=26
|
||||||
'('=1
|
'('=1
|
||||||
','=2
|
','=2
|
||||||
')'=3
|
')'=3
|
||||||
@@ -28,3 +36,9 @@ STRING=18
|
|||||||
'namespace'=10
|
'namespace'=10
|
||||||
'include'=11
|
'include'=11
|
||||||
'use'=12
|
'use'=12
|
||||||
|
'%import'=13
|
||||||
|
'%map'=14
|
||||||
|
'&&'=15
|
||||||
|
'||'=16
|
||||||
|
'if'=17
|
||||||
|
'else'=18
|
||||||
|
|||||||
+25
-1
File diff suppressed because one or more lines are too long
+20
-6
@@ -10,12 +10,20 @@ T__8=9
|
|||||||
T__9=10
|
T__9=10
|
||||||
T__10=11
|
T__10=11
|
||||||
T__11=12
|
T__11=12
|
||||||
WS=13
|
T__12=13
|
||||||
NUMBER=14
|
T__13=14
|
||||||
HEX=15
|
T__14=15
|
||||||
IDENTIFIER=16
|
T__15=16
|
||||||
MATH=17
|
T__16=17
|
||||||
STRING=18
|
T__17=18
|
||||||
|
WS=19
|
||||||
|
NUMBER=20
|
||||||
|
HEX=21
|
||||||
|
IDENTIFIER=22
|
||||||
|
GOIDENTIFIER=23
|
||||||
|
MATH=24
|
||||||
|
STRING=25
|
||||||
|
MODULE_NAME=26
|
||||||
'('=1
|
'('=1
|
||||||
','=2
|
','=2
|
||||||
')'=3
|
')'=3
|
||||||
@@ -28,3 +36,9 @@ STRING=18
|
|||||||
'namespace'=10
|
'namespace'=10
|
||||||
'include'=11
|
'include'=11
|
||||||
'use'=12
|
'use'=12
|
||||||
|
'%import'=13
|
||||||
|
'%map'=14
|
||||||
|
'&&'=15
|
||||||
|
'||'=16
|
||||||
|
'if'=17
|
||||||
|
'else'=18
|
||||||
|
|||||||
@@ -93,6 +93,54 @@ func (s *BaseWystListener) EnterUse_statement(ctx *Use_statementContext) {}
|
|||||||
// ExitUse_statement is called when production use_statement is exited.
|
// ExitUse_statement is called when production use_statement is exited.
|
||||||
func (s *BaseWystListener) ExitUse_statement(ctx *Use_statementContext) {}
|
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.
|
// EnterExpr is called when production expr is entered.
|
||||||
func (s *BaseWystListener) EnterExpr(ctx *ExprContext) {}
|
func (s *BaseWystListener) EnterExpr(ctx *ExprContext) {}
|
||||||
|
|
||||||
|
|||||||
+123
-75
@@ -44,85 +44,125 @@ func wystlexerLexerInit() {
|
|||||||
}
|
}
|
||||||
staticData.LiteralNames = []string{
|
staticData.LiteralNames = []string{
|
||||||
"", "'('", "','", "')'", "'{'", "';'", "'}'", "'='", "'.'", "'struct'",
|
"", "'('", "','", "')'", "'{'", "';'", "'}'", "'='", "'.'", "'struct'",
|
||||||
"'namespace'", "'include'", "'use'",
|
"'namespace'", "'include'", "'use'", "'%import'", "'%map'", "'&&'",
|
||||||
|
"'||'", "'if'", "'else'",
|
||||||
}
|
}
|
||||||
staticData.SymbolicNames = []string{
|
staticData.SymbolicNames = []string{
|
||||||
"", "", "", "", "", "", "", "", "", "", "", "", "", "WS", "NUMBER",
|
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
|
||||||
"HEX", "IDENTIFIER", "MATH", "STRING",
|
"", "", "WS", "NUMBER", "HEX", "IDENTIFIER", "GOIDENTIFIER", "MATH",
|
||||||
|
"STRING", "MODULE_NAME",
|
||||||
}
|
}
|
||||||
staticData.RuleNames = []string{
|
staticData.RuleNames = []string{
|
||||||
"T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8",
|
"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",
|
"T__9", "T__10", "T__11", "T__12", "T__13", "T__14", "T__15", "T__16",
|
||||||
"ESC", "STRING",
|
"T__17", "WS", "NUMBER", "HEX", "IDENTIFIER", "GOIDENTIFIER", "MATH",
|
||||||
|
"ESC", "STRING", "MODULE_NAME",
|
||||||
}
|
}
|
||||||
staticData.PredictionContextCache = antlr.NewPredictionContextCache()
|
staticData.PredictionContextCache = antlr.NewPredictionContextCache()
|
||||||
staticData.serializedATN = []int32{
|
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,
|
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,
|
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,
|
7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7,
|
||||||
1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 7, 1, 7,
|
20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25,
|
||||||
1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9,
|
2, 26, 7, 26, 1, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 1,
|
||||||
1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10,
|
4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1,
|
||||||
1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 11, 1, 12, 4, 12, 86, 8, 12, 11,
|
8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1,
|
||||||
12, 12, 12, 87, 1, 12, 1, 12, 1, 13, 1, 13, 5, 13, 94, 8, 13, 10, 13, 12,
|
10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11,
|
||||||
13, 97, 9, 13, 1, 13, 3, 13, 100, 8, 13, 1, 14, 1, 14, 1, 14, 1, 14, 5,
|
1, 11, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 13, 1,
|
||||||
14, 106, 8, 14, 10, 14, 12, 14, 109, 9, 14, 1, 15, 1, 15, 5, 15, 113, 8,
|
13, 1, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 15, 1, 16,
|
||||||
15, 10, 15, 12, 15, 116, 9, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 5, 15,
|
1, 16, 1, 16, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 18, 4, 18, 129, 8,
|
||||||
123, 8, 15, 10, 15, 12, 15, 126, 9, 15, 5, 15, 128, 8, 15, 10, 15, 12,
|
18, 11, 18, 12, 18, 130, 1, 18, 1, 18, 1, 19, 1, 19, 5, 19, 137, 8, 19,
|
||||||
15, 131, 9, 15, 1, 16, 1, 16, 1, 17, 1, 17, 1, 17, 1, 18, 1, 18, 1, 18,
|
10, 19, 12, 19, 140, 9, 19, 1, 19, 3, 19, 143, 8, 19, 1, 20, 1, 20, 1,
|
||||||
5, 18, 141, 8, 18, 10, 18, 12, 18, 144, 9, 18, 1, 18, 1, 18, 0, 0, 19,
|
20, 1, 20, 5, 20, 149, 8, 20, 10, 20, 12, 20, 152, 9, 20, 1, 21, 1, 21,
|
||||||
1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11,
|
5, 21, 156, 8, 21, 10, 21, 12, 21, 159, 9, 21, 1, 21, 1, 21, 1, 21, 1,
|
||||||
23, 12, 25, 13, 27, 14, 29, 15, 31, 16, 33, 17, 35, 0, 37, 18, 1, 0, 9,
|
21, 1, 21, 5, 21, 166, 8, 21, 10, 21, 12, 21, 169, 9, 21, 5, 21, 171, 8,
|
||||||
3, 0, 9, 10, 13, 13, 32, 32, 1, 0, 49, 57, 1, 0, 48, 57, 3, 0, 48, 57,
|
21, 10, 21, 12, 21, 174, 9, 21, 1, 22, 1, 22, 1, 22, 5, 22, 179, 8, 22,
|
||||||
65, 70, 97, 102, 3, 0, 65, 90, 95, 95, 97, 122, 4, 0, 48, 57, 65, 90, 95,
|
10, 22, 12, 22, 182, 9, 22, 1, 22, 1, 22, 1, 22, 5, 22, 187, 8, 22, 10,
|
||||||
95, 97, 122, 3, 0, 42, 43, 45, 45, 47, 47, 3, 0, 34, 34, 39, 39, 92, 92,
|
22, 12, 22, 190, 9, 22, 5, 22, 192, 8, 22, 10, 22, 12, 22, 195, 9, 22,
|
||||||
2, 0, 34, 34, 92, 92, 154, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1,
|
1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 3, 23, 206,
|
||||||
0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13,
|
8, 23, 1, 24, 1, 24, 1, 24, 1, 25, 1, 25, 1, 25, 5, 25, 214, 8, 25, 10,
|
||||||
1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0,
|
25, 12, 25, 217, 9, 25, 1, 25, 1, 25, 1, 26, 1, 26, 5, 26, 223, 8, 26,
|
||||||
21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0,
|
10, 26, 12, 26, 226, 9, 26, 0, 0, 27, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11,
|
||||||
0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 37, 1, 0, 0,
|
6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15,
|
||||||
0, 1, 39, 1, 0, 0, 0, 3, 41, 1, 0, 0, 0, 5, 43, 1, 0, 0, 0, 7, 45, 1, 0,
|
31, 16, 33, 17, 35, 18, 37, 19, 39, 20, 41, 21, 43, 22, 45, 23, 47, 24,
|
||||||
0, 0, 9, 47, 1, 0, 0, 0, 11, 49, 1, 0, 0, 0, 13, 51, 1, 0, 0, 0, 15, 53,
|
49, 0, 51, 25, 53, 26, 1, 0, 9, 3, 0, 9, 10, 13, 13, 32, 32, 1, 0, 49,
|
||||||
1, 0, 0, 0, 17, 55, 1, 0, 0, 0, 19, 62, 1, 0, 0, 0, 21, 72, 1, 0, 0, 0,
|
57, 1, 0, 48, 57, 3, 0, 48, 57, 65, 70, 97, 102, 3, 0, 65, 90, 95, 95,
|
||||||
23, 80, 1, 0, 0, 0, 25, 85, 1, 0, 0, 0, 27, 99, 1, 0, 0, 0, 29, 101, 1,
|
97, 122, 4, 0, 48, 57, 65, 90, 95, 95, 97, 122, 3, 0, 42, 43, 45, 45, 47,
|
||||||
0, 0, 0, 31, 110, 1, 0, 0, 0, 33, 132, 1, 0, 0, 0, 35, 134, 1, 0, 0, 0,
|
47, 3, 0, 34, 34, 39, 39, 92, 92, 2, 0, 34, 34, 92, 92, 242, 0, 1, 1, 0,
|
||||||
37, 137, 1, 0, 0, 0, 39, 40, 5, 40, 0, 0, 40, 2, 1, 0, 0, 0, 41, 42, 5,
|
0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0,
|
||||||
44, 0, 0, 42, 4, 1, 0, 0, 0, 43, 44, 5, 41, 0, 0, 44, 6, 1, 0, 0, 0, 45,
|
0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1,
|
||||||
46, 5, 123, 0, 0, 46, 8, 1, 0, 0, 0, 47, 48, 5, 59, 0, 0, 48, 10, 1, 0,
|
0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25,
|
||||||
0, 0, 49, 50, 5, 125, 0, 0, 50, 12, 1, 0, 0, 0, 51, 52, 5, 61, 0, 0, 52,
|
1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0,
|
||||||
14, 1, 0, 0, 0, 53, 54, 5, 46, 0, 0, 54, 16, 1, 0, 0, 0, 55, 56, 5, 115,
|
33, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0,
|
||||||
0, 0, 56, 57, 5, 116, 0, 0, 57, 58, 5, 114, 0, 0, 58, 59, 5, 117, 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,
|
||||||
59, 60, 5, 99, 0, 0, 60, 61, 5, 116, 0, 0, 61, 18, 1, 0, 0, 0, 62, 63,
|
0, 0, 51, 1, 0, 0, 0, 0, 53, 1, 0, 0, 0, 1, 55, 1, 0, 0, 0, 3, 57, 1, 0,
|
||||||
5, 110, 0, 0, 63, 64, 5, 97, 0, 0, 64, 65, 5, 109, 0, 0, 65, 66, 5, 101,
|
0, 0, 5, 59, 1, 0, 0, 0, 7, 61, 1, 0, 0, 0, 9, 63, 1, 0, 0, 0, 11, 65,
|
||||||
0, 0, 66, 67, 5, 115, 0, 0, 67, 68, 5, 112, 0, 0, 68, 69, 5, 97, 0, 0,
|
1, 0, 0, 0, 13, 67, 1, 0, 0, 0, 15, 69, 1, 0, 0, 0, 17, 71, 1, 0, 0, 0,
|
||||||
69, 70, 5, 99, 0, 0, 70, 71, 5, 101, 0, 0, 71, 20, 1, 0, 0, 0, 72, 73,
|
19, 78, 1, 0, 0, 0, 21, 88, 1, 0, 0, 0, 23, 96, 1, 0, 0, 0, 25, 100, 1,
|
||||||
5, 105, 0, 0, 73, 74, 5, 110, 0, 0, 74, 75, 5, 99, 0, 0, 75, 76, 5, 108,
|
0, 0, 0, 27, 108, 1, 0, 0, 0, 29, 113, 1, 0, 0, 0, 31, 116, 1, 0, 0, 0,
|
||||||
0, 0, 76, 77, 5, 117, 0, 0, 77, 78, 5, 100, 0, 0, 78, 79, 5, 101, 0, 0,
|
33, 119, 1, 0, 0, 0, 35, 122, 1, 0, 0, 0, 37, 128, 1, 0, 0, 0, 39, 142,
|
||||||
79, 22, 1, 0, 0, 0, 80, 81, 5, 117, 0, 0, 81, 82, 5, 115, 0, 0, 82, 83,
|
1, 0, 0, 0, 41, 144, 1, 0, 0, 0, 43, 153, 1, 0, 0, 0, 45, 175, 1, 0, 0,
|
||||||
5, 101, 0, 0, 83, 24, 1, 0, 0, 0, 84, 86, 7, 0, 0, 0, 85, 84, 1, 0, 0,
|
0, 47, 205, 1, 0, 0, 0, 49, 207, 1, 0, 0, 0, 51, 210, 1, 0, 0, 0, 53, 220,
|
||||||
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, 55, 56, 5, 40, 0, 0, 56, 2, 1, 0, 0, 0, 57, 58, 5, 44, 0, 0,
|
||||||
1, 0, 0, 0, 89, 90, 6, 12, 0, 0, 90, 26, 1, 0, 0, 0, 91, 95, 7, 1, 0, 0,
|
58, 4, 1, 0, 0, 0, 59, 60, 5, 41, 0, 0, 60, 6, 1, 0, 0, 0, 61, 62, 5, 123,
|
||||||
92, 94, 7, 2, 0, 0, 93, 92, 1, 0, 0, 0, 94, 97, 1, 0, 0, 0, 95, 93, 1,
|
0, 0, 62, 8, 1, 0, 0, 0, 63, 64, 5, 59, 0, 0, 64, 10, 1, 0, 0, 0, 65, 66,
|
||||||
0, 0, 0, 95, 96, 1, 0, 0, 0, 96, 100, 1, 0, 0, 0, 97, 95, 1, 0, 0, 0, 98,
|
5, 125, 0, 0, 66, 12, 1, 0, 0, 0, 67, 68, 5, 61, 0, 0, 68, 14, 1, 0, 0,
|
||||||
100, 5, 48, 0, 0, 99, 91, 1, 0, 0, 0, 99, 98, 1, 0, 0, 0, 100, 28, 1, 0,
|
0, 69, 70, 5, 46, 0, 0, 70, 16, 1, 0, 0, 0, 71, 72, 5, 115, 0, 0, 72, 73,
|
||||||
0, 0, 101, 102, 5, 48, 0, 0, 102, 103, 5, 120, 0, 0, 103, 107, 1, 0, 0,
|
5, 116, 0, 0, 73, 74, 5, 114, 0, 0, 74, 75, 5, 117, 0, 0, 75, 76, 5, 99,
|
||||||
0, 104, 106, 7, 3, 0, 0, 105, 104, 1, 0, 0, 0, 106, 109, 1, 0, 0, 0, 107,
|
0, 0, 76, 77, 5, 116, 0, 0, 77, 18, 1, 0, 0, 0, 78, 79, 5, 110, 0, 0, 79,
|
||||||
105, 1, 0, 0, 0, 107, 108, 1, 0, 0, 0, 108, 30, 1, 0, 0, 0, 109, 107, 1,
|
80, 5, 97, 0, 0, 80, 81, 5, 109, 0, 0, 81, 82, 5, 101, 0, 0, 82, 83, 5,
|
||||||
0, 0, 0, 110, 114, 7, 4, 0, 0, 111, 113, 7, 5, 0, 0, 112, 111, 1, 0, 0,
|
115, 0, 0, 83, 84, 5, 112, 0, 0, 84, 85, 5, 97, 0, 0, 85, 86, 5, 99, 0,
|
||||||
0, 113, 116, 1, 0, 0, 0, 114, 112, 1, 0, 0, 0, 114, 115, 1, 0, 0, 0, 115,
|
0, 86, 87, 5, 101, 0, 0, 87, 20, 1, 0, 0, 0, 88, 89, 5, 105, 0, 0, 89,
|
||||||
129, 1, 0, 0, 0, 116, 114, 1, 0, 0, 0, 117, 118, 5, 58, 0, 0, 118, 119,
|
90, 5, 110, 0, 0, 90, 91, 5, 99, 0, 0, 91, 92, 5, 108, 0, 0, 92, 93, 5,
|
||||||
5, 58, 0, 0, 119, 120, 1, 0, 0, 0, 120, 124, 7, 4, 0, 0, 121, 123, 7, 5,
|
117, 0, 0, 93, 94, 5, 100, 0, 0, 94, 95, 5, 101, 0, 0, 95, 22, 1, 0, 0,
|
||||||
0, 0, 122, 121, 1, 0, 0, 0, 123, 126, 1, 0, 0, 0, 124, 122, 1, 0, 0, 0,
|
0, 96, 97, 5, 117, 0, 0, 97, 98, 5, 115, 0, 0, 98, 99, 5, 101, 0, 0, 99,
|
||||||
124, 125, 1, 0, 0, 0, 125, 128, 1, 0, 0, 0, 126, 124, 1, 0, 0, 0, 127,
|
24, 1, 0, 0, 0, 100, 101, 5, 37, 0, 0, 101, 102, 5, 105, 0, 0, 102, 103,
|
||||||
117, 1, 0, 0, 0, 128, 131, 1, 0, 0, 0, 129, 127, 1, 0, 0, 0, 129, 130,
|
5, 109, 0, 0, 103, 104, 5, 112, 0, 0, 104, 105, 5, 111, 0, 0, 105, 106,
|
||||||
1, 0, 0, 0, 130, 32, 1, 0, 0, 0, 131, 129, 1, 0, 0, 0, 132, 133, 7, 6,
|
5, 114, 0, 0, 106, 107, 5, 116, 0, 0, 107, 26, 1, 0, 0, 0, 108, 109, 5,
|
||||||
0, 0, 133, 34, 1, 0, 0, 0, 134, 135, 5, 92, 0, 0, 135, 136, 7, 7, 0, 0,
|
37, 0, 0, 109, 110, 5, 109, 0, 0, 110, 111, 5, 97, 0, 0, 111, 112, 5, 112,
|
||||||
136, 36, 1, 0, 0, 0, 137, 142, 5, 34, 0, 0, 138, 141, 3, 35, 17, 0, 139,
|
0, 0, 112, 28, 1, 0, 0, 0, 113, 114, 5, 38, 0, 0, 114, 115, 5, 38, 0, 0,
|
||||||
141, 8, 8, 0, 0, 140, 138, 1, 0, 0, 0, 140, 139, 1, 0, 0, 0, 141, 144,
|
115, 30, 1, 0, 0, 0, 116, 117, 5, 124, 0, 0, 117, 118, 5, 124, 0, 0, 118,
|
||||||
1, 0, 0, 0, 142, 140, 1, 0, 0, 0, 142, 143, 1, 0, 0, 0, 143, 145, 1, 0,
|
32, 1, 0, 0, 0, 119, 120, 5, 105, 0, 0, 120, 121, 5, 102, 0, 0, 121, 34,
|
||||||
0, 0, 144, 142, 1, 0, 0, 0, 145, 146, 5, 34, 0, 0, 146, 38, 1, 0, 0, 0,
|
1, 0, 0, 0, 122, 123, 5, 101, 0, 0, 123, 124, 5, 108, 0, 0, 124, 125, 5,
|
||||||
10, 0, 87, 95, 99, 107, 114, 124, 129, 140, 142, 1, 6, 0, 0,
|
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)
|
deserializer := antlr.NewATNDeserializer(nil)
|
||||||
staticData.atn = deserializer.Deserialize(staticData.serializedATN)
|
staticData.atn = deserializer.Deserialize(staticData.serializedATN)
|
||||||
@@ -175,10 +215,18 @@ const (
|
|||||||
WystLexerT__9 = 10
|
WystLexerT__9 = 10
|
||||||
WystLexerT__10 = 11
|
WystLexerT__10 = 11
|
||||||
WystLexerT__11 = 12
|
WystLexerT__11 = 12
|
||||||
WystLexerWS = 13
|
WystLexerT__12 = 13
|
||||||
WystLexerNUMBER = 14
|
WystLexerT__13 = 14
|
||||||
WystLexerHEX = 15
|
WystLexerT__14 = 15
|
||||||
WystLexerIDENTIFIER = 16
|
WystLexerT__15 = 16
|
||||||
WystLexerMATH = 17
|
WystLexerT__16 = 17
|
||||||
WystLexerSTRING = 18
|
WystLexerT__17 = 18
|
||||||
|
WystLexerWS = 19
|
||||||
|
WystLexerNUMBER = 20
|
||||||
|
WystLexerHEX = 21
|
||||||
|
WystLexerIDENTIFIER = 22
|
||||||
|
WystLexerGOIDENTIFIER = 23
|
||||||
|
WystLexerMATH = 24
|
||||||
|
WystLexerSTRING = 25
|
||||||
|
WystLexerMODULE_NAME = 26
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -44,6 +44,30 @@ type WystListener interface {
|
|||||||
// EnterUse_statement is called when entering the use_statement production.
|
// EnterUse_statement is called when entering the use_statement production.
|
||||||
EnterUse_statement(c *Use_statementContext)
|
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 is called when entering the expr production.
|
||||||
EnterExpr(c *ExprContext)
|
EnterExpr(c *ExprContext)
|
||||||
|
|
||||||
@@ -89,6 +113,30 @@ type WystListener interface {
|
|||||||
// ExitUse_statement is called when exiting the use_statement production.
|
// ExitUse_statement is called when exiting the use_statement production.
|
||||||
ExitUse_statement(c *Use_statementContext)
|
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 is called when exiting the expr production.
|
||||||
ExitExpr(c *ExprContext)
|
ExitExpr(c *ExprContext)
|
||||||
|
|
||||||
|
|||||||
+1638
-193
File diff suppressed because it is too large
Load Diff
+38
-8
@@ -7,7 +7,7 @@ import (
|
|||||||
|
|
||||||
type wmap [2]string
|
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 {
|
func TranspileToken(node ASTNode) string {
|
||||||
res := ""
|
res := ""
|
||||||
@@ -42,6 +42,8 @@ func TranspileToken(node ASTNode) string {
|
|||||||
res += ", "
|
res += ", "
|
||||||
case "IDENT":
|
case "IDENT":
|
||||||
res += fmt.Sprintf("_%#x", node.Text)
|
res += fmt.Sprintf("_%#x", node.Text)
|
||||||
|
case "GOIDENTIFIER":
|
||||||
|
res += strings.TrimPrefix(node.Text, "^")
|
||||||
default:
|
default:
|
||||||
fmt.Printf("\x1b[33mDEV NOTICE:\x1b[0m Missing token case for '%s'\n", node.Rule)
|
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[0])
|
||||||
res += m.TranspileNode(node.Inner[1])
|
res += m.TranspileNode(node.Inner[1])
|
||||||
|
|
||||||
case "round_call":
|
|
||||||
res += fmt.Sprintf("(%s)", m.TranspileNodes(node.Inner))
|
|
||||||
|
|
||||||
case "struct_def":
|
case "struct_def":
|
||||||
res += fmt.Sprintf("type %s struct %s\n", m.TranspileNode(node.Inner[0]), m.TranspileNode(node.Inner[1]))
|
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))
|
res += fmt.Sprintf("import . \"%s\"\n", m.ImportModule(node.Inner[0].Text))
|
||||||
|
|
||||||
case "use_statement":
|
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])
|
modname := m.ImportModule(ident[0])
|
||||||
m := strings.Split(modname, "/")
|
md := strings.Split(modname, "/")
|
||||||
res += fmt.Sprintf("import %s \"%s\"\n", m[len(m)-1], modname)
|
res += fmt.Sprintf("import %s \"%s\"\n", md[len(md)-1], modname)
|
||||||
if len(ident) > 1 {
|
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:
|
default:
|
||||||
fmt.Printf("\x1b[33mDEV NOTICE:\x1b[0m Missing case for '%s'\n", node.Rule)
|
fmt.Printf("\x1b[33mDEV NOTICE:\x1b[0m Missing case for '%s'\n", node.Rule)
|
||||||
|
|
||||||
|
|||||||
+11
-9
@@ -4,8 +4,11 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const OUT_FOLDER = "build/"
|
||||||
|
|
||||||
func FileExists(filename string) bool {
|
func FileExists(filename string) bool {
|
||||||
_, err := os.Stat(filename)
|
_, err := os.Stat(filename)
|
||||||
return err == nil || !os.IsNotExist(err)
|
return err == nil || !os.IsNotExist(err)
|
||||||
@@ -43,7 +46,7 @@ func NewRoot(file_path string) Module {
|
|||||||
root := Module{}
|
root := Module{}
|
||||||
|
|
||||||
root.Path = file_path
|
root.Path = file_path
|
||||||
root.Out = "out/main.go"
|
root.Out = OUT_FOLDER+"main.go"
|
||||||
root.Name = "root"
|
root.Name = "root"
|
||||||
root.Code = root.Transpile(readFile(file_path))
|
root.Code = root.Transpile(readFile(file_path))
|
||||||
|
|
||||||
@@ -53,16 +56,15 @@ func NewRoot(file_path string) Module {
|
|||||||
func (root *Module) ImportModule(modname string) string {
|
func (root *Module) ImportModule(modname string) string {
|
||||||
module := Module{Name: modname}
|
module := Module{Name: modname}
|
||||||
module.Path = path.Join(path.Dir(root.Path), module.Name+".wyst")
|
module.Path = path.Join(path.Dir(root.Path), module.Name+".wyst")
|
||||||
if FileExists(module.Path) {
|
if !FileExists(module.Path) {
|
||||||
module.Code = "package " + fmt.Sprintf("_%#x", modname) + "\n" + module.Transpile(readFile(module.Path))
|
|
||||||
} else {
|
|
||||||
module.Path = path.Join(path.Dir(root.Path), module.Name, "mod.wyst")
|
module.Path = path.Join(path.Dir(root.Path), module.Name, "mod.wyst")
|
||||||
|
}
|
||||||
|
|
||||||
if FileExists(module.Path) {
|
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)
|
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)
|
root.Inner = append(root.Inner, module)
|
||||||
|
}
|
||||||
return fmt.Sprintf("%s/I%#x", path.Dir(root.Out), module.Name)
|
return fmt.Sprintf("%s/I%#x", path.Dir(root.Out), module.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,7 +76,7 @@ func WriteModules(root Module) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func WriteRoot(root Module) {
|
func WriteRoot(root Module) {
|
||||||
writeFile("out/main.go", "package main\n"+root.Code)
|
writeFile(OUT_FOLDER+"main.go", "package main\n"+root.Code)
|
||||||
writeFile("out/go.mod", "module out\n")
|
writeFile(OUT_FOLDER+"go.mod", "module "+strings.ReplaceAll(OUT_FOLDER, "/", "")+"\n")
|
||||||
WriteModules(root)
|
WriteModules(root)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user