app and bug fixes
This commit is contained in:
+3
-1
@@ -26,4 +26,6 @@ go.work
|
||||
|
||||
.antlr/
|
||||
|
||||
test/
|
||||
test/
|
||||
|
||||
build/
|
||||
@@ -6,11 +6,10 @@ HEX: '0x' [a-fA-F0-9]*;
|
||||
IDENTIFIER: [a-zA-Z_] [a-zA-Z0-9_]* ('::' [a-zA-Z_] [a-zA-Z0-9_]*)*;
|
||||
GOIDENTIFIER: '^' [a-zA-Z_] [a-zA-Z0-9_]* ('.' [a-zA-Z_] [a-zA-Z0-9_]*)*;
|
||||
MATH: '+' | '-' | '*' | '/' | '==' | '!=' | '>=' | '<=';
|
||||
fragment ESC: '\\' ['"\\] ;
|
||||
STRING: '"' (ESC | ~["\\])* '"';
|
||||
fragment ESC: '\\' . ;
|
||||
STRING: ('"' (ESC | ~["\\])* '"') | ('\'' (ESC | ~["\\])* '\'') ;
|
||||
MODULE_NAME: [a-zA-Z_] [a-zA-Z0-9_]*;
|
||||
|
||||
|
||||
round_def: '(' (var_def (',' var_def)* ','?)? ')';
|
||||
enum_curly: '{' (var_def ';')* '}';
|
||||
round_call: '(' (expr (',' expr)* ','?)? ')';
|
||||
|
||||
@@ -7,5 +7,10 @@ toolchain go1.22.6
|
||||
require github.com/antlr4-go/antlr/v4 v4.13.1 // direct
|
||||
|
||||
require (
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
|
||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||
github.com/urfave/cli/v2 v2.27.4 // direct
|
||||
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
|
||||
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect
|
||||
|
||||
)
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
github.com/antlr4-go/antlr v0.0.0-20230518091524-98b52378c522 h1:o+W7GDFUwWtVkN28CW/nhh/aCmHn6OJddUs3+8vMMjs=
|
||||
github.com/antlr4-go/antlr v0.0.0-20230518091524-98b52378c522/go.mod h1:srLVvW4JLxy+tCG9Nn2l8al77mUIMCwAOLQocfLDU2w=
|
||||
github.com/antlr4-go/antlr/v4 v4.13.1 h1:SqQKkuVZ+zWkMMNkjy5FZe5mr5WURWnlpmOuzYWrPrQ=
|
||||
github.com/antlr4-go/antlr/v4 v4.13.1/go.mod h1:GKmUxMtwp6ZgGwZSva4eWPC5mS6vUAmOABFgjdkM7Nw=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/urfave/cli/v2 v2.27.4 h1:o1owoI+02Eb+K107p27wEX9Bb8eqIoZCfLXloLUSWJ8=
|
||||
github.com/urfave/cli/v2 v2.27.4/go.mod h1:m4QzxcD2qpra4z7WhzEGn74WZLViBnMpb1ToCAKdGRQ=
|
||||
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4=
|
||||
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM=
|
||||
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 h1:vr/HnozRka3pE4EsMEg1lgkXJkTFJCVUX+S/ZT6wYzM=
|
||||
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
|
||||
|
||||
File diff suppressed because one or more lines are too long
+62
-57
@@ -60,7 +60,7 @@ func wystlexerLexerInit() {
|
||||
}
|
||||
staticData.PredictionContextCache = antlr.NewPredictionContextCache()
|
||||
staticData.serializedATN = []int32{
|
||||
4, 0, 26, 227, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2,
|
||||
4, 0, 26, 237, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2,
|
||||
4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2,
|
||||
10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15,
|
||||
7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7,
|
||||
@@ -82,55 +82,56 @@ func wystlexerLexerInit() {
|
||||
22, 12, 22, 190, 9, 22, 5, 22, 192, 8, 22, 10, 22, 12, 22, 195, 9, 22,
|
||||
1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 3, 23, 206,
|
||||
8, 23, 1, 24, 1, 24, 1, 24, 1, 25, 1, 25, 1, 25, 5, 25, 214, 8, 25, 10,
|
||||
25, 12, 25, 217, 9, 25, 1, 25, 1, 25, 1, 26, 1, 26, 5, 26, 223, 8, 26,
|
||||
10, 26, 12, 26, 226, 9, 26, 0, 0, 27, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11,
|
||||
6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15,
|
||||
31, 16, 33, 17, 35, 18, 37, 19, 39, 20, 41, 21, 43, 22, 45, 23, 47, 24,
|
||||
49, 0, 51, 25, 53, 26, 1, 0, 9, 3, 0, 9, 10, 13, 13, 32, 32, 1, 0, 49,
|
||||
57, 1, 0, 48, 57, 3, 0, 48, 57, 65, 70, 97, 102, 3, 0, 65, 90, 95, 95,
|
||||
97, 122, 4, 0, 48, 57, 65, 90, 95, 95, 97, 122, 3, 0, 42, 43, 45, 45, 47,
|
||||
47, 3, 0, 34, 34, 39, 39, 92, 92, 2, 0, 34, 34, 92, 92, 242, 0, 1, 1, 0,
|
||||
0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0,
|
||||
0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1,
|
||||
0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25,
|
||||
1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0,
|
||||
33, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0,
|
||||
0, 41, 1, 0, 0, 0, 0, 43, 1, 0, 0, 0, 0, 45, 1, 0, 0, 0, 0, 47, 1, 0, 0,
|
||||
0, 0, 51, 1, 0, 0, 0, 0, 53, 1, 0, 0, 0, 1, 55, 1, 0, 0, 0, 3, 57, 1, 0,
|
||||
0, 0, 5, 59, 1, 0, 0, 0, 7, 61, 1, 0, 0, 0, 9, 63, 1, 0, 0, 0, 11, 65,
|
||||
1, 0, 0, 0, 13, 67, 1, 0, 0, 0, 15, 69, 1, 0, 0, 0, 17, 71, 1, 0, 0, 0,
|
||||
19, 78, 1, 0, 0, 0, 21, 88, 1, 0, 0, 0, 23, 96, 1, 0, 0, 0, 25, 100, 1,
|
||||
0, 0, 0, 27, 108, 1, 0, 0, 0, 29, 113, 1, 0, 0, 0, 31, 116, 1, 0, 0, 0,
|
||||
33, 119, 1, 0, 0, 0, 35, 122, 1, 0, 0, 0, 37, 128, 1, 0, 0, 0, 39, 142,
|
||||
1, 0, 0, 0, 41, 144, 1, 0, 0, 0, 43, 153, 1, 0, 0, 0, 45, 175, 1, 0, 0,
|
||||
0, 47, 205, 1, 0, 0, 0, 49, 207, 1, 0, 0, 0, 51, 210, 1, 0, 0, 0, 53, 220,
|
||||
1, 0, 0, 0, 55, 56, 5, 40, 0, 0, 56, 2, 1, 0, 0, 0, 57, 58, 5, 44, 0, 0,
|
||||
58, 4, 1, 0, 0, 0, 59, 60, 5, 41, 0, 0, 60, 6, 1, 0, 0, 0, 61, 62, 5, 123,
|
||||
0, 0, 62, 8, 1, 0, 0, 0, 63, 64, 5, 59, 0, 0, 64, 10, 1, 0, 0, 0, 65, 66,
|
||||
5, 125, 0, 0, 66, 12, 1, 0, 0, 0, 67, 68, 5, 61, 0, 0, 68, 14, 1, 0, 0,
|
||||
0, 69, 70, 5, 46, 0, 0, 70, 16, 1, 0, 0, 0, 71, 72, 5, 115, 0, 0, 72, 73,
|
||||
5, 116, 0, 0, 73, 74, 5, 114, 0, 0, 74, 75, 5, 117, 0, 0, 75, 76, 5, 99,
|
||||
0, 0, 76, 77, 5, 116, 0, 0, 77, 18, 1, 0, 0, 0, 78, 79, 5, 110, 0, 0, 79,
|
||||
80, 5, 97, 0, 0, 80, 81, 5, 109, 0, 0, 81, 82, 5, 101, 0, 0, 82, 83, 5,
|
||||
115, 0, 0, 83, 84, 5, 112, 0, 0, 84, 85, 5, 97, 0, 0, 85, 86, 5, 99, 0,
|
||||
0, 86, 87, 5, 101, 0, 0, 87, 20, 1, 0, 0, 0, 88, 89, 5, 105, 0, 0, 89,
|
||||
90, 5, 110, 0, 0, 90, 91, 5, 99, 0, 0, 91, 92, 5, 108, 0, 0, 92, 93, 5,
|
||||
117, 0, 0, 93, 94, 5, 100, 0, 0, 94, 95, 5, 101, 0, 0, 95, 22, 1, 0, 0,
|
||||
0, 96, 97, 5, 117, 0, 0, 97, 98, 5, 115, 0, 0, 98, 99, 5, 101, 0, 0, 99,
|
||||
24, 1, 0, 0, 0, 100, 101, 5, 37, 0, 0, 101, 102, 5, 105, 0, 0, 102, 103,
|
||||
5, 109, 0, 0, 103, 104, 5, 112, 0, 0, 104, 105, 5, 111, 0, 0, 105, 106,
|
||||
5, 114, 0, 0, 106, 107, 5, 116, 0, 0, 107, 26, 1, 0, 0, 0, 108, 109, 5,
|
||||
37, 0, 0, 109, 110, 5, 109, 0, 0, 110, 111, 5, 97, 0, 0, 111, 112, 5, 112,
|
||||
0, 0, 112, 28, 1, 0, 0, 0, 113, 114, 5, 38, 0, 0, 114, 115, 5, 38, 0, 0,
|
||||
115, 30, 1, 0, 0, 0, 116, 117, 5, 124, 0, 0, 117, 118, 5, 124, 0, 0, 118,
|
||||
32, 1, 0, 0, 0, 119, 120, 5, 105, 0, 0, 120, 121, 5, 102, 0, 0, 121, 34,
|
||||
1, 0, 0, 0, 122, 123, 5, 101, 0, 0, 123, 124, 5, 108, 0, 0, 124, 125, 5,
|
||||
115, 0, 0, 125, 126, 5, 101, 0, 0, 126, 36, 1, 0, 0, 0, 127, 129, 7, 0,
|
||||
0, 0, 128, 127, 1, 0, 0, 0, 129, 130, 1, 0, 0, 0, 130, 128, 1, 0, 0, 0,
|
||||
130, 131, 1, 0, 0, 0, 131, 132, 1, 0, 0, 0, 132, 133, 6, 18, 0, 0, 133,
|
||||
38, 1, 0, 0, 0, 134, 138, 7, 1, 0, 0, 135, 137, 7, 2, 0, 0, 136, 135, 1,
|
||||
0, 0, 0, 137, 140, 1, 0, 0, 0, 138, 136, 1, 0, 0, 0, 138, 139, 1, 0, 0,
|
||||
0, 139, 143, 1, 0, 0, 0, 140, 138, 1, 0, 0, 0, 141, 143, 5, 48, 0, 0, 142,
|
||||
25, 12, 25, 217, 9, 25, 1, 25, 1, 25, 1, 25, 1, 25, 5, 25, 223, 8, 25,
|
||||
10, 25, 12, 25, 226, 9, 25, 1, 25, 3, 25, 229, 8, 25, 1, 26, 1, 26, 5,
|
||||
26, 233, 8, 26, 10, 26, 12, 26, 236, 9, 26, 0, 0, 27, 1, 1, 3, 2, 5, 3,
|
||||
7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13,
|
||||
27, 14, 29, 15, 31, 16, 33, 17, 35, 18, 37, 19, 39, 20, 41, 21, 43, 22,
|
||||
45, 23, 47, 24, 49, 0, 51, 25, 53, 26, 1, 0, 8, 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, 2, 0, 34, 34, 92, 92, 255, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0,
|
||||
0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0,
|
||||
0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1,
|
||||
0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27,
|
||||
1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0,
|
||||
35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0, 0, 41, 1, 0, 0, 0,
|
||||
0, 43, 1, 0, 0, 0, 0, 45, 1, 0, 0, 0, 0, 47, 1, 0, 0, 0, 0, 51, 1, 0, 0,
|
||||
0, 0, 53, 1, 0, 0, 0, 1, 55, 1, 0, 0, 0, 3, 57, 1, 0, 0, 0, 5, 59, 1, 0,
|
||||
0, 0, 7, 61, 1, 0, 0, 0, 9, 63, 1, 0, 0, 0, 11, 65, 1, 0, 0, 0, 13, 67,
|
||||
1, 0, 0, 0, 15, 69, 1, 0, 0, 0, 17, 71, 1, 0, 0, 0, 19, 78, 1, 0, 0, 0,
|
||||
21, 88, 1, 0, 0, 0, 23, 96, 1, 0, 0, 0, 25, 100, 1, 0, 0, 0, 27, 108, 1,
|
||||
0, 0, 0, 29, 113, 1, 0, 0, 0, 31, 116, 1, 0, 0, 0, 33, 119, 1, 0, 0, 0,
|
||||
35, 122, 1, 0, 0, 0, 37, 128, 1, 0, 0, 0, 39, 142, 1, 0, 0, 0, 41, 144,
|
||||
1, 0, 0, 0, 43, 153, 1, 0, 0, 0, 45, 175, 1, 0, 0, 0, 47, 205, 1, 0, 0,
|
||||
0, 49, 207, 1, 0, 0, 0, 51, 228, 1, 0, 0, 0, 53, 230, 1, 0, 0, 0, 55, 56,
|
||||
5, 40, 0, 0, 56, 2, 1, 0, 0, 0, 57, 58, 5, 44, 0, 0, 58, 4, 1, 0, 0, 0,
|
||||
59, 60, 5, 41, 0, 0, 60, 6, 1, 0, 0, 0, 61, 62, 5, 123, 0, 0, 62, 8, 1,
|
||||
0, 0, 0, 63, 64, 5, 59, 0, 0, 64, 10, 1, 0, 0, 0, 65, 66, 5, 125, 0, 0,
|
||||
66, 12, 1, 0, 0, 0, 67, 68, 5, 61, 0, 0, 68, 14, 1, 0, 0, 0, 69, 70, 5,
|
||||
46, 0, 0, 70, 16, 1, 0, 0, 0, 71, 72, 5, 115, 0, 0, 72, 73, 5, 116, 0,
|
||||
0, 73, 74, 5, 114, 0, 0, 74, 75, 5, 117, 0, 0, 75, 76, 5, 99, 0, 0, 76,
|
||||
77, 5, 116, 0, 0, 77, 18, 1, 0, 0, 0, 78, 79, 5, 110, 0, 0, 79, 80, 5,
|
||||
97, 0, 0, 80, 81, 5, 109, 0, 0, 81, 82, 5, 101, 0, 0, 82, 83, 5, 115, 0,
|
||||
0, 83, 84, 5, 112, 0, 0, 84, 85, 5, 97, 0, 0, 85, 86, 5, 99, 0, 0, 86,
|
||||
87, 5, 101, 0, 0, 87, 20, 1, 0, 0, 0, 88, 89, 5, 105, 0, 0, 89, 90, 5,
|
||||
110, 0, 0, 90, 91, 5, 99, 0, 0, 91, 92, 5, 108, 0, 0, 92, 93, 5, 117, 0,
|
||||
0, 93, 94, 5, 100, 0, 0, 94, 95, 5, 101, 0, 0, 95, 22, 1, 0, 0, 0, 96,
|
||||
97, 5, 117, 0, 0, 97, 98, 5, 115, 0, 0, 98, 99, 5, 101, 0, 0, 99, 24, 1,
|
||||
0, 0, 0, 100, 101, 5, 37, 0, 0, 101, 102, 5, 105, 0, 0, 102, 103, 5, 109,
|
||||
0, 0, 103, 104, 5, 112, 0, 0, 104, 105, 5, 111, 0, 0, 105, 106, 5, 114,
|
||||
0, 0, 106, 107, 5, 116, 0, 0, 107, 26, 1, 0, 0, 0, 108, 109, 5, 37, 0,
|
||||
0, 109, 110, 5, 109, 0, 0, 110, 111, 5, 97, 0, 0, 111, 112, 5, 112, 0,
|
||||
0, 112, 28, 1, 0, 0, 0, 113, 114, 5, 38, 0, 0, 114, 115, 5, 38, 0, 0, 115,
|
||||
30, 1, 0, 0, 0, 116, 117, 5, 124, 0, 0, 117, 118, 5, 124, 0, 0, 118, 32,
|
||||
1, 0, 0, 0, 119, 120, 5, 105, 0, 0, 120, 121, 5, 102, 0, 0, 121, 34, 1,
|
||||
0, 0, 0, 122, 123, 5, 101, 0, 0, 123, 124, 5, 108, 0, 0, 124, 125, 5, 115,
|
||||
0, 0, 125, 126, 5, 101, 0, 0, 126, 36, 1, 0, 0, 0, 127, 129, 7, 0, 0, 0,
|
||||
128, 127, 1, 0, 0, 0, 129, 130, 1, 0, 0, 0, 130, 128, 1, 0, 0, 0, 130,
|
||||
131, 1, 0, 0, 0, 131, 132, 1, 0, 0, 0, 132, 133, 6, 18, 0, 0, 133, 38,
|
||||
1, 0, 0, 0, 134, 138, 7, 1, 0, 0, 135, 137, 7, 2, 0, 0, 136, 135, 1, 0,
|
||||
0, 0, 137, 140, 1, 0, 0, 0, 138, 136, 1, 0, 0, 0, 138, 139, 1, 0, 0, 0,
|
||||
139, 143, 1, 0, 0, 0, 140, 138, 1, 0, 0, 0, 141, 143, 5, 48, 0, 0, 142,
|
||||
134, 1, 0, 0, 0, 142, 141, 1, 0, 0, 0, 143, 40, 1, 0, 0, 0, 144, 145, 5,
|
||||
48, 0, 0, 145, 146, 5, 120, 0, 0, 146, 150, 1, 0, 0, 0, 147, 149, 7, 3,
|
||||
0, 0, 148, 147, 1, 0, 0, 0, 149, 152, 1, 0, 0, 0, 150, 148, 1, 0, 0, 0,
|
||||
@@ -155,14 +156,18 @@ func wystlexerLexerInit() {
|
||||
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,
|
||||
9, 0, 0, 0, 209, 50, 1, 0, 0, 0, 210, 215, 5, 34, 0, 0, 211, 214, 3, 49,
|
||||
24, 0, 212, 214, 8, 7, 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,
|
||||
218, 1, 0, 0, 0, 217, 215, 1, 0, 0, 0, 218, 229, 5, 34, 0, 0, 219, 224,
|
||||
5, 39, 0, 0, 220, 223, 3, 49, 24, 0, 221, 223, 8, 7, 0, 0, 222, 220, 1,
|
||||
0, 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, 227, 1, 0, 0, 0, 226, 224, 1, 0, 0, 0, 227,
|
||||
229, 5, 39, 0, 0, 228, 210, 1, 0, 0, 0, 228, 219, 1, 0, 0, 0, 229, 52,
|
||||
1, 0, 0, 0, 230, 234, 7, 4, 0, 0, 231, 233, 7, 5, 0, 0, 232, 231, 1, 0,
|
||||
0, 0, 233, 236, 1, 0, 0, 0, 234, 232, 1, 0, 0, 0, 234, 235, 1, 0, 0, 0,
|
||||
235, 54, 1, 0, 0, 0, 236, 234, 1, 0, 0, 0, 18, 0, 130, 138, 142, 150, 157,
|
||||
167, 172, 180, 188, 193, 205, 213, 215, 222, 224, 228, 234, 1, 6, 0, 0,
|
||||
}
|
||||
deserializer := antlr.NewATNDeserializer(nil)
|
||||
staticData.atn = deserializer.Deserialize(staticData.serializedATN)
|
||||
|
||||
+50
-2
@@ -1,6 +1,54 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
func main() {
|
||||
root := NewRoot("src/main.wyst")
|
||||
WriteRoot(root)
|
||||
app := &cli.App{
|
||||
Name: "Wyst",
|
||||
Version: "alpha_0.0.1",
|
||||
Authors: []*cli.Author{
|
||||
{Name: "Orus"},
|
||||
},
|
||||
Usage: "The wyst compiler",
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "output",
|
||||
Aliases: []string{"o"},
|
||||
Usage: "Specifies the output binary file name",
|
||||
},
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
if c.NArg() < 1 {
|
||||
return cli.Exit("Error: <file> argument is required.", 1)
|
||||
}
|
||||
file := c.Args().Get(0)
|
||||
if FileExists(file) {
|
||||
root := NewRoot(file)
|
||||
WriteRoot(root)
|
||||
cmd := exec.Command("go", "build", "-o", "../out", "./")
|
||||
cmd.Dir = "./build"
|
||||
|
||||
output, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
fmt.Println("Error:", err)
|
||||
}
|
||||
fmt.Println(string(output))
|
||||
// os.RemoveAll(OUT_FOLDER)
|
||||
} else {
|
||||
return cli.Exit(fmt.Sprintf("Error: file '%s' not found.", file), 1)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
err := app.Run(os.Args)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
+9
-5
@@ -35,7 +35,11 @@ func TranspileToken(node ASTNode) string {
|
||||
case "MATH":
|
||||
res += node.Text
|
||||
case "STRING":
|
||||
res += node.Text
|
||||
if strings.HasPrefix(node.Text, "'") {
|
||||
res += "\"" + strings.ReplaceAll(strings.TrimSuffix(strings.TrimPrefix(node.Text, "'"), "'"), "\\'", "'") + "\""
|
||||
} else {
|
||||
res += node.Text
|
||||
}
|
||||
case "';'":
|
||||
res += "\n "
|
||||
case "','":
|
||||
@@ -68,11 +72,11 @@ func (m *Module) TranspileNode(node ASTNode) string {
|
||||
case "expr":
|
||||
res += m.TranspileNodes(node.Inner)
|
||||
case "code_block":
|
||||
res += fmt.Sprintf("{\n %s}", strings.TrimSuffix(m.TranspileNodes(node.Inner), " "))
|
||||
res += fmt.Sprintf("{\n %s}", strings.TrimRight(m.TranspileNodes(node.Inner), " "))
|
||||
case "var_def":
|
||||
res += fmt.Sprintf("var %s %s", m.TranspileNode(node.Inner[1]), m.TranspileNode(node.Inner[0]))
|
||||
case "round_def":
|
||||
res += fmt.Sprintf("(%s)", strings.TrimSuffix(strings.ReplaceAll(m.TranspileNodes(node.Inner), "var ", ""), " "))
|
||||
res += fmt.Sprintf("(%s)", strings.TrimRight(strings.ReplaceAll(m.TranspileNodes(node.Inner), "var ", ""), " "))
|
||||
case "call_tree":
|
||||
for i, c := range node.Inner {
|
||||
res += m.TranspileNode(c)
|
||||
@@ -89,7 +93,7 @@ func (m *Module) TranspileNode(node ASTNode) string {
|
||||
res += fmt.Sprintf("type %s struct %s\n", m.TranspileNode(node.Inner[0]), m.TranspileNode(node.Inner[1]))
|
||||
|
||||
case "enum_curly":
|
||||
res += fmt.Sprintf("{\n %s}", strings.TrimSuffix(m.TranspileNodes(node.Inner), " "))
|
||||
res += fmt.Sprintf("{\n %s}", strings.TrimRight(m.TranspileNodes(node.Inner), " "))
|
||||
|
||||
case "namespace":
|
||||
namespace_name := "n" + m.TranspileNode(node.Inner[0])
|
||||
@@ -159,7 +163,7 @@ func (m *Module) TranspileNode(node ASTNode) string {
|
||||
case "else_statement":
|
||||
res += "else "
|
||||
res += m.TranspileNodes(node.Inner)
|
||||
|
||||
|
||||
case "elseif_statement":
|
||||
res += "else "
|
||||
res += m.TranspileNodes(node.Inner)
|
||||
|
||||
+2
-2
@@ -46,7 +46,7 @@ func NewRoot(file_path string) Module {
|
||||
root := Module{}
|
||||
|
||||
root.Path = file_path
|
||||
root.Out = OUT_FOLDER+"main.go"
|
||||
root.Out = OUT_FOLDER + "main.go"
|
||||
root.Name = "root"
|
||||
root.Code = root.Transpile(readFile(file_path))
|
||||
|
||||
@@ -77,6 +77,6 @@ func WriteModules(root Module) {
|
||||
|
||||
func WriteRoot(root Module) {
|
||||
writeFile(OUT_FOLDER+"main.go", "package main\n"+root.Code)
|
||||
writeFile(OUT_FOLDER+"go.mod", "module "+strings.ReplaceAll(OUT_FOLDER, "/", "")+"\n")
|
||||
writeFile(OUT_FOLDER+"go.mod", "module "+strings.ReplaceAll(OUT_FOLDER, "/", "")+"\n"+"go 1.22\ntoolchain go1.22.6")
|
||||
WriteModules(root)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user