Browse Source

Renamed BPF ANTLR module to Assembler

maze 5 months ago
parent
commit
d833dee66c

+ 2
- 2
.gitignore View File

@@ -19,5 +19,5 @@
19 19
 .idea/
20 20
 
21 21
 # Antlr artifacts
22
-parser/*.interp
23
-parser/*.tokens
22
+*.interp
23
+*.tokens

+ 13
- 0
Makefile View File

@@ -0,0 +1,13 @@
1
+all: build
2
+
3
+build: build-linux build-darwin build-windows
4
+
5
+build-linux:
6
+	GOOS=linux GOARCH=amd64 go build -v -o build/bpfasm
7
+
8
+build-darwin:
9
+	GOOS=darwin GOARCH=amd64 go build -v -o build/bpfasm-darwin
10
+
11
+build-windows:
12
+	GOOS=windows GOARCH=amd64 go build -v -o build/bpfasm.exe
13
+ 	GOOS=windows GOARCH=386 go build -v -o build/bpfasm-x86.exe

+ 3
- 3
assembler.go View File

@@ -1,4 +1,4 @@
1
-//go:generate antlr -package parser -Dlanguage=Go -visitor parser/BPF.g4
1
+//go:generate antlr -package parser -Dlanguage=Go -visitor internal/parser/Assembler.g4
2 2
 
3 3
 // Copyright (c) 2019 Wijnand Modderman-Lenstra. All rights reserved.
4 4
 // Use of this source code is governed by a BSD-style
@@ -27,9 +27,9 @@ func (p Program) Assemble() ([]bpf.RawInstruction, error) {
27 27
 func Assemble(source string) (Program, error) {
28 28
 	var (
29 29
 		input  = antlr.NewInputStream(source)
30
-		lexer  = parser.NewBPFLexer(input)
30
+		lexer  = parser.NewAssemblerLexer(input)
31 31
 		stream = antlr.NewCommonTokenStream(lexer, 0)
32
-		parse  = parser.NewBPFParser(stream)
32
+		parse  = parser.NewAssemblerParser(stream)
33 33
 	)
34 34
 	parse.BuildParseTrees = true
35 35
 

internal/parser/BPF.g4 → internal/parser/Assembler.g4 View File

@@ -1,4 +1,4 @@
1
-grammar BPF;
1
+grammar Assembler;
2 2
 
3 3
 program
4 4
 	: (labelDefinition | labelDefinition? instruction)+ EOF

+ 0
- 122
internal/parser/BPF.interp View File

@@ -1,122 +0,0 @@
1
-token literal names:
2
-null
3
-':'
4
-','
5
-'#'
6
-'['
7
-'x'
8
-'+'
9
-']'
10
-'r'
11
-null
12
-null
13
-null
14
-null
15
-null
16
-null
17
-null
18
-null
19
-null
20
-null
21
-null
22
-null
23
-null
24
-null
25
-null
26
-null
27
-null
28
-null
29
-null
30
-null
31
-null
32
-null
33
-null
34
-null
35
-null
36
-null
37
-null
38
-null
39
-null
40
-null
41
-null
42
-null
43
-null
44
-null
45
-
46
-token symbolic names:
47
-null
48
-null
49
-null
50
-null
51
-null
52
-null
53
-null
54
-null
55
-null
56
-ADD
57
-SUB
58
-MUL
59
-DIV
60
-MOD
61
-AND
62
-OR
63
-XOR
64
-LSH
65
-RSH
66
-JA
67
-JEQ
68
-JNE
69
-JLT
70
-JLE
71
-JGT
72
-JGE
73
-JSE
74
-LDA
75
-LDX
76
-LDB
77
-LDH
78
-STA
79
-STX
80
-TAX
81
-TXA
82
-NEG
83
-RET
84
-NUMBER
85
-COMMENT
86
-IDENTIFIER
87
-WHITESPACE
88
-REGA
89
-REGX
90
-
91
-rule names:
92
-program
93
-labelDefinition
94
-label
95
-comment
96
-instruction
97
-aluOperation
98
-aluOperator
99
-jumpOperation
100
-jumpOperator
101
-jumpConditionalOperation
102
-jumpConditionalOperator
103
-ifTrue
104
-ifFalse
105
-loadOperation
106
-loadOperator
107
-storeOperation
108
-storeOperator
109
-simpleOperation
110
-returnOperation
111
-number
112
-literalNumber
113
-indirectX
114
-absoluteNumber
115
-registerA
116
-registerX
117
-registerR
118
-extension
119
-
120
-
121
-atn:
122
-[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 44, 162, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23, 9, 23, 4, 24, 9, 24, 4, 25, 9, 25, 4, 26, 9, 26, 4, 27, 9, 27, 4, 28, 9, 28, 3, 2, 3, 2, 5, 2, 59, 10, 2, 3, 2, 6, 2, 62, 10, 2, 13, 2, 14, 2, 63, 3, 2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 4, 3, 4, 3, 5, 3, 5, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 5, 6, 82, 10, 6, 3, 7, 3, 7, 3, 7, 5, 7, 87, 10, 7, 3, 8, 3, 8, 3, 9, 3, 9, 3, 9, 3, 10, 3, 10, 3, 11, 3, 11, 3, 11, 5, 11, 99, 10, 11, 3, 11, 3, 11, 3, 11, 3, 11, 5, 11, 105, 10, 11, 3, 12, 3, 12, 3, 13, 3, 13, 5, 13, 111, 10, 13, 3, 14, 3, 14, 5, 14, 115, 10, 14, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 5, 15, 122, 10, 15, 3, 16, 3, 16, 3, 17, 3, 17, 3, 17, 3, 18, 3, 18, 3, 19, 3, 19, 3, 20, 3, 20, 3, 20, 5, 20, 136, 10, 20, 3, 21, 3, 21, 3, 22, 3, 22, 3, 22, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 24, 3, 24, 3, 24, 3, 24, 3, 25, 3, 25, 3, 26, 3, 26, 3, 27, 3, 27, 3, 27, 3, 28, 3, 28, 3, 28, 2, 2, 29, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 2, 7, 3, 2, 11, 20, 3, 2, 22, 28, 3, 2, 29, 32, 3, 2, 33, 34, 3, 2, 35, 37, 2, 152, 2, 61, 3, 2, 2, 2, 4, 67, 3, 2, 2, 2, 6, 70, 3, 2, 2, 2, 8, 72, 3, 2, 2, 2, 10, 81, 3, 2, 2, 2, 12, 83, 3, 2, 2, 2, 14, 88, 3, 2, 2, 2, 16, 90, 3, 2, 2, 2, 18, 93, 3, 2, 2, 2, 20, 95, 3, 2, 2, 2, 22, 106, 3, 2, 2, 2, 24, 110, 3, 2, 2, 2, 26, 114, 3, 2, 2, 2, 28, 116, 3, 2, 2, 2, 30, 123, 3, 2, 2, 2, 32, 125, 3, 2, 2, 2, 34, 128, 3, 2, 2, 2, 36, 130, 3, 2, 2, 2, 38, 132, 3, 2, 2, 2, 40, 137, 3, 2, 2, 2, 42, 139, 3, 2, 2, 2, 44, 142, 3, 2, 2, 2, 46, 148, 3, 2, 2, 2, 48, 152, 3, 2, 2, 2, 50, 154, 3, 2, 2, 2, 52, 156, 3, 2, 2, 2, 54, 159, 3, 2, 2, 2, 56, 62, 5, 4, 3, 2, 57, 59, 5, 4, 3, 2, 58, 57, 3, 2, 2, 2, 58, 59, 3, 2, 2, 2, 59, 60, 3, 2, 2, 2, 60, 62, 5, 10, 6, 2, 61, 56, 3, 2, 2, 2, 61, 58, 3, 2, 2, 2, 62, 63, 3, 2, 2, 2, 63, 61, 3, 2, 2, 2, 63, 64, 3, 2, 2, 2, 64, 65, 3, 2, 2, 2, 65, 66, 7, 2, 2, 3, 66, 3, 3, 2, 2, 2, 67, 68, 7, 41, 2, 2, 68, 69, 7, 3, 2, 2, 69, 5, 3, 2, 2, 2, 70, 71, 7, 41, 2, 2, 71, 7, 3, 2, 2, 2, 72, 73, 7, 40, 2, 2, 73, 9, 3, 2, 2, 2, 74, 82, 5, 12, 7, 2, 75, 82, 5, 16, 9, 2, 76, 82, 5, 20, 11, 2, 77, 82, 5, 28, 15, 2, 78, 82, 5, 32, 17, 2, 79, 82, 5, 36, 19, 2, 80, 82, 5, 38, 20, 2, 81, 74, 3, 2, 2, 2, 81, 75, 3, 2, 2, 2, 81, 76, 3, 2, 2, 2, 81, 77, 3, 2, 2, 2, 81, 78, 3, 2, 2, 2, 81, 79, 3, 2, 2, 2, 81, 80, 3, 2, 2, 2, 82, 11, 3, 2, 2, 2, 83, 86, 5, 14, 8, 2, 84, 87, 5, 42, 22, 2, 85, 87, 5, 50, 26, 2, 86, 84, 3, 2, 2, 2, 86, 85, 3, 2, 2, 2, 87, 13, 3, 2, 2, 2, 88, 89, 9, 2, 2, 2, 89, 15, 3, 2, 2, 2, 90, 91, 5, 18, 10, 2, 91, 92, 5, 40, 21, 2, 92, 17, 3, 2, 2, 2, 93, 94, 7, 21, 2, 2, 94, 19, 3, 2, 2, 2, 95, 98, 5, 22, 12, 2, 96, 99, 5, 42, 22, 2, 97, 99, 5, 50, 26, 2, 98, 96, 3, 2, 2, 2, 98, 97, 3, 2, 2, 2, 99, 100, 3, 2, 2, 2, 100, 101, 7, 4, 2, 2, 101, 104, 5, 24, 13, 2, 102, 103, 7, 4, 2, 2, 103, 105, 5, 26, 14, 2, 104, 102, 3, 2, 2, 2, 104, 105, 3, 2, 2, 2, 105, 21, 3, 2, 2, 2, 106, 107, 9, 3, 2, 2, 107, 23, 3, 2, 2, 2, 108, 111, 5, 40, 21, 2, 109, 111, 5, 6, 4, 2, 110, 108, 3, 2, 2, 2, 110, 109, 3, 2, 2, 2, 111, 25, 3, 2, 2, 2, 112, 115, 5, 40, 21, 2, 113, 115, 5, 6, 4, 2, 114, 112, 3, 2, 2, 2, 114, 113, 3, 2, 2, 2, 115, 27, 3, 2, 2, 2, 116, 121, 5, 30, 16, 2, 117, 122, 5, 44, 23, 2, 118, 122, 5, 46, 24, 2, 119, 122, 5, 52, 27, 2, 120, 122, 5, 54, 28, 2, 121, 117, 3, 2, 2, 2, 121, 118, 3, 2, 2, 2, 121, 119, 3, 2, 2, 2, 121, 120, 3, 2, 2, 2, 122, 29, 3, 2, 2, 2, 123, 124, 9, 4, 2, 2, 124, 31, 3, 2, 2, 2, 125, 126, 5, 34, 18, 2, 126, 127, 5, 52, 27, 2, 127, 33, 3, 2, 2, 2, 128, 129, 9, 5, 2, 2, 129, 35, 3, 2, 2, 2, 130, 131, 9, 6, 2, 2, 131, 37, 3, 2, 2, 2, 132, 135, 7, 38, 2, 2, 133, 136, 5, 48, 25, 2, 134, 136, 5, 42, 22, 2, 135, 133, 3, 2, 2, 2, 135, 134, 3, 2, 2, 2, 136, 39, 3, 2, 2, 2, 137, 138, 7, 39, 2, 2, 138, 41, 3, 2, 2, 2, 139, 140, 7, 5, 2, 2, 140, 141, 5, 40, 21, 2, 141, 43, 3, 2, 2, 2, 142, 143, 7, 6, 2, 2, 143, 144, 7, 7, 2, 2, 144, 145, 7, 8, 2, 2, 145, 146, 5, 40, 21, 2, 146, 147, 7, 9, 2, 2, 147, 45, 3, 2, 2, 2, 148, 149, 7, 6, 2, 2, 149, 150, 5, 40, 21, 2, 150, 151, 7, 9, 2, 2, 151, 47, 3, 2, 2, 2, 152, 153, 7, 43, 2, 2, 153, 49, 3, 2, 2, 2, 154, 155, 7, 44, 2, 2, 155, 51, 3, 2, 2, 2, 156, 157, 7, 10, 2, 2, 157, 158, 7, 39, 2, 2, 158, 53, 3, 2, 2, 2, 159, 160, 7, 41, 2, 2, 160, 55, 3, 2, 2, 2, 13, 58, 61, 63, 81, 86, 98, 104, 110, 114, 121, 135]

+ 0
- 50
internal/parser/BPF.tokens View File

@@ -1,50 +0,0 @@
1
-T__0=1
2
-T__1=2
3
-T__2=3
4
-T__3=4
5
-T__4=5
6
-T__5=6
7
-T__6=7
8
-T__7=8
9
-ADD=9
10
-SUB=10
11
-MUL=11
12
-DIV=12
13
-MOD=13
14
-AND=14
15
-OR=15
16
-XOR=16
17
-LSH=17
18
-RSH=18
19
-JA=19
20
-JEQ=20
21
-JNE=21
22
-JLT=22
23
-JLE=23
24
-JGT=24
25
-JGE=25
26
-JSE=26
27
-LDA=27
28
-LDX=28
29
-LDB=29
30
-LDH=30
31
-STA=31
32
-STX=32
33
-TAX=33
34
-TXA=34
35
-NEG=35
36
-RET=36
37
-NUMBER=37
38
-COMMENT=38
39
-IDENTIFIER=39
40
-WHITESPACE=40
41
-REGA=41
42
-REGX=42
43
-':'=1
44
-','=2
45
-'#'=3
46
-'['=4
47
-'x'=5
48
-'+'=6
49
-']'=7
50
-'r'=8

+ 0
- 143
internal/parser/BPFLexer.interp
File diff suppressed because it is too large
View File


+ 0
- 50
internal/parser/BPFLexer.tokens View File

@@ -1,50 +0,0 @@
1
-T__0=1
2
-T__1=2
3
-T__2=3
4
-T__3=4
5
-T__4=5
6
-T__5=6
7
-T__6=7
8
-T__7=8
9
-ADD=9
10
-SUB=10
11
-MUL=11
12
-DIV=12
13
-MOD=13
14
-AND=14
15
-OR=15
16
-XOR=16
17
-LSH=17
18
-RSH=18
19
-JA=19
20
-JEQ=20
21
-JNE=21
22
-JLT=22
23
-JLE=23
24
-JGT=24
25
-JGE=25
26
-JSE=26
27
-LDA=27
28
-LDX=28
29
-LDB=29
30
-LDH=30
31
-STA=31
32
-STX=32
33
-TAX=33
34
-TXA=34
35
-NEG=35
36
-RET=36
37
-NUMBER=37
38
-COMMENT=38
39
-IDENTIFIER=39
40
-WHITESPACE=40
41
-REGA=41
42
-REGX=42
43
-':'=1
44
-','=2
45
-'#'=3
46
-'['=4
47
-'x'=5
48
-'+'=6
49
-']'=7
50
-'r'=8

+ 249
- 0
internal/parser/Compiler.g4 View File

@@ -0,0 +1,249 @@
1
+grammar C;
2
+
3
+program
4
+    : block EOF
5
+    ;
6
+
7
+block
8
+    : stat* retstat?
9
+    ;
10
+
11
+stat
12
+    : ';'
13
+    | varlist '=' explist
14
+    | functioncall
15
+    | label
16
+    | 'break'
17
+    | 'goto' NAME
18
+    | 'if' exp 'then' block ('elseif' exp 'then' block)* ('else' block)? 'end'
19
+    | 'function' funcname funcbody
20
+    ;
21
+
22
+retstat
23
+    : 'return' explist? ';'?
24
+    ;
25
+
26
+label
27
+    : NAME ':'
28
+    ;
29
+
30
+funcname
31
+    : NAME (':' NAME)?
32
+    ;
33
+
34
+varlist
35
+    : var (',' var)*
36
+    ;
37
+
38
+namelist
39
+    : NAME (',' NAME)*
40
+    ;
41
+
42
+explist
43
+    : exp (',' exp)*
44
+    ;
45
+
46
+exp
47
+    : 'null' | 'false' | 'true'
48
+    | number
49
+    | string
50
+    | functiondef
51
+    | prefixexp
52
+    | <assoc=right> exp operatorPower exp
53
+    | operatorUnary exp
54
+    | exp operatorMulDivMod exp
55
+    | exp operatorAddSub exp
56
+    | <assoc=right> exp operatorStrcat exp
57
+    | exp operatorComparison exp
58
+    | exp operatorAnd exp
59
+    | exp operatorOr exp
60
+    | exp operatorBitwise exp
61
+    ;
62
+
63
+prefixexp
64
+    : varOrExp nameAndArgs*
65
+    ;
66
+
67
+functioncall
68
+    : varOrExp nameAndArgs+
69
+    ;
70
+
71
+varOrExp
72
+    : var | '(' exp ')'
73
+    ;
74
+
75
+var
76
+    : (NAME | '(' exp ')' varSuffix) varSuffix*
77
+    ;
78
+
79
+varSuffix
80
+    : nameAndArgs* ('[' exp ']' | '.' NAME)
81
+    ;
82
+
83
+nameAndArgs
84
+    : (':' NAME)? args
85
+    ;
86
+
87
+args
88
+    : '(' explist? ')' | tableconstructor | string
89
+    ;
90
+
91
+functiondef
92
+    : 'function' funcbody
93
+    ;
94
+
95
+funcbody
96
+    : '(' parlist? ')' block 'end'
97
+    ;
98
+
99
+parlist
100
+    : namelist (',' '...')? | '...'
101
+    ;
102
+
103
+tableconstructor
104
+    : '{' fieldlist? '}'
105
+    ;
106
+
107
+fieldlist
108
+    : field (fieldsep field)* fieldsep?
109
+    ;
110
+
111
+field
112
+    : '[' exp ']' '=' exp | NAME '=' exp | exp
113
+    ;
114
+
115
+fieldsep
116
+    : ',' | ';'
117
+    ;
118
+
119
+operatorOr
120
+	: 'or';
121
+
122
+operatorAnd
123
+	: 'and';
124
+
125
+operatorComparison
126
+	: '<' | '>' | '<=' | '>=' | '~=' | '==';
127
+
128
+operatorStrcat
129
+	: '..';
130
+
131
+operatorAddSub
132
+	: '+' | '-';
133
+
134
+operatorMulDivMod
135
+	: '*' | '/' | '%' | '//';
136
+
137
+operatorBitwise
138
+	: '&' | '|' | '~' | '<<' | '>>';
139
+
140
+operatorUnary
141
+    : 'not' | '#' | '-' | '~';
142
+
143
+operatorPower
144
+    : '^';
145
+
146
+number
147
+    : INT | HEX | FLOAT | HEX_FLOAT
148
+    ;
149
+
150
+string
151
+    : NORMALSTRING | CHARSTRING | LONGSTRING
152
+    ;
153
+
154
+NAME
155
+    : [a-zA-Z_][a-zA-Z_0-9]*
156
+    ;
157
+
158
+NORMALSTRING
159
+    : '"' ( EscapeSequence | ~('\\'|'"') )* '"'
160
+    ;
161
+
162
+CHARSTRING
163
+    : '\'' ( EscapeSequence | ~('\''|'\\') )* '\''
164
+    ;
165
+
166
+LONGSTRING
167
+    : '[' NESTED_STR ']'
168
+    ;
169
+
170
+fragment
171
+NESTED_STR
172
+    : '=' NESTED_STR '='
173
+    | '[' .*? ']'
174
+    ;
175
+
176
+INT
177
+    : Digit+
178
+    ;
179
+
180
+HEX
181
+    : '0' [xX] HexDigit+
182
+    ;
183
+
184
+FLOAT
185
+    : Digit+ '.' Digit* ExponentPart?
186
+    | '.' Digit+ ExponentPart?
187
+    | Digit+ ExponentPart
188
+    ;
189
+
190
+HEX_FLOAT
191
+    : '0' [xX] HexDigit+ '.' HexDigit* HexExponentPart?
192
+    | '0' [xX] '.' HexDigit+ HexExponentPart?
193
+    | '0' [xX] HexDigit+ HexExponentPart
194
+    ;
195
+
196
+fragment
197
+ExponentPart
198
+    : [eE] [+-]? Digit+
199
+    ;
200
+
201
+fragment
202
+HexExponentPart
203
+    : [pP] [+-]? Digit+
204
+    ;
205
+
206
+fragment
207
+EscapeSequence
208
+    : '\\' [abfnrtvz"'\\]
209
+    | '\\' '\r'? '\n'
210
+    | DecimalEscape
211
+    | HexEscape
212
+    | UtfEscape
213
+    ;
214
+
215
+fragment
216
+DecimalEscape
217
+    : '\\' Digit
218
+    | '\\' Digit Digit
219
+    | '\\' [0-2] Digit Digit
220
+    ;
221
+
222
+fragment
223
+HexEscape
224
+    : '\\' 'x' HexDigit HexDigit
225
+    ;
226
+fragment
227
+UtfEscape
228
+    : '\\' 'u{' HexDigit+ '}'
229
+    ;
230
+fragment
231
+Digit
232
+    : [0-9]
233
+    ;
234
+fragment
235
+HexDigit
236
+    : [0-9a-fA-F]
237
+    ;
238
+
239
+BLOCK_COMMENT
240
+    : '/*' .*? '*/' -> skip
241
+    ;
242
+
243
+LINE_COMMENT
244
+    : '//' ~[\r\n]* -> skip
245
+    ;
246
+
247
+WS
248
+    : [ \t\u000C\r\n]+ -> skip
249
+    ;

+ 183
- 0
internal/parser/assembler_base_listener.go View File

@@ -0,0 +1,183 @@
1
+// Code generated from internal/parser/Assembler.g4 by ANTLR 4.7.2. DO NOT EDIT.
2
+
3
+package parser // Assembler
4
+import "github.com/antlr/antlr4/runtime/Go/antlr"
5
+
6
+// BaseAssemblerListener is a complete listener for a parse tree produced by AssemblerParser.
7
+type BaseAssemblerListener struct{}
8
+
9
+var _ AssemblerListener = &BaseAssemblerListener{}
10
+
11
+// VisitTerminal is called when a terminal node is visited.
12
+func (s *BaseAssemblerListener) VisitTerminal(node antlr.TerminalNode) {}
13
+
14
+// VisitErrorNode is called when an error node is visited.
15
+func (s *BaseAssemblerListener) VisitErrorNode(node antlr.ErrorNode) {}
16
+
17
+// EnterEveryRule is called when any rule is entered.
18
+func (s *BaseAssemblerListener) EnterEveryRule(ctx antlr.ParserRuleContext) {}
19
+
20
+// ExitEveryRule is called when any rule is exited.
21
+func (s *BaseAssemblerListener) ExitEveryRule(ctx antlr.ParserRuleContext) {}
22
+
23
+// EnterProgram is called when production program is entered.
24
+func (s *BaseAssemblerListener) EnterProgram(ctx *ProgramContext) {}
25
+
26
+// ExitProgram is called when production program is exited.
27
+func (s *BaseAssemblerListener) ExitProgram(ctx *ProgramContext) {}
28
+
29
+// EnterLabelDefinition is called when production labelDefinition is entered.
30
+func (s *BaseAssemblerListener) EnterLabelDefinition(ctx *LabelDefinitionContext) {}
31
+
32
+// ExitLabelDefinition is called when production labelDefinition is exited.
33
+func (s *BaseAssemblerListener) ExitLabelDefinition(ctx *LabelDefinitionContext) {}
34
+
35
+// EnterLabel is called when production label is entered.
36
+func (s *BaseAssemblerListener) EnterLabel(ctx *LabelContext) {}
37
+
38
+// ExitLabel is called when production label is exited.
39
+func (s *BaseAssemblerListener) ExitLabel(ctx *LabelContext) {}
40
+
41
+// EnterComment is called when production comment is entered.
42
+func (s *BaseAssemblerListener) EnterComment(ctx *CommentContext) {}
43
+
44
+// ExitComment is called when production comment is exited.
45
+func (s *BaseAssemblerListener) ExitComment(ctx *CommentContext) {}
46
+
47
+// EnterInstruction is called when production instruction is entered.
48
+func (s *BaseAssemblerListener) EnterInstruction(ctx *InstructionContext) {}
49
+
50
+// ExitInstruction is called when production instruction is exited.
51
+func (s *BaseAssemblerListener) ExitInstruction(ctx *InstructionContext) {}
52
+
53
+// EnterAluOperation is called when production aluOperation is entered.
54
+func (s *BaseAssemblerListener) EnterAluOperation(ctx *AluOperationContext) {}
55
+
56
+// ExitAluOperation is called when production aluOperation is exited.
57
+func (s *BaseAssemblerListener) ExitAluOperation(ctx *AluOperationContext) {}
58
+
59
+// EnterAluOperator is called when production aluOperator is entered.
60
+func (s *BaseAssemblerListener) EnterAluOperator(ctx *AluOperatorContext) {}
61
+
62
+// ExitAluOperator is called when production aluOperator is exited.
63
+func (s *BaseAssemblerListener) ExitAluOperator(ctx *AluOperatorContext) {}
64
+
65
+// EnterJumpOperation is called when production jumpOperation is entered.
66
+func (s *BaseAssemblerListener) EnterJumpOperation(ctx *JumpOperationContext) {}
67
+
68
+// ExitJumpOperation is called when production jumpOperation is exited.
69
+func (s *BaseAssemblerListener) ExitJumpOperation(ctx *JumpOperationContext) {}
70
+
71
+// EnterJumpOperator is called when production jumpOperator is entered.
72
+func (s *BaseAssemblerListener) EnterJumpOperator(ctx *JumpOperatorContext) {}
73
+
74
+// ExitJumpOperator is called when production jumpOperator is exited.
75
+func (s *BaseAssemblerListener) ExitJumpOperator(ctx *JumpOperatorContext) {}
76
+
77
+// EnterJumpConditionalOperation is called when production jumpConditionalOperation is entered.
78
+func (s *BaseAssemblerListener) EnterJumpConditionalOperation(ctx *JumpConditionalOperationContext) {}
79
+
80
+// ExitJumpConditionalOperation is called when production jumpConditionalOperation is exited.
81
+func (s *BaseAssemblerListener) ExitJumpConditionalOperation(ctx *JumpConditionalOperationContext) {}
82
+
83
+// EnterJumpConditionalOperator is called when production jumpConditionalOperator is entered.
84
+func (s *BaseAssemblerListener) EnterJumpConditionalOperator(ctx *JumpConditionalOperatorContext) {}
85
+
86
+// ExitJumpConditionalOperator is called when production jumpConditionalOperator is exited.
87
+func (s *BaseAssemblerListener) ExitJumpConditionalOperator(ctx *JumpConditionalOperatorContext) {}
88
+
89
+// EnterIfTrue is called when production ifTrue is entered.
90
+func (s *BaseAssemblerListener) EnterIfTrue(ctx *IfTrueContext) {}
91
+
92
+// ExitIfTrue is called when production ifTrue is exited.
93
+func (s *BaseAssemblerListener) ExitIfTrue(ctx *IfTrueContext) {}
94
+
95
+// EnterIfFalse is called when production ifFalse is entered.
96
+func (s *BaseAssemblerListener) EnterIfFalse(ctx *IfFalseContext) {}
97
+
98
+// ExitIfFalse is called when production ifFalse is exited.
99
+func (s *BaseAssemblerListener) ExitIfFalse(ctx *IfFalseContext) {}
100
+
101
+// EnterLoadOperation is called when production loadOperation is entered.
102
+func (s *BaseAssemblerListener) EnterLoadOperation(ctx *LoadOperationContext) {}
103
+
104
+// ExitLoadOperation is called when production loadOperation is exited.
105
+func (s *BaseAssemblerListener) ExitLoadOperation(ctx *LoadOperationContext) {}
106
+
107
+// EnterLoadOperator is called when production loadOperator is entered.
108
+func (s *BaseAssemblerListener) EnterLoadOperator(ctx *LoadOperatorContext) {}
109
+
110
+// ExitLoadOperator is called when production loadOperator is exited.
111
+func (s *BaseAssemblerListener) ExitLoadOperator(ctx *LoadOperatorContext) {}
112
+
113
+// EnterStoreOperation is called when production storeOperation is entered.
114
+func (s *BaseAssemblerListener) EnterStoreOperation(ctx *StoreOperationContext) {}
115
+
116
+// ExitStoreOperation is called when production storeOperation is exited.
117
+func (s *BaseAssemblerListener) ExitStoreOperation(ctx *StoreOperationContext) {}
118
+
119
+// EnterStoreOperator is called when production storeOperator is entered.
120
+func (s *BaseAssemblerListener) EnterStoreOperator(ctx *StoreOperatorContext) {}
121
+
122
+// ExitStoreOperator is called when production storeOperator is exited.
123
+func (s *BaseAssemblerListener) ExitStoreOperator(ctx *StoreOperatorContext) {}
124
+
125
+// EnterSimpleOperation is called when production simpleOperation is entered.
126
+func (s *BaseAssemblerListener) EnterSimpleOperation(ctx *SimpleOperationContext) {}
127
+
128
+// ExitSimpleOperation is called when production simpleOperation is exited.
129
+func (s *BaseAssemblerListener) ExitSimpleOperation(ctx *SimpleOperationContext) {}
130
+
131
+// EnterReturnOperation is called when production returnOperation is entered.
132
+func (s *BaseAssemblerListener) EnterReturnOperation(ctx *ReturnOperationContext) {}
133
+
134
+// ExitReturnOperation is called when production returnOperation is exited.
135
+func (s *BaseAssemblerListener) ExitReturnOperation(ctx *ReturnOperationContext) {}
136
+
137
+// EnterNumber is called when production number is entered.
138
+func (s *BaseAssemblerListener) EnterNumber(ctx *NumberContext) {}
139
+
140
+// ExitNumber is called when production number is exited.
141
+func (s *BaseAssemblerListener) ExitNumber(ctx *NumberContext) {}
142
+
143
+// EnterLiteralNumber is called when production literalNumber is entered.
144
+func (s *BaseAssemblerListener) EnterLiteralNumber(ctx *LiteralNumberContext) {}
145
+
146
+// ExitLiteralNumber is called when production literalNumber is exited.
147
+func (s *BaseAssemblerListener) ExitLiteralNumber(ctx *LiteralNumberContext) {}
148
+
149
+// EnterIndirectX is called when production indirectX is entered.
150
+func (s *BaseAssemblerListener) EnterIndirectX(ctx *IndirectXContext) {}
151
+
152
+// ExitIndirectX is called when production indirectX is exited.
153
+func (s *BaseAssemblerListener) ExitIndirectX(ctx *IndirectXContext) {}
154
+
155
+// EnterAbsoluteNumber is called when production absoluteNumber is entered.
156
+func (s *BaseAssemblerListener) EnterAbsoluteNumber(ctx *AbsoluteNumberContext) {}
157
+
158
+// ExitAbsoluteNumber is called when production absoluteNumber is exited.
159
+func (s *BaseAssemblerListener) ExitAbsoluteNumber(ctx *AbsoluteNumberContext) {}
160
+
161
+// EnterRegisterA is called when production registerA is entered.
162
+func (s *BaseAssemblerListener) EnterRegisterA(ctx *RegisterAContext) {}
163
+
164
+// ExitRegisterA is called when production registerA is exited.
165
+func (s *BaseAssemblerListener) ExitRegisterA(ctx *RegisterAContext) {}
166
+
167
+// EnterRegisterX is called when production registerX is entered.
168
+func (s *BaseAssemblerListener) EnterRegisterX(ctx *RegisterXContext) {}
169
+
170
+// ExitRegisterX is called when production registerX is exited.
171
+func (s *BaseAssemblerListener) ExitRegisterX(ctx *RegisterXContext) {}
172
+
173
+// EnterRegisterR is called when production registerR is entered.
174
+func (s *BaseAssemblerListener) EnterRegisterR(ctx *RegisterRContext) {}
175
+
176
+// ExitRegisterR is called when production registerR is exited.
177
+func (s *BaseAssemblerListener) ExitRegisterR(ctx *RegisterRContext) {}
178
+
179
+// EnterExtension is called when production extension is entered.
180
+func (s *BaseAssemblerListener) EnterExtension(ctx *ExtensionContext) {}
181
+
182
+// ExitExtension is called when production extension is exited.
183
+func (s *BaseAssemblerListener) ExitExtension(ctx *ExtensionContext) {}

+ 116
- 0
internal/parser/assembler_base_visitor.go View File

@@ -0,0 +1,116 @@
1
+// Code generated from internal/parser/Assembler.g4 by ANTLR 4.7.2. DO NOT EDIT.
2
+
3
+package parser // Assembler
4
+import "github.com/antlr/antlr4/runtime/Go/antlr"
5
+
6
+type BaseAssemblerVisitor struct {
7
+	*antlr.BaseParseTreeVisitor
8
+}
9
+
10
+func (v *BaseAssemblerVisitor) VisitProgram(ctx *ProgramContext) interface{} {
11
+	return v.VisitChildren(ctx)
12
+}
13
+
14
+func (v *BaseAssemblerVisitor) VisitLabelDefinition(ctx *LabelDefinitionContext) interface{} {
15
+	return v.VisitChildren(ctx)
16
+}
17
+
18
+func (v *BaseAssemblerVisitor) VisitLabel(ctx *LabelContext) interface{} {
19
+	return v.VisitChildren(ctx)
20
+}
21
+
22
+func (v *BaseAssemblerVisitor) VisitComment(ctx *CommentContext) interface{} {
23
+	return v.VisitChildren(ctx)
24
+}
25
+
26
+func (v *BaseAssemblerVisitor) VisitInstruction(ctx *InstructionContext) interface{} {
27
+	return v.VisitChildren(ctx)
28
+}
29
+
30
+func (v *BaseAssemblerVisitor) VisitAluOperation(ctx *AluOperationContext) interface{} {
31
+	return v.VisitChildren(ctx)
32
+}
33
+
34
+func (v *BaseAssemblerVisitor) VisitAluOperator(ctx *AluOperatorContext) interface{} {
35
+	return v.VisitChildren(ctx)
36
+}
37
+
38
+func (v *BaseAssemblerVisitor) VisitJumpOperation(ctx *JumpOperationContext) interface{} {
39
+	return v.VisitChildren(ctx)
40
+}
41
+
42
+func (v *BaseAssemblerVisitor) VisitJumpOperator(ctx *JumpOperatorContext) interface{} {
43
+	return v.VisitChildren(ctx)
44
+}
45
+
46
+func (v *BaseAssemblerVisitor) VisitJumpConditionalOperation(ctx *JumpConditionalOperationContext) interface{} {
47
+	return v.VisitChildren(ctx)
48
+}
49
+
50
+func (v *BaseAssemblerVisitor) VisitJumpConditionalOperator(ctx *JumpConditionalOperatorContext) interface{} {
51
+	return v.VisitChildren(ctx)
52
+}
53
+
54
+func (v *BaseAssemblerVisitor) VisitIfTrue(ctx *IfTrueContext) interface{} {
55
+	return v.VisitChildren(ctx)
56
+}
57
+
58
+func (v *BaseAssemblerVisitor) VisitIfFalse(ctx *IfFalseContext) interface{} {
59
+	return v.VisitChildren(ctx)
60
+}
61
+
62
+func (v *BaseAssemblerVisitor) VisitLoadOperation(ctx *LoadOperationContext) interface{} {
63
+	return v.VisitChildren(ctx)
64
+}
65
+
66
+func (v *BaseAssemblerVisitor) VisitLoadOperator(ctx *LoadOperatorContext) interface{} {
67
+	return v.VisitChildren(ctx)
68
+}
69
+
70
+func (v *BaseAssemblerVisitor) VisitStoreOperation(ctx *StoreOperationContext) interface{} {
71
+	return v.VisitChildren(ctx)
72
+}
73
+
74
+func (v *BaseAssemblerVisitor) VisitStoreOperator(ctx *StoreOperatorContext) interface{} {
75
+	return v.VisitChildren(ctx)
76
+}
77
+
78
+func (v *BaseAssemblerVisitor) VisitSimpleOperation(ctx *SimpleOperationContext) interface{} {
79
+	return v.VisitChildren(ctx)
80
+}
81
+
82
+func (v *BaseAssemblerVisitor) VisitReturnOperation(ctx *ReturnOperationContext) interface{} {
83
+	return v.VisitChildren(ctx)
84
+}
85
+
86
+func (v *BaseAssemblerVisitor) VisitNumber(ctx *NumberContext) interface{} {
87
+	return v.VisitChildren(ctx)
88
+}
89
+
90
+func (v *BaseAssemblerVisitor) VisitLiteralNumber(ctx *LiteralNumberContext) interface{} {
91
+	return v.VisitChildren(ctx)
92
+}
93
+
94
+func (v *BaseAssemblerVisitor) VisitIndirectX(ctx *IndirectXContext) interface{} {
95
+	return v.VisitChildren(ctx)
96
+}
97
+
98
+func (v *BaseAssemblerVisitor) VisitAbsoluteNumber(ctx *AbsoluteNumberContext) interface{} {
99
+	return v.VisitChildren(ctx)
100
+}
101
+
102
+func (v *BaseAssemblerVisitor) VisitRegisterA(ctx *RegisterAContext) interface{} {
103
+	return v.VisitChildren(ctx)
104
+}
105
+
106
+func (v *BaseAssemblerVisitor) VisitRegisterX(ctx *RegisterXContext) interface{} {
107
+	return v.VisitChildren(ctx)
108
+}
109
+
110
+func (v *BaseAssemblerVisitor) VisitRegisterR(ctx *RegisterRContext) interface{} {
111
+	return v.VisitChildren(ctx)
112
+}
113
+
114
+func (v *BaseAssemblerVisitor) VisitExtension(ctx *ExtensionContext) interface{} {
115
+	return v.VisitChildren(ctx)
116
+}

internal/parser/bpf_lexer.go → internal/parser/assembler_lexer.go View File

@@ -1,4 +1,4 @@
1
-// Code generated from parser/BPF.g4 by ANTLR 4.7.2. DO NOT EDIT.
1
+// Code generated from internal/parser/Assembler.g4 by ANTLR 4.7.2. DO NOT EDIT.
2 2
 
3 3
 package parser
4 4
 
@@ -233,7 +233,7 @@ var lexerRuleNames = []string{
233 233
 	"REGA", "REGX",
234 234
 }
235 235
 
236
-type BPFLexer struct {
236
+type AssemblerLexer struct {
237 237
 	*antlr.BaseLexer
238 238
 	channelNames []string
239 239
 	modeNames    []string
@@ -248,9 +248,9 @@ func init() {
248 248
 	}
249 249
 }
250 250
 
251
-func NewBPFLexer(input antlr.CharStream) *BPFLexer {
251
+func NewAssemblerLexer(input antlr.CharStream) *AssemblerLexer {
252 252
 
253
-	l := new(BPFLexer)
253
+	l := new(AssemblerLexer)
254 254
 
255 255
 	l.BaseLexer = antlr.NewBaseLexer(input)
256 256
 	l.Interpreter = antlr.NewLexerATNSimulator(l, lexerAtn, lexerDecisionToDFA, antlr.NewPredictionContextCache())
@@ -260,54 +260,54 @@ func NewBPFLexer(input antlr.CharStream) *BPFLexer {
260 260
 	l.RuleNames = lexerRuleNames
261 261
 	l.LiteralNames = lexerLiteralNames
262 262
 	l.SymbolicNames = lexerSymbolicNames
263
-	l.GrammarFileName = "BPF.g4"
263
+	l.GrammarFileName = "Assembler.g4"
264 264
 	// TODO: l.EOF = antlr.TokenEOF
265 265
 
266 266
 	return l
267 267
 }
268 268
 
269
-// BPFLexer tokens.
269
+// AssemblerLexer tokens.
270 270
 const (
271
-	BPFLexerT__0       = 1
272
-	BPFLexerT__1       = 2
273
-	BPFLexerT__2       = 3
274
-	BPFLexerT__3       = 4
275
-	BPFLexerT__4       = 5
276
-	BPFLexerT__5       = 6
277
-	BPFLexerT__6       = 7
278
-	BPFLexerT__7       = 8
279
-	BPFLexerADD        = 9
280
-	BPFLexerSUB        = 10
281
-	BPFLexerMUL        = 11
282
-	BPFLexerDIV        = 12
283
-	BPFLexerMOD        = 13
284
-	BPFLexerAND        = 14
285
-	BPFLexerOR         = 15
286
-	BPFLexerXOR        = 16
287
-	BPFLexerLSH        = 17
288
-	BPFLexerRSH        = 18
289
-	BPFLexerJA         = 19
290
-	BPFLexerJEQ        = 20
291
-	BPFLexerJNE        = 21
292
-	BPFLexerJLT        = 22
293
-	BPFLexerJLE        = 23
294
-	BPFLexerJGT        = 24
295
-	BPFLexerJGE        = 25
296
-	BPFLexerJSE        = 26
297
-	BPFLexerLDA        = 27
298
-	BPFLexerLDX        = 28
299
-	BPFLexerLDB        = 29
300
-	BPFLexerLDH        = 30
301
-	BPFLexerSTA        = 31
302
-	BPFLexerSTX        = 32
303
-	BPFLexerTAX        = 33
304
-	BPFLexerTXA        = 34
305
-	BPFLexerNEG        = 35
306
-	BPFLexerRET        = 36
307
-	BPFLexerNUMBER     = 37
308
-	BPFLexerCOMMENT    = 38
309
-	BPFLexerIDENTIFIER = 39
310
-	BPFLexerWHITESPACE = 40
311
-	BPFLexerREGA       = 41
312
-	BPFLexerREGX       = 42
271
+	AssemblerLexerT__0       = 1
272
+	AssemblerLexerT__1       = 2
273
+	AssemblerLexerT__2       = 3
274
+	AssemblerLexerT__3       = 4
275
+	AssemblerLexerT__4       = 5
276
+	AssemblerLexerT__5       = 6
277
+	AssemblerLexerT__6       = 7
278
+	AssemblerLexerT__7       = 8
279
+	AssemblerLexerADD        = 9
280
+	AssemblerLexerSUB        = 10
281
+	AssemblerLexerMUL        = 11
282
+	AssemblerLexerDIV        = 12
283
+	AssemblerLexerMOD        = 13
284
+	AssemblerLexerAND        = 14
285
+	AssemblerLexerOR         = 15
286
+	AssemblerLexerXOR        = 16
287
+	AssemblerLexerLSH        = 17
288
+	AssemblerLexerRSH        = 18
289
+	AssemblerLexerJA         = 19
290
+	AssemblerLexerJEQ        = 20
291
+	AssemblerLexerJNE        = 21
292
+	AssemblerLexerJLT        = 22
293
+	AssemblerLexerJLE        = 23
294
+	AssemblerLexerJGT        = 24
295
+	AssemblerLexerJGE        = 25
296
+	AssemblerLexerJSE        = 26
297
+	AssemblerLexerLDA        = 27
298
+	AssemblerLexerLDX        = 28
299
+	AssemblerLexerLDB        = 29
300
+	AssemblerLexerLDH        = 30
301
+	AssemblerLexerSTA        = 31
302
+	AssemblerLexerSTX        = 32
303
+	AssemblerLexerTAX        = 33
304
+	AssemblerLexerTXA        = 34
305
+	AssemblerLexerNEG        = 35
306
+	AssemblerLexerRET        = 36
307
+	AssemblerLexerNUMBER     = 37
308
+	AssemblerLexerCOMMENT    = 38
309
+	AssemblerLexerIDENTIFIER = 39
310
+	AssemblerLexerWHITESPACE = 40
311
+	AssemblerLexerREGA       = 41
312
+	AssemblerLexerREGX       = 42
313 313
 )

internal/parser/bpf_listener.go → internal/parser/assembler_listener.go View File

@@ -1,10 +1,10 @@
1
-// Code generated from parser/BPF.g4 by ANTLR 4.7.2. DO NOT EDIT.
1
+// Code generated from internal/parser/Assembler.g4 by ANTLR 4.7.2. DO NOT EDIT.
2 2
 
3
-package parser // BPF
3
+package parser // Assembler
4 4
 import "github.com/antlr/antlr4/runtime/Go/antlr"
5 5
 
6
-// BPFListener is a complete listener for a parse tree produced by BPFParser.
7
-type BPFListener interface {
6
+// AssemblerListener is a complete listener for a parse tree produced by AssemblerParser.
7
+type AssemblerListener interface {
8 8
 	antlr.ParseTreeListener
9 9
 
10 10
 	// EnterProgram is called when entering the program production.

internal/parser/assembler_parser.go
File diff suppressed because it is too large
View File


+ 90
- 0
internal/parser/assembler_visitor.go View File

@@ -0,0 +1,90 @@
1
+// Code generated from internal/parser/Assembler.g4 by ANTLR 4.7.2. DO NOT EDIT.
2
+
3
+package parser // Assembler
4
+import "github.com/antlr/antlr4/runtime/Go/antlr"
5
+
6
+// A complete Visitor for a parse tree produced by AssemblerParser.
7
+type AssemblerVisitor interface {
8
+	antlr.ParseTreeVisitor
9
+
10
+	// Visit a parse tree produced by AssemblerParser#program.
11
+	VisitProgram(ctx *ProgramContext) interface{}
12
+
13
+	// Visit a parse tree produced by AssemblerParser#labelDefinition.
14
+	VisitLabelDefinition(ctx *LabelDefinitionContext) interface{}
15
+
16
+	// Visit a parse tree produced by AssemblerParser#label.
17
+	VisitLabel(ctx *LabelContext) interface{}
18
+
19
+	// Visit a parse tree produced by AssemblerParser#comment.
20
+	VisitComment(ctx *CommentContext) interface{}
21
+
22
+	// Visit a parse tree produced by AssemblerParser#instruction.
23
+	VisitInstruction(ctx *InstructionContext) interface{}
24
+
25
+	// Visit a parse tree produced by AssemblerParser#aluOperation.
26
+	VisitAluOperation(ctx *AluOperationContext) interface{}
27
+
28
+	// Visit a parse tree produced by AssemblerParser#aluOperator.
29
+	VisitAluOperator(ctx *AluOperatorContext) interface{}
30
+
31
+	// Visit a parse tree produced by AssemblerParser#jumpOperation.
32
+	VisitJumpOperation(ctx *JumpOperationContext) interface{}
33
+
34
+	// Visit a parse tree produced by AssemblerParser#jumpOperator.
35
+	VisitJumpOperator(ctx *JumpOperatorContext) interface{}
36
+
37
+	// Visit a parse tree produced by AssemblerParser#jumpConditionalOperation.
38
+	VisitJumpConditionalOperation(ctx *JumpConditionalOperationContext) interface{}
39
+
40
+	// Visit a parse tree produced by AssemblerParser#jumpConditionalOperator.
41
+	VisitJumpConditionalOperator(ctx *JumpConditionalOperatorContext) interface{}
42
+
43
+	// Visit a parse tree produced by AssemblerParser#ifTrue.
44
+	VisitIfTrue(ctx *IfTrueContext) interface{}
45
+
46
+	// Visit a parse tree produced by AssemblerParser#ifFalse.
47
+	VisitIfFalse(ctx *IfFalseContext) interface{}
48
+
49
+	// Visit a parse tree produced by AssemblerParser#loadOperation.
50
+	VisitLoadOperation(ctx *LoadOperationContext) interface{}
51
+
52
+	// Visit a parse tree produced by AssemblerParser#loadOperator.
53
+	VisitLoadOperator(ctx *LoadOperatorContext) interface{}
54
+
55
+	// Visit a parse tree produced by AssemblerParser#storeOperation.
56
+	VisitStoreOperation(ctx *StoreOperationContext) interface{}
57
+
58
+	// Visit a parse tree produced by AssemblerParser#storeOperator.
59
+	VisitStoreOperator(ctx *StoreOperatorContext) interface{}
60
+
61
+	// Visit a parse tree produced by AssemblerParser#simpleOperation.
62
+	VisitSimpleOperation(ctx *SimpleOperationContext) interface{}
63
+
64
+	// Visit a parse tree produced by AssemblerParser#returnOperation.
65
+	VisitReturnOperation(ctx *ReturnOperationContext) interface{}
66
+
67
+	// Visit a parse tree produced by AssemblerParser#number.
68
+	VisitNumber(ctx *NumberContext) interface{}
69
+
70
+	// Visit a parse tree produced by AssemblerParser#literalNumber.
71
+	VisitLiteralNumber(ctx *LiteralNumberContext) interface{}
72
+
73
+	// Visit a parse tree produced by AssemblerParser#indirectX.
74
+	VisitIndirectX(ctx *IndirectXContext) interface{}
75
+
76
+	// Visit a parse tree produced by AssemblerParser#absoluteNumber.
77
+	VisitAbsoluteNumber(ctx *AbsoluteNumberContext) interface{}
78
+
79
+	// Visit a parse tree produced by AssemblerParser#registerA.
80
+	VisitRegisterA(ctx *RegisterAContext) interface{}
81
+
82
+	// Visit a parse tree produced by AssemblerParser#registerX.
83
+	VisitRegisterX(ctx *RegisterXContext) interface{}
84
+
85
+	// Visit a parse tree produced by AssemblerParser#registerR.
86
+	VisitRegisterR(ctx *RegisterRContext) interface{}
87
+
88
+	// Visit a parse tree produced by AssemblerParser#extension.
89
+	VisitExtension(ctx *ExtensionContext) interface{}
90
+}

+ 0
- 183
internal/parser/bpf_base_listener.go View File

@@ -1,183 +0,0 @@
1
-// Code generated from parser/BPF.g4 by ANTLR 4.7.2. DO NOT EDIT.
2
-
3
-package parser // BPF
4
-import "github.com/antlr/antlr4/runtime/Go/antlr"
5
-
6
-// BaseBPFListener is a complete listener for a parse tree produced by BPFParser.
7
-type BaseBPFListener struct{}
8
-
9
-var _ BPFListener = &BaseBPFListener{}
10
-
11
-// VisitTerminal is called when a terminal node is visited.
12
-func (s *BaseBPFListener) VisitTerminal(node antlr.TerminalNode) {}
13
-
14
-// VisitErrorNode is called when an error node is visited.
15
-func (s *BaseBPFListener) VisitErrorNode(node antlr.ErrorNode) {}
16
-
17
-// EnterEveryRule is called when any rule is entered.
18
-func (s *BaseBPFListener) EnterEveryRule(ctx antlr.ParserRuleContext) {}
19
-
20
-// ExitEveryRule is called when any rule is exited.
21
-func (s *BaseBPFListener) ExitEveryRule(ctx antlr.ParserRuleContext) {}
22
-
23
-// EnterProgram is called when production program is entered.
24
-func (s *BaseBPFListener) EnterProgram(ctx *ProgramContext) {}
25
-
26
-// ExitProgram is called when production program is exited.
27
-func (s *BaseBPFListener) ExitProgram(ctx *ProgramContext) {}
28
-
29
-// EnterLabelDefinition is called when production labelDefinition is entered.
30
-func (s *BaseBPFListener) EnterLabelDefinition(ctx *LabelDefinitionContext) {}
31
-
32
-// ExitLabelDefinition is called when production labelDefinition is exited.
33
-func (s *BaseBPFListener) ExitLabelDefinition(ctx *LabelDefinitionContext) {}
34
-
35
-// EnterLabel is called when production label is entered.
36
-func (s *BaseBPFListener) EnterLabel(ctx *LabelContext) {}
37
-
38
-// ExitLabel is called when production label is exited.
39
-func (s *BaseBPFListener) ExitLabel(ctx *LabelContext) {}
40
-
41
-// EnterComment is called when production comment is entered.
42
-func (s *BaseBPFListener) EnterComment(ctx *CommentContext) {}
43
-
44
-// ExitComment is called when production comment is exited.
45
-func (s *BaseBPFListener) ExitComment(ctx *CommentContext) {}
46
-
47
-// EnterInstruction is called when production instruction is entered.
48
-func (s *BaseBPFListener) EnterInstruction(ctx *InstructionContext) {}
49
-
50
-// ExitInstruction is called when production instruction is exited.
51
-func (s *BaseBPFListener) ExitInstruction(ctx *InstructionContext) {}
52
-
53
-// EnterAluOperation is called when production aluOperation is entered.
54
-func (s *BaseBPFListener) EnterAluOperation(ctx *AluOperationContext) {}
55
-
56
-// ExitAluOperation is called when production aluOperation is exited.
57
-func (s *BaseBPFListener) ExitAluOperation(ctx *AluOperationContext) {}
58
-
59
-// EnterAluOperator is called when production aluOperator is entered.
60
-func (s *BaseBPFListener) EnterAluOperator(ctx *AluOperatorContext) {}
61
-
62
-// ExitAluOperator is called when production aluOperator is exited.
63
-func (s *BaseBPFListener) ExitAluOperator(ctx *AluOperatorContext) {}
64
-
65
-// EnterJumpOperation is called when production jumpOperation is entered.
66
-func (s *BaseBPFListener) EnterJumpOperation(ctx *JumpOperationContext) {}
67
-
68
-// ExitJumpOperation is called when production jumpOperation is exited.
69
-func (s *BaseBPFListener) ExitJumpOperation(ctx *JumpOperationContext) {}
70
-
71
-// EnterJumpOperator is called when production jumpOperator is entered.
72
-func (s *BaseBPFListener) EnterJumpOperator(ctx *JumpOperatorContext) {}
73
-
74
-// ExitJumpOperator is called when production jumpOperator is exited.
75
-func (s *BaseBPFListener) ExitJumpOperator(ctx *JumpOperatorContext) {}
76
-
77
-// EnterJumpConditionalOperation is called when production jumpConditionalOperation is entered.
78
-func (s *BaseBPFListener) EnterJumpConditionalOperation(ctx *JumpConditionalOperationContext) {}
79
-
80
-// ExitJumpConditionalOperation is called when production jumpConditionalOperation is exited.
81
-func (s *BaseBPFListener) ExitJumpConditionalOperation(ctx *JumpConditionalOperationContext) {}
82
-
83
-// EnterJumpConditionalOperator is called when production jumpConditionalOperator is entered.
84
-func (s *BaseBPFListener) EnterJumpConditionalOperator(ctx *JumpConditionalOperatorContext) {}
85
-
86
-// ExitJumpConditionalOperator is called when production jumpConditionalOperator is exited.
87
-func (s *BaseBPFListener) ExitJumpConditionalOperator(ctx *JumpConditionalOperatorContext) {}
88
-
89
-// EnterIfTrue is called when production ifTrue is entered.
90
-func (s *BaseBPFListener) EnterIfTrue(ctx *IfTrueContext) {}
91
-
92
-// ExitIfTrue is called when production ifTrue is exited.
93
-func (s *BaseBPFListener) ExitIfTrue(ctx *IfTrueContext) {}
94
-
95
-// EnterIfFalse is called when production ifFalse is entered.
96
-func (s *BaseBPFListener) EnterIfFalse(ctx *IfFalseContext) {}
97
-
98
-// ExitIfFalse is called when production ifFalse is exited.
99
-func (s *BaseBPFListener) ExitIfFalse(ctx *IfFalseContext) {}
100
-
101
-// EnterLoadOperation is called when production loadOperation is entered.
102
-func (s *BaseBPFListener) EnterLoadOperation(ctx *LoadOperationContext) {}
103
-
104
-// ExitLoadOperation is called when production loadOperation is exited.
105
-func (s *BaseBPFListener) ExitLoadOperation(ctx *LoadOperationContext) {}
106
-
107
-// EnterLoadOperator is called when production loadOperator is entered.
108
-func (s *BaseBPFListener) EnterLoadOperator(ctx *LoadOperatorContext) {}
109
-
110
-// ExitLoadOperator is called when production loadOperator is exited.
111
-func (s *BaseBPFListener) ExitLoadOperator(ctx *LoadOperatorContext) {}
112
-
113
-// EnterStoreOperation is called when production storeOperation is entered.
114
-func (s *BaseBPFListener) EnterStoreOperation(ctx *StoreOperationContext) {}
115
-
116
-// ExitStoreOperation is called when production storeOperation is exited.
117
-func (s *BaseBPFListener) ExitStoreOperation(ctx *StoreOperationContext) {}
118
-
119
-// EnterStoreOperator is called when production storeOperator is entered.
120
-func (s *BaseBPFListener) EnterStoreOperator(ctx *StoreOperatorContext) {}
121
-
122
-// ExitStoreOperator is called when production storeOperator is exited.
123
-func (s *BaseBPFListener) ExitStoreOperator(ctx *StoreOperatorContext) {}
124
-
125
-// EnterSimpleOperation is called when production simpleOperation is entered.
126
-func (s *BaseBPFListener) EnterSimpleOperation(ctx *SimpleOperationContext) {}
127
-
128
-// ExitSimpleOperation is called when production simpleOperation is exited.
129
-func (s *BaseBPFListener) ExitSimpleOperation(ctx *SimpleOperationContext) {}
130
-
131
-// EnterReturnOperation is called when production returnOperation is entered.
132
-func (s *BaseBPFListener) EnterReturnOperation(ctx *ReturnOperationContext) {}
133
-
134
-// ExitReturnOperation is called when production returnOperation is exited.
135
-func (s *BaseBPFListener) ExitReturnOperation(ctx *ReturnOperationContext) {}
136
-
137
-// EnterNumber is called when production number is entered.
138
-func (s *BaseBPFListener) EnterNumber(ctx *NumberContext) {}
139
-
140
-// ExitNumber is called when production number is exited.
141
-func (s *BaseBPFListener) ExitNumber(ctx *NumberContext) {}
142
-
143
-// EnterLiteralNumber is called when production literalNumber is entered.
144
-func (s *BaseBPFListener) EnterLiteralNumber(ctx *LiteralNumberContext) {}
145
-
146
-// ExitLiteralNumber is called when production literalNumber is exited.
147
-func (s *BaseBPFListener) ExitLiteralNumber(ctx *LiteralNumberContext) {}
148
-
149
-// EnterIndirectX is called when production indirectX is entered.
150
-func (s *BaseBPFListener) EnterIndirectX(ctx *IndirectXContext) {}
151
-
152
-// ExitIndirectX is called when production indirectX is exited.
153
-func (s *BaseBPFListener) ExitIndirectX(ctx *IndirectXContext) {}
154
-
155
-// EnterAbsoluteNumber is called when production absoluteNumber is entered.
156
-func (s *BaseBPFListener) EnterAbsoluteNumber(ctx *AbsoluteNumberContext) {}
157
-
158
-// ExitAbsoluteNumber is called when production absoluteNumber is exited.
159
-func (s *BaseBPFListener) ExitAbsoluteNumber(ctx *AbsoluteNumberContext) {}
160
-
161
-// EnterRegisterA is called when production registerA is entered.
162
-func (s *BaseBPFListener) EnterRegisterA(ctx *RegisterAContext) {}
163
-
164
-// ExitRegisterA is called when production registerA is exited.
165
-func (s *BaseBPFListener) ExitRegisterA(ctx *RegisterAContext) {}
166
-
167
-// EnterRegisterX is called when production registerX is entered.
168
-func (s *BaseBPFListener) EnterRegisterX(ctx *RegisterXContext) {}
169
-
170
-// ExitRegisterX is called when production registerX is exited.
171
-func (s *BaseBPFListener) ExitRegisterX(ctx *RegisterXContext) {}
172
-
173
-// EnterRegisterR is called when production registerR is entered.
174
-func (s *BaseBPFListener) EnterRegisterR(ctx *RegisterRContext) {}
175
-
176
-// ExitRegisterR is called when production registerR is exited.
177
-func (s *BaseBPFListener) ExitRegisterR(ctx *RegisterRContext) {}
178
-
179
-// EnterExtension is called when production extension is entered.
180
-func (s *BaseBPFListener) EnterExtension(ctx *ExtensionContext) {}
181
-
182
-// ExitExtension is called when production extension is exited.
183
-func (s *BaseBPFListener) ExitExtension(ctx *ExtensionContext) {}

+ 0
- 116
internal/parser/bpf_base_visitor.go View File

@@ -1,116 +0,0 @@
1
-// Code generated from parser/BPF.g4 by ANTLR 4.7.2. DO NOT EDIT.
2
-
3
-package parser // BPF
4
-import "github.com/antlr/antlr4/runtime/Go/antlr"
5
-
6
-type BaseBPFVisitor struct {
7
-	*antlr.BaseParseTreeVisitor
8
-}
9
-
10
-func (v *BaseBPFVisitor) VisitProgram(ctx *ProgramContext) interface{} {
11
-	return v.VisitChildren(ctx)
12
-}
13
-
14
-func (v *BaseBPFVisitor) VisitLabelDefinition(ctx *LabelDefinitionContext) interface{} {
15
-	return v.VisitChildren(ctx)
16
-}
17
-
18
-func (v *BaseBPFVisitor) VisitLabel(ctx *LabelContext) interface{} {
19
-	return v.VisitChildren(ctx)
20
-}
21
-
22
-func (v *BaseBPFVisitor) VisitComment(ctx *CommentContext) interface{} {
23
-	return v.VisitChildren(ctx)
24
-}
25
-
26
-func (v *BaseBPFVisitor) VisitInstruction(ctx *InstructionContext) interface{} {
27
-	return v.VisitChildren(ctx)
28
-}
29
-
30
-func (v *BaseBPFVisitor) VisitAluOperation(ctx *AluOperationContext) interface{} {
31
-	return v.VisitChildren(ctx)
32
-}
33
-
34
-func (v *BaseBPFVisitor) VisitAluOperator(ctx *AluOperatorContext) interface{} {
35
-	return v.VisitChildren(ctx)
36
-}
37
-
38
-func (v *BaseBPFVisitor) VisitJumpOperation(ctx *JumpOperationContext) interface{} {
39
-	return v.VisitChildren(ctx)
40
-}
41
-
42
-func (v *BaseBPFVisitor) VisitJumpOperator(ctx *JumpOperatorContext) interface{} {
43
-	return v.VisitChildren(ctx)
44
-}
45
-
46
-func (v *BaseBPFVisitor) VisitJumpConditionalOperation(ctx *JumpConditionalOperationContext) interface{} {
47
-	return v.VisitChildren(ctx)
48
-}
49
-
50
-func (v *BaseBPFVisitor) VisitJumpConditionalOperator(ctx *JumpConditionalOperatorContext) interface{} {
51
-	return v.VisitChildren(ctx)
52
-}
53
-
54
-func (v *BaseBPFVisitor) VisitIfTrue(ctx *IfTrueContext) interface{} {
55
-	return v.VisitChildren(ctx)
56
-}
57
-
58
-func (v *BaseBPFVisitor) VisitIfFalse(ctx *IfFalseContext) interface{} {
59
-	return v.VisitChildren(ctx)
60
-}
61
-
62
-func (v *BaseBPFVisitor) VisitLoadOperation(ctx *LoadOperationContext) interface{} {
63
-	return v.VisitChildren(ctx)
64
-}
65
-
66
-func (v *BaseBPFVisitor) VisitLoadOperator(ctx *LoadOperatorContext) interface{} {
67
-	return v.VisitChildren(ctx)
68
-}
69
-
70
-func (v *BaseBPFVisitor) VisitStoreOperation(ctx *StoreOperationContext) interface{} {
71
-	return v.VisitChildren(ctx)
72
-}
73
-
74
-func (v *BaseBPFVisitor) VisitStoreOperator(ctx *StoreOperatorContext) interface{} {
75
-	return v.VisitChildren(ctx)
76
-}
77
-
78
-func (v *BaseBPFVisitor) VisitSimpleOperation(ctx *SimpleOperationContext) interface{} {
79
-	return v.VisitChildren(ctx)
80
-}
81
-
82
-func (v *BaseBPFVisitor) VisitReturnOperation(ctx *ReturnOperationContext) interface{} {
83
-	return v.VisitChildren(ctx)
84
-}
85
-
86
-func (v *BaseBPFVisitor) VisitNumber(ctx *NumberContext) interface{} {
87
-	return v.VisitChildren(ctx)
88
-}
89
-
90
-func (v *BaseBPFVisitor) VisitLiteralNumber(ctx *LiteralNumberContext) interface{} {
91
-	return v.VisitChildren(ctx)
92
-}
93
-
94
-func (v *BaseBPFVisitor) VisitIndirectX(ctx *IndirectXContext) interface{} {
95
-	return v.VisitChildren(ctx)
96
-}
97
-
98
-func (v *BaseBPFVisitor) VisitAbsoluteNumber(ctx *AbsoluteNumberContext) interface{} {
99
-	return v.VisitChildren(ctx)
100
-}
101
-
102
-func (v *BaseBPFVisitor) VisitRegisterA(ctx *RegisterAContext) interface{} {
103
-	return v.VisitChildren(ctx)
104
-}
105
-
106
-func (v *BaseBPFVisitor) VisitRegisterX(ctx *RegisterXContext) interface{} {
107
-	return v.VisitChildren(ctx)
108
-}
109
-
110
-func (v *BaseBPFVisitor) VisitRegisterR(ctx *RegisterRContext) interface{} {
111
-	return v.VisitChildren(ctx)
112
-}
113
-
114
-func (v *BaseBPFVisitor) VisitExtension(ctx *ExtensionContext) interface{} {
115
-	return v.VisitChildren(ctx)
116
-}

+ 0
- 90
internal/parser/bpf_visitor.go View File

@@ -1,90 +0,0 @@
1
-// Code generated from parser/BPF.g4 by ANTLR 4.7.2. DO NOT EDIT.
2
-
3
-package parser // BPF
4
-import "github.com/antlr/antlr4/runtime/Go/antlr"
5
-
6
-// A complete Visitor for a parse tree produced by BPFParser.
7
-type BPFVisitor interface {
8
-	antlr.ParseTreeVisitor
9
-
10
-	// Visit a parse tree produced by BPFParser#program.
11
-	VisitProgram(ctx *ProgramContext) interface{}
12
-
13
-	// Visit a parse tree produced by BPFParser#labelDefinition.
14
-	VisitLabelDefinition(ctx *LabelDefinitionContext) interface{}
15
-
16
-	// Visit a parse tree produced by BPFParser#label.
17
-	VisitLabel(ctx *LabelContext) interface{}
18
-
19
-	// Visit a parse tree produced by BPFParser#comment.
20
-	VisitComment(ctx *CommentContext) interface{}
21
-
22
-	// Visit a parse tree produced by BPFParser#instruction.
23
-	VisitInstruction(ctx *InstructionContext) interface{}
24
-
25
-	// Visit a parse tree produced by BPFParser#aluOperation.
26
-	VisitAluOperation(ctx *AluOperationContext) interface{}
27
-
28
-	// Visit a parse tree produced by BPFParser#aluOperator.
29
-	VisitAluOperator(ctx *AluOperatorContext) interface{}
30
-
31
-	// Visit a parse tree produced by BPFParser#jumpOperation.
32
-	VisitJumpOperation(ctx *JumpOperationContext) interface{}
33
-
34
-	// Visit a parse tree produced by BPFParser#jumpOperator.
35
-	VisitJumpOperator(ctx *JumpOperatorContext) interface{}
36
-
37
-	// Visit a parse tree produced by BPFParser#jumpConditionalOperation.
38
-	VisitJumpConditionalOperation(ctx *JumpConditionalOperationContext) interface{}
39
-
40
-	// Visit a parse tree produced by BPFParser#jumpConditionalOperator.
41
-	VisitJumpConditionalOperator(ctx *JumpConditionalOperatorContext) interface{}
42
-
43
-	// Visit a parse tree produced by BPFParser#ifTrue.
44
-	VisitIfTrue(ctx *IfTrueContext) interface{}
45
-
46
-	// Visit a parse tree produced by BPFParser#ifFalse.
47
-	VisitIfFalse(ctx *IfFalseContext) interface{}
48
-
49
-	// Visit a parse tree produced by BPFParser#loadOperation.
50
-	VisitLoadOperation(ctx *LoadOperationContext) interface{}
51
-
52
-	// Visit a parse tree produced by BPFParser#loadOperator.
53
-	VisitLoadOperator(ctx *LoadOperatorContext) interface{}
54
-
55
-	// Visit a parse tree produced by BPFParser#storeOperation.
56
-	VisitStoreOperation(ctx *StoreOperationContext) interface{}
57
-
58
-	// Visit a parse tree produced by BPFParser#storeOperator.
59
-	VisitStoreOperator(ctx *StoreOperatorContext) interface{}
60
-
61
-	// Visit a parse tree produced by BPFParser#simpleOperation.
62
-	VisitSimpleOperation(ctx *SimpleOperationContext) interface{}
63
-
64
-	// Visit a parse tree produced by BPFParser#returnOperation.
65
-	VisitReturnOperation(ctx *ReturnOperationContext) interface{}
66
-
67
-	// Visit a parse tree produced by BPFParser#number.
68
-	VisitNumber(ctx *NumberContext) interface{}
69
-
70
-	// Visit a parse tree produced by BPFParser#literalNumber.
71
-	VisitLiteralNumber(ctx *LiteralNumberContext) interface{}
72
-
73
-	// Visit a parse tree produced by BPFParser#indirectX.
74
-	VisitIndirectX(ctx *IndirectXContext) interface{}
75
-
76
-	// Visit a parse tree produced by BPFParser#absoluteNumber.
77
-	VisitAbsoluteNumber(ctx *AbsoluteNumberContext) interface{}
78
-
79
-	// Visit a parse tree produced by BPFParser#registerA.
80
-	VisitRegisterA(ctx *RegisterAContext) interface{}
81
-
82
-	// Visit a parse tree produced by BPFParser#registerX.
83
-	VisitRegisterX(ctx *RegisterXContext) interface{}
84
-
85
-	// Visit a parse tree produced by BPFParser#registerR.
86
-	VisitRegisterR(ctx *RegisterRContext) interface{}
87
-
88
-	// Visit a parse tree produced by BPFParser#extension.
89
-	VisitExtension(ctx *ExtensionContext) interface{}
90
-}

Loading…
Cancel
Save