Browse Source

Renamed BPF ANTLR module to Assembler

tags/v1.0.0
maze 9 months ago
parent
commit
d833dee66c

+ 2
- 2
.gitignore View File

@@ -19,5 +19,5 @@
.idea/

# Antlr artifacts
parser/*.interp
parser/*.tokens
*.interp
*.tokens

+ 13
- 0
Makefile View File

@@ -0,0 +1,13 @@
all: build

build: build-linux build-darwin build-windows

build-linux:
GOOS=linux GOARCH=amd64 go build -v -o build/bpfasm

build-darwin:
GOOS=darwin GOARCH=amd64 go build -v -o build/bpfasm-darwin

build-windows:
GOOS=windows GOARCH=amd64 go build -v -o build/bpfasm.exe
GOOS=windows GOARCH=386 go build -v -o build/bpfasm-x86.exe

+ 3
- 3
assembler.go View File

@@ -1,4 +1,4 @@
//go:generate antlr -package parser -Dlanguage=Go -visitor parser/BPF.g4
//go:generate antlr -package parser -Dlanguage=Go -visitor internal/parser/Assembler.g4

// Copyright (c) 2019 Wijnand Modderman-Lenstra. All rights reserved.
// Use of this source code is governed by a BSD-style
@@ -27,9 +27,9 @@ func (p Program) Assemble() ([]bpf.RawInstruction, error) {
func Assemble(source string) (Program, error) {
var (
input = antlr.NewInputStream(source)
lexer = parser.NewBPFLexer(input)
lexer = parser.NewAssemblerLexer(input)
stream = antlr.NewCommonTokenStream(lexer, 0)
parse = parser.NewBPFParser(stream)
parse = parser.NewAssemblerParser(stream)
)
parse.BuildParseTrees = true


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

@@ -1,4 +1,4 @@
grammar BPF;
grammar Assembler;

program
: (labelDefinition | labelDefinition? instruction)+ EOF

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

@@ -1,122 +0,0 @@
token literal names:
null
':'
','
'#'
'['
'x'
'+'
']'
'r'
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null

token symbolic names:
null
null
null
null
null
null
null
null
null
ADD
SUB
MUL
DIV
MOD
AND
OR
XOR
LSH
RSH
JA
JEQ
JNE
JLT
JLE
JGT
JGE
JSE
LDA
LDX
LDB
LDH
STA
STX
TAX
TXA
NEG
RET
NUMBER
COMMENT
IDENTIFIER
WHITESPACE
REGA
REGX

rule names:
program
labelDefinition
label
comment
instruction
aluOperation
aluOperator
jumpOperation
jumpOperator
jumpConditionalOperation
jumpConditionalOperator
ifTrue
ifFalse
loadOperation
loadOperator
storeOperation
storeOperator
simpleOperation
returnOperation
number
literalNumber
indirectX
absoluteNumber
registerA
registerX
registerR
extension


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

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

@@ -0,0 +1,249 @@
grammar C;

program
: block EOF
;

block
: stat* retstat?
;

stat
: ';'
| varlist '=' explist
| functioncall
| label
| 'break'
| 'goto' NAME
| 'if' exp 'then' block ('elseif' exp 'then' block)* ('else' block)? 'end'
| 'function' funcname funcbody
;

retstat
: 'return' explist? ';'?
;

label
: NAME ':'
;

funcname
: NAME (':' NAME)?
;

varlist
: var (',' var)*
;

namelist
: NAME (',' NAME)*
;

explist
: exp (',' exp)*
;

exp
: 'null' | 'false' | 'true'
| number
| string
| functiondef
| prefixexp
| <assoc=right> exp operatorPower exp
| operatorUnary exp
| exp operatorMulDivMod exp
| exp operatorAddSub exp
| <assoc=right> exp operatorStrcat exp
| exp operatorComparison exp
| exp operatorAnd exp
| exp operatorOr exp
| exp operatorBitwise exp
;

prefixexp
: varOrExp nameAndArgs*
;

functioncall
: varOrExp nameAndArgs+
;

varOrExp
: var | '(' exp ')'
;

var
: (NAME | '(' exp ')' varSuffix) varSuffix*
;

varSuffix
: nameAndArgs* ('[' exp ']' | '.' NAME)
;

nameAndArgs
: (':' NAME)? args
;

args
: '(' explist? ')' | tableconstructor | string
;

functiondef
: 'function' funcbody
;

funcbody
: '(' parlist? ')' block 'end'
;

parlist
: namelist (',' '...')? | '...'
;

tableconstructor
: '{' fieldlist? '}'
;

fieldlist
: field (fieldsep field)* fieldsep?
;

field
: '[' exp ']' '=' exp | NAME '=' exp | exp
;

fieldsep
: ',' | ';'
;

operatorOr
: 'or';

operatorAnd
: 'and';

operatorComparison
: '<' | '>' | '<=' | '>=' | '~=' | '==';

operatorStrcat
: '..';

operatorAddSub
: '+' | '-';

operatorMulDivMod
: '*' | '/' | '%' | '//';

operatorBitwise
: '&' | '|' | '~' | '<<' | '>>';

operatorUnary
: 'not' | '#' | '-' | '~';

operatorPower
: '^';

number
: INT | HEX | FLOAT | HEX_FLOAT
;

string
: NORMALSTRING | CHARSTRING | LONGSTRING
;

NAME
: [a-zA-Z_][a-zA-Z_0-9]*
;

NORMALSTRING
: '"' ( EscapeSequence | ~('\\'|'"') )* '"'
;

CHARSTRING
: '\'' ( EscapeSequence | ~('\''|'\\') )* '\''
;

LONGSTRING
: '[' NESTED_STR ']'
;

fragment
NESTED_STR
: '=' NESTED_STR '='
| '[' .*? ']'
;

INT
: Digit+
;

HEX
: '0' [xX] HexDigit+
;

FLOAT
: Digit+ '.' Digit* ExponentPart?
| '.' Digit+ ExponentPart?
| Digit+ ExponentPart
;

HEX_FLOAT
: '0' [xX] HexDigit+ '.' HexDigit* HexExponentPart?
| '0' [xX] '.' HexDigit+ HexExponentPart?
| '0' [xX] HexDigit+ HexExponentPart
;

fragment
ExponentPart
: [eE] [+-]? Digit+
;

fragment
HexExponentPart
: [pP] [+-]? Digit+
;

fragment
EscapeSequence
: '\\' [abfnrtvz"'\\]
| '\\' '\r'? '\n'
| DecimalEscape
| HexEscape
| UtfEscape
;

fragment
DecimalEscape
: '\\' Digit
| '\\' Digit Digit
| '\\' [0-2] Digit Digit
;

fragment
HexEscape
: '\\' 'x' HexDigit HexDigit
;
fragment
UtfEscape
: '\\' 'u{' HexDigit+ '}'
;
fragment
Digit
: [0-9]
;
fragment
HexDigit
: [0-9a-fA-F]
;

BLOCK_COMMENT
: '/*' .*? '*/' -> skip
;

LINE_COMMENT
: '//' ~[\r\n]* -> skip
;

WS
: [ \t\u000C\r\n]+ -> skip
;

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

@@ -0,0 +1,183 @@
// Code generated from internal/parser/Assembler.g4 by ANTLR 4.7.2. DO NOT EDIT.

package parser // Assembler
import "github.com/antlr/antlr4/runtime/Go/antlr"

// BaseAssemblerListener is a complete listener for a parse tree produced by AssemblerParser.
type BaseAssemblerListener struct{}

var _ AssemblerListener = &BaseAssemblerListener{}

// VisitTerminal is called when a terminal node is visited.
func (s *BaseAssemblerListener) VisitTerminal(node antlr.TerminalNode) {}

// VisitErrorNode is called when an error node is visited.
func (s *BaseAssemblerListener) VisitErrorNode(node antlr.ErrorNode) {}

// EnterEveryRule is called when any rule is entered.
func (s *BaseAssemblerListener) EnterEveryRule(ctx antlr.ParserRuleContext) {}

// ExitEveryRule is called when any rule is exited.
func (s *BaseAssemblerListener) ExitEveryRule(ctx antlr.ParserRuleContext) {}

// EnterProgram is called when production program is entered.
func (s *BaseAssemblerListener) EnterProgram(ctx *ProgramContext) {}

// ExitProgram is called when production program is exited.
func (s *BaseAssemblerListener) ExitProgram(ctx *ProgramContext) {}

// EnterLabelDefinition is called when production labelDefinition is entered.
func (s *BaseAssemblerListener) EnterLabelDefinition(ctx *LabelDefinitionContext) {}

// ExitLabelDefinition is called when production labelDefinition is exited.
func (s *BaseAssemblerListener) ExitLabelDefinition(ctx *LabelDefinitionContext) {}

// EnterLabel is called when production label is entered.
func (s *BaseAssemblerListener) EnterLabel(ctx *LabelContext) {}

// ExitLabel is called when production label is exited.
func (s *BaseAssemblerListener) ExitLabel(ctx *LabelContext) {}

// EnterComment is called when production comment is entered.
func (s *BaseAssemblerListener) EnterComment(ctx *CommentContext) {}

// ExitComment is called when production comment is exited.
func (s *BaseAssemblerListener) ExitComment(ctx *CommentContext) {}

// EnterInstruction is called when production instruction is entered.
func (s *BaseAssemblerListener) EnterInstruction(ctx *InstructionContext) {}

// ExitInstruction is called when production instruction is exited.
func (s *BaseAssemblerListener) ExitInstruction(ctx *InstructionContext) {}

// EnterAluOperation is called when production aluOperation is entered.
func (s *BaseAssemblerListener) EnterAluOperation(ctx *AluOperationContext) {}

// ExitAluOperation is called when production aluOperation is exited.
func (s *BaseAssemblerListener) ExitAluOperation(ctx *AluOperationContext) {}

// EnterAluOperator is called when production aluOperator is entered.
func (s *BaseAssemblerListener) EnterAluOperator(ctx *AluOperatorContext) {}

// ExitAluOperator is called when production aluOperator is exited.
func (s *BaseAssemblerListener) ExitAluOperator(ctx *AluOperatorContext) {}

// EnterJumpOperation is called when production jumpOperation is entered.
func (s *BaseAssemblerListener) EnterJumpOperation(ctx *JumpOperationContext) {}

// ExitJumpOperation is called when production jumpOperation is exited.
func (s *BaseAssemblerListener) ExitJumpOperation(ctx *JumpOperationContext) {}

// EnterJumpOperator is called when production jumpOperator is entered.
func (s *BaseAssemblerListener) EnterJumpOperator(ctx *JumpOperatorContext) {}

// ExitJumpOperator is called when production jumpOperator is exited.
func (s *BaseAssemblerListener) ExitJumpOperator(ctx *JumpOperatorContext) {}

// EnterJumpConditionalOperation is called when production jumpConditionalOperation is entered.
func (s *BaseAssemblerListener) EnterJumpConditionalOperation(ctx *JumpConditionalOperationContext) {}

// ExitJumpConditionalOperation is called when production jumpConditionalOperation is exited.
func (s *BaseAssemblerListener) ExitJumpConditionalOperation(ctx *JumpConditionalOperationContext) {}

// EnterJumpConditionalOperator is called when production jumpConditionalOperator is entered.
func (s *BaseAssemblerListener) EnterJumpConditionalOperator(ctx *JumpConditionalOperatorContext) {}

// ExitJumpConditionalOperator is called when production jumpConditionalOperator is exited.
func (s *BaseAssemblerListener) ExitJumpConditionalOperator(ctx *JumpConditionalOperatorContext) {}

// EnterIfTrue is called when production ifTrue is entered.
func (s *BaseAssemblerListener) EnterIfTrue(ctx *IfTrueContext) {}

// ExitIfTrue is called when production ifTrue is exited.
func (s *BaseAssemblerListener) ExitIfTrue(ctx *IfTrueContext) {}

// EnterIfFalse is called when production ifFalse is entered.
func (s *BaseAssemblerListener) EnterIfFalse(ctx *IfFalseContext) {}

// ExitIfFalse is called when production ifFalse is exited.
func (s *BaseAssemblerListener) ExitIfFalse(ctx *IfFalseContext) {}

// EnterLoadOperation is called when production loadOperation is entered.
func (s *BaseAssemblerListener) EnterLoadOperation(ctx *LoadOperationContext) {}

// ExitLoadOperation is called when production loadOperation is exited.
func (s *BaseAssemblerListener) ExitLoadOperation(ctx *LoadOperationContext) {}

// EnterLoadOperator is called when production loadOperator is entered.
func (s *BaseAssemblerListener) EnterLoadOperator(ctx *LoadOperatorContext) {}

// ExitLoadOperator is called when production loadOperator is exited.
func (s *BaseAssemblerListener) ExitLoadOperator(ctx *LoadOperatorContext) {}

// EnterStoreOperation is called when production storeOperation is entered.
func (s *BaseAssemblerListener) EnterStoreOperation(ctx *StoreOperationContext) {}

// ExitStoreOperation is called when production storeOperation is exited.
func (s *BaseAssemblerListener) ExitStoreOperation(ctx *StoreOperationContext) {}

// EnterStoreOperator is called when production storeOperator is entered.
func (s *BaseAssemblerListener) EnterStoreOperator(ctx *StoreOperatorContext) {}

// ExitStoreOperator is called when production storeOperator is exited.
func (s *BaseAssemblerListener) ExitStoreOperator(ctx *StoreOperatorContext) {}

// EnterSimpleOperation is called when production simpleOperation is entered.
func (s *BaseAssemblerListener) EnterSimpleOperation(ctx *SimpleOperationContext) {}

// ExitSimpleOperation is called when production simpleOperation is exited.
func (s *BaseAssemblerListener) ExitSimpleOperation(ctx *SimpleOperationContext) {}

// EnterReturnOperation is called when production returnOperation is entered.
func (s *BaseAssemblerListener) EnterReturnOperation(ctx *ReturnOperationContext) {}

// ExitReturnOperation is called when production returnOperation is exited.
func (s *BaseAssemblerListener) ExitReturnOperation(ctx *ReturnOperationContext) {}

// EnterNumber is called when production number is entered.
func (s *BaseAssemblerListener) EnterNumber(ctx *NumberContext) {}

// ExitNumber is called when production number is exited.
func (s *BaseAssemblerListener) ExitNumber(ctx *NumberContext) {}

// EnterLiteralNumber is called when production literalNumber is entered.
func (s *BaseAssemblerListener) EnterLiteralNumber(ctx *LiteralNumberContext) {}

// ExitLiteralNumber is called when production literalNumber is exited.
func (s *BaseAssemblerListener) ExitLiteralNumber(ctx *LiteralNumberContext) {}

// EnterIndirectX is called when production indirectX is entered.
func (s *BaseAssemblerListener) EnterIndirectX(ctx *IndirectXContext) {}

// ExitIndirectX is called when production indirectX is exited.
func (s *BaseAssemblerListener) ExitIndirectX(ctx *IndirectXContext) {}

// EnterAbsoluteNumber is called when production absoluteNumber is entered.
func (s *BaseAssemblerListener) EnterAbsoluteNumber(ctx *AbsoluteNumberContext) {}

// ExitAbsoluteNumber is called when production absoluteNumber is exited.
func (s *BaseAssemblerListener) ExitAbsoluteNumber(ctx *AbsoluteNumberContext) {}

// EnterRegisterA is called when production registerA is entered.
func (s *BaseAssemblerListener) EnterRegisterA(ctx *RegisterAContext) {}

// ExitRegisterA is called when production registerA is exited.
func (s *BaseAssemblerListener) ExitRegisterA(ctx *RegisterAContext) {}

// EnterRegisterX is called when production registerX is entered.
func (s *BaseAssemblerListener) EnterRegisterX(ctx *RegisterXContext) {}

// ExitRegisterX is called when production registerX is exited.
func (s *BaseAssemblerListener) ExitRegisterX(ctx *RegisterXContext) {}

// EnterRegisterR is called when production registerR is entered.
func (s *BaseAssemblerListener) EnterRegisterR(ctx *RegisterRContext) {}

// ExitRegisterR is called when production registerR is exited.
func (s *BaseAssemblerListener) ExitRegisterR(ctx *RegisterRContext) {}

// EnterExtension is called when production extension is entered.
func (s *BaseAssemblerListener) EnterExtension(ctx *ExtensionContext) {}

// ExitExtension is called when production extension is exited.
func (s *BaseAssemblerListener) ExitExtension(ctx *ExtensionContext) {}

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

@@ -0,0 +1,116 @@
// Code generated from internal/parser/Assembler.g4 by ANTLR 4.7.2. DO NOT EDIT.

package parser // Assembler
import "github.com/antlr/antlr4/runtime/Go/antlr"

type BaseAssemblerVisitor struct {
*antlr.BaseParseTreeVisitor
}

func (v *BaseAssemblerVisitor) VisitProgram(ctx *ProgramContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseAssemblerVisitor) VisitLabelDefinition(ctx *LabelDefinitionContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseAssemblerVisitor) VisitLabel(ctx *LabelContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseAssemblerVisitor) VisitComment(ctx *CommentContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseAssemblerVisitor) VisitInstruction(ctx *InstructionContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseAssemblerVisitor) VisitAluOperation(ctx *AluOperationContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseAssemblerVisitor) VisitAluOperator(ctx *AluOperatorContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseAssemblerVisitor) VisitJumpOperation(ctx *JumpOperationContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseAssemblerVisitor) VisitJumpOperator(ctx *JumpOperatorContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseAssemblerVisitor) VisitJumpConditionalOperation(ctx *JumpConditionalOperationContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseAssemblerVisitor) VisitJumpConditionalOperator(ctx *JumpConditionalOperatorContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseAssemblerVisitor) VisitIfTrue(ctx *IfTrueContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseAssemblerVisitor) VisitIfFalse(ctx *IfFalseContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseAssemblerVisitor) VisitLoadOperation(ctx *LoadOperationContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseAssemblerVisitor) VisitLoadOperator(ctx *LoadOperatorContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseAssemblerVisitor) VisitStoreOperation(ctx *StoreOperationContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseAssemblerVisitor) VisitStoreOperator(ctx *StoreOperatorContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseAssemblerVisitor) VisitSimpleOperation(ctx *SimpleOperationContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseAssemblerVisitor) VisitReturnOperation(ctx *ReturnOperationContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseAssemblerVisitor) VisitNumber(ctx *NumberContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseAssemblerVisitor) VisitLiteralNumber(ctx *LiteralNumberContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseAssemblerVisitor) VisitIndirectX(ctx *IndirectXContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseAssemblerVisitor) VisitAbsoluteNumber(ctx *AbsoluteNumberContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseAssemblerVisitor) VisitRegisterA(ctx *RegisterAContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseAssemblerVisitor) VisitRegisterX(ctx *RegisterXContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseAssemblerVisitor) VisitRegisterR(ctx *RegisterRContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseAssemblerVisitor) VisitExtension(ctx *ExtensionContext) interface{} {
return v.VisitChildren(ctx)
}

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

@@ -1,4 +1,4 @@
// Code generated from parser/BPF.g4 by ANTLR 4.7.2. DO NOT EDIT.
// Code generated from internal/parser/Assembler.g4 by ANTLR 4.7.2. DO NOT EDIT.

package parser

@@ -233,7 +233,7 @@ var lexerRuleNames = []string{
"REGA", "REGX",
}

type BPFLexer struct {
type AssemblerLexer struct {
*antlr.BaseLexer
channelNames []string
modeNames []string
@@ -248,9 +248,9 @@ func init() {
}
}

func NewBPFLexer(input antlr.CharStream) *BPFLexer {
func NewAssemblerLexer(input antlr.CharStream) *AssemblerLexer {

l := new(BPFLexer)
l := new(AssemblerLexer)

l.BaseLexer = antlr.NewBaseLexer(input)
l.Interpreter = antlr.NewLexerATNSimulator(l, lexerAtn, lexerDecisionToDFA, antlr.NewPredictionContextCache())
@@ -260,54 +260,54 @@ func NewBPFLexer(input antlr.CharStream) *BPFLexer {
l.RuleNames = lexerRuleNames
l.LiteralNames = lexerLiteralNames
l.SymbolicNames = lexerSymbolicNames
l.GrammarFileName = "BPF.g4"
l.GrammarFileName = "Assembler.g4"
// TODO: l.EOF = antlr.TokenEOF

return l
}

// BPFLexer tokens.
// AssemblerLexer tokens.
const (
BPFLexerT__0 = 1
BPFLexerT__1 = 2
BPFLexerT__2 = 3
BPFLexerT__3 = 4
BPFLexerT__4 = 5
BPFLexerT__5 = 6
BPFLexerT__6 = 7
BPFLexerT__7 = 8
BPFLexerADD = 9
BPFLexerSUB = 10
BPFLexerMUL = 11
BPFLexerDIV = 12
BPFLexerMOD = 13
BPFLexerAND = 14
BPFLexerOR = 15
BPFLexerXOR = 16
BPFLexerLSH = 17
BPFLexerRSH = 18
BPFLexerJA = 19
BPFLexerJEQ = 20
BPFLexerJNE = 21
BPFLexerJLT = 22
BPFLexerJLE = 23
BPFLexerJGT = 24
BPFLexerJGE = 25
BPFLexerJSE = 26
BPFLexerLDA = 27
BPFLexerLDX = 28
BPFLexerLDB = 29
BPFLexerLDH = 30
BPFLexerSTA = 31
BPFLexerSTX = 32
BPFLexerTAX = 33
BPFLexerTXA = 34
BPFLexerNEG = 35
BPFLexerRET = 36
BPFLexerNUMBER = 37
BPFLexerCOMMENT = 38
BPFLexerIDENTIFIER = 39
BPFLexerWHITESPACE = 40
BPFLexerREGA = 41
BPFLexerREGX = 42
AssemblerLexerT__0 = 1
AssemblerLexerT__1 = 2
AssemblerLexerT__2 = 3
AssemblerLexerT__3 = 4
AssemblerLexerT__4 = 5
AssemblerLexerT__5 = 6
AssemblerLexerT__6 = 7
AssemblerLexerT__7 = 8
AssemblerLexerADD = 9
AssemblerLexerSUB = 10
AssemblerLexerMUL = 11
AssemblerLexerDIV = 12
AssemblerLexerMOD = 13
AssemblerLexerAND = 14
AssemblerLexerOR = 15
AssemblerLexerXOR = 16
AssemblerLexerLSH = 17
AssemblerLexerRSH = 18
AssemblerLexerJA = 19
AssemblerLexerJEQ = 20
AssemblerLexerJNE = 21
AssemblerLexerJLT = 22
AssemblerLexerJLE = 23
AssemblerLexerJGT = 24
AssemblerLexerJGE = 25
AssemblerLexerJSE = 26
AssemblerLexerLDA = 27
AssemblerLexerLDX = 28
AssemblerLexerLDB = 29
AssemblerLexerLDH = 30
AssemblerLexerSTA = 31
AssemblerLexerSTX = 32
AssemblerLexerTAX = 33
AssemblerLexerTXA = 34
AssemblerLexerNEG = 35
AssemblerLexerRET = 36
AssemblerLexerNUMBER = 37
AssemblerLexerCOMMENT = 38
AssemblerLexerIDENTIFIER = 39
AssemblerLexerWHITESPACE = 40
AssemblerLexerREGA = 41
AssemblerLexerREGX = 42
)

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

@@ -1,10 +1,10 @@
// Code generated from parser/BPF.g4 by ANTLR 4.7.2. DO NOT EDIT.
// Code generated from internal/parser/Assembler.g4 by ANTLR 4.7.2. DO NOT EDIT.

package parser // BPF
package parser // Assembler
import "github.com/antlr/antlr4/runtime/Go/antlr"

// BPFListener is a complete listener for a parse tree produced by BPFParser.
type BPFListener interface {
// AssemblerListener is a complete listener for a parse tree produced by AssemblerParser.
type AssemblerListener interface {
antlr.ParseTreeListener

// 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 @@
// Code generated from internal/parser/Assembler.g4 by ANTLR 4.7.2. DO NOT EDIT.

package parser // Assembler
import "github.com/antlr/antlr4/runtime/Go/antlr"

// A complete Visitor for a parse tree produced by AssemblerParser.
type AssemblerVisitor interface {
antlr.ParseTreeVisitor

// Visit a parse tree produced by AssemblerParser#program.
VisitProgram(ctx *ProgramContext) interface{}

// Visit a parse tree produced by AssemblerParser#labelDefinition.
VisitLabelDefinition(ctx *LabelDefinitionContext) interface{}

// Visit a parse tree produced by AssemblerParser#label.
VisitLabel(ctx *LabelContext) interface{}

// Visit a parse tree produced by AssemblerParser#comment.
VisitComment(ctx *CommentContext) interface{}

// Visit a parse tree produced by AssemblerParser#instruction.
VisitInstruction(ctx *InstructionContext) interface{}

// Visit a parse tree produced by AssemblerParser#aluOperation.
VisitAluOperation(ctx *AluOperationContext) interface{}

// Visit a parse tree produced by AssemblerParser#aluOperator.
VisitAluOperator(ctx *AluOperatorContext) interface{}

// Visit a parse tree produced by AssemblerParser#jumpOperation.
VisitJumpOperation(ctx *JumpOperationContext) interface{}

// Visit a parse tree produced by AssemblerParser#jumpOperator.
VisitJumpOperator(ctx *JumpOperatorContext) interface{}

// Visit a parse tree produced by AssemblerParser#jumpConditionalOperation.
VisitJumpConditionalOperation(ctx *JumpConditionalOperationContext) interface{}

// Visit a parse tree produced by AssemblerParser#jumpConditionalOperator.
VisitJumpConditionalOperator(ctx *JumpConditionalOperatorContext) interface{}

// Visit a parse tree produced by AssemblerParser#ifTrue.
VisitIfTrue(ctx *IfTrueContext) interface{}

// Visit a parse tree produced by AssemblerParser#ifFalse.
VisitIfFalse(ctx *IfFalseContext) interface{}

// Visit a parse tree produced by AssemblerParser#loadOperation.
VisitLoadOperation(ctx *LoadOperationContext) interface{}

// Visit a parse tree produced by AssemblerParser#loadOperator.
VisitLoadOperator(ctx *LoadOperatorContext) interface{}

// Visit a parse tree produced by AssemblerParser#storeOperation.
VisitStoreOperation(ctx *StoreOperationContext) interface{}

// Visit a parse tree produced by AssemblerParser#storeOperator.
VisitStoreOperator(ctx *StoreOperatorContext) interface{}

// Visit a parse tree produced by AssemblerParser#simpleOperation.
VisitSimpleOperation(ctx *SimpleOperationContext) interface{}

// Visit a parse tree produced by AssemblerParser#returnOperation.
VisitReturnOperation(ctx *ReturnOperationContext) interface{}

// Visit a parse tree produced by AssemblerParser#number.
VisitNumber(ctx *NumberContext) interface{}

// Visit a parse tree produced by AssemblerParser#literalNumber.
VisitLiteralNumber(ctx *LiteralNumberContext) interface{}

// Visit a parse tree produced by AssemblerParser#indirectX.
VisitIndirectX(ctx *IndirectXContext) interface{}

// Visit a parse tree produced by AssemblerParser#absoluteNumber.
VisitAbsoluteNumber(ctx *AbsoluteNumberContext) interface{}

// Visit a parse tree produced by AssemblerParser#registerA.
VisitRegisterA(ctx *RegisterAContext) interface{}

// Visit a parse tree produced by AssemblerParser#registerX.
VisitRegisterX(ctx *RegisterXContext) interface{}

// Visit a parse tree produced by AssemblerParser#registerR.
VisitRegisterR(ctx *RegisterRContext) interface{}

// Visit a parse tree produced by AssemblerParser#extension.
VisitExtension(ctx *ExtensionContext) interface{}
}

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

@@ -1,183 +0,0 @@
// Code generated from parser/BPF.g4 by ANTLR 4.7.2. DO NOT EDIT.

package parser // BPF
import "github.com/antlr/antlr4/runtime/Go/antlr"

// BaseBPFListener is a complete listener for a parse tree produced by BPFParser.
type BaseBPFListener struct{}

var _ BPFListener = &BaseBPFListener{}

// VisitTerminal is called when a terminal node is visited.
func (s *BaseBPFListener) VisitTerminal(node antlr.TerminalNode) {}

// VisitErrorNode is called when an error node is visited.
func (s *BaseBPFListener) VisitErrorNode(node antlr.ErrorNode) {}

// EnterEveryRule is called when any rule is entered.
func (s *BaseBPFListener) EnterEveryRule(ctx antlr.ParserRuleContext) {}

// ExitEveryRule is called when any rule is exited.
func (s *BaseBPFListener) ExitEveryRule(ctx antlr.ParserRuleContext) {}

// EnterProgram is called when production program is entered.
func (s *BaseBPFListener) EnterProgram(ctx *ProgramContext) {}

// ExitProgram is called when production program is exited.
func (s *BaseBPFListener) ExitProgram(ctx *ProgramContext) {}

// EnterLabelDefinition is called when production labelDefinition is entered.
func (s *BaseBPFListener) EnterLabelDefinition(ctx *LabelDefinitionContext) {}

// ExitLabelDefinition is called when production labelDefinition is exited.
func (s *BaseBPFListener) ExitLabelDefinition(ctx *LabelDefinitionContext) {}

// EnterLabel is called when production label is entered.
func (s *BaseBPFListener) EnterLabel(ctx *LabelContext) {}

// ExitLabel is called when production label is exited.
func (s *BaseBPFListener) ExitLabel(ctx *LabelContext) {}

// EnterComment is called when production comment is entered.
func (s *BaseBPFListener) EnterComment(ctx *CommentContext) {}

// ExitComment is called when production comment is exited.
func (s *BaseBPFListener) ExitComment(ctx *CommentContext) {}

// EnterInstruction is called when production instruction is entered.
func (s *BaseBPFListener) EnterInstruction(ctx *InstructionContext) {}

// ExitInstruction is called when production instruction is exited.
func (s *BaseBPFListener) ExitInstruction(ctx *InstructionContext) {}

// EnterAluOperation is called when production aluOperation is entered.
func (s *BaseBPFListener) EnterAluOperation(ctx *AluOperationContext) {}

// ExitAluOperation is called when production aluOperation is exited.
func (s *BaseBPFListener) ExitAluOperation(ctx *AluOperationContext) {}

// EnterAluOperator is called when production aluOperator is entered.
func (s *BaseBPFListener) EnterAluOperator(ctx *AluOperatorContext) {}

// ExitAluOperator is called when production aluOperator is exited.
func (s *BaseBPFListener) ExitAluOperator(ctx *AluOperatorContext) {}

// EnterJumpOperation is called when production jumpOperation is entered.
func (s *BaseBPFListener) EnterJumpOperation(ctx *JumpOperationContext) {}

// ExitJumpOperation is called when production jumpOperation is exited.
func (s *BaseBPFListener) ExitJumpOperation(ctx *JumpOperationContext) {}

// EnterJumpOperator is called when production jumpOperator is entered.
func (s *BaseBPFListener) EnterJumpOperator(ctx *JumpOperatorContext) {}

// ExitJumpOperator is called when production jumpOperator is exited.
func (s *BaseBPFListener) ExitJumpOperator(ctx *JumpOperatorContext) {}

// EnterJumpConditionalOperation is called when production jumpConditionalOperation is entered.
func (s *BaseBPFListener) EnterJumpConditionalOperation(ctx *JumpConditionalOperationContext) {}

// ExitJumpConditionalOperation is called when production jumpConditionalOperation is exited.
func (s *BaseBPFListener) ExitJumpConditionalOperation(ctx *JumpConditionalOperationContext) {}

// EnterJumpConditionalOperator is called when production jumpConditionalOperator is entered.
func (s *BaseBPFListener) EnterJumpConditionalOperator(ctx *JumpConditionalOperatorContext) {}

// ExitJumpConditionalOperator is called when production jumpConditionalOperator is exited.
func (s *BaseBPFListener) ExitJumpConditionalOperator(ctx *JumpConditionalOperatorContext) {}

// EnterIfTrue is called when production ifTrue is entered.
func (s *BaseBPFListener) EnterIfTrue(ctx *IfTrueContext) {}

// ExitIfTrue is called when production ifTrue is exited.
func (s *BaseBPFListener) ExitIfTrue(ctx *IfTrueContext) {}

// EnterIfFalse is called when production ifFalse is entered.
func (s *BaseBPFListener) EnterIfFalse(ctx *IfFalseContext) {}

// ExitIfFalse is called when production ifFalse is exited.
func (s *BaseBPFListener) ExitIfFalse(ctx *IfFalseContext) {}

// EnterLoadOperation is called when production loadOperation is entered.
func (s *BaseBPFListener) EnterLoadOperation(ctx *LoadOperationContext) {}

// ExitLoadOperation is called when production loadOperation is exited.
func (s *BaseBPFListener) ExitLoadOperation(ctx *LoadOperationContext) {}

// EnterLoadOperator is called when production loadOperator is entered.
func (s *BaseBPFListener) EnterLoadOperator(ctx *LoadOperatorContext) {}

// ExitLoadOperator is called when production loadOperator is exited.
func (s *BaseBPFListener) ExitLoadOperator(ctx *LoadOperatorContext) {}

// EnterStoreOperation is called when production storeOperation is entered.
func (s *BaseBPFListener) EnterStoreOperation(ctx *StoreOperationContext) {}

// ExitStoreOperation is called when production storeOperation is exited.
func (s *BaseBPFListener) ExitStoreOperation(ctx *StoreOperationContext) {}

// EnterStoreOperator is called when production storeOperator is entered.
func (s *BaseBPFListener) EnterStoreOperator(ctx *StoreOperatorContext) {}

// ExitStoreOperator is called when production storeOperator is exited.
func (s *BaseBPFListener) ExitStoreOperator(ctx *StoreOperatorContext) {}

// EnterSimpleOperation is called when production simpleOperation is entered.
func (s *BaseBPFListener) EnterSimpleOperation(ctx *SimpleOperationContext) {}

// ExitSimpleOperation is called when production simpleOperation is exited.
func (s *BaseBPFListener) ExitSimpleOperation(ctx *SimpleOperationContext) {}

// EnterReturnOperation is called when production returnOperation is entered.
func (s *BaseBPFListener) EnterReturnOperation(ctx *ReturnOperationContext) {}

// ExitReturnOperation is called when production returnOperation is exited.
func (s *BaseBPFListener) ExitReturnOperation(ctx *ReturnOperationContext) {}

// EnterNumber is called when production number is entered.
func (s *BaseBPFListener) EnterNumber(ctx *NumberContext) {}

// ExitNumber is called when production number is exited.
func (s *BaseBPFListener) ExitNumber(ctx *NumberContext) {}

// EnterLiteralNumber is called when production literalNumber is entered.
func (s *BaseBPFListener) EnterLiteralNumber(ctx *LiteralNumberContext) {}

// ExitLiteralNumber is called when production literalNumber is exited.
func (s *BaseBPFListener) ExitLiteralNumber(ctx *LiteralNumberContext) {}

// EnterIndirectX is called when production indirectX is entered.
func (s *BaseBPFListener) EnterIndirectX(ctx *IndirectXContext) {}

// ExitIndirectX is called when production indirectX is exited.
func (s *BaseBPFListener) ExitIndirectX(ctx *IndirectXContext) {}

// EnterAbsoluteNumber is called when production absoluteNumber is entered.
func (s *BaseBPFListener) EnterAbsoluteNumber(ctx *AbsoluteNumberContext) {}

// ExitAbsoluteNumber is called when production absoluteNumber is exited.
func (s *BaseBPFListener) ExitAbsoluteNumber(ctx *AbsoluteNumberContext) {}

// EnterRegisterA is called when production registerA is entered.
func (s *BaseBPFListener) EnterRegisterA(ctx *RegisterAContext) {}

// ExitRegisterA is called when production registerA is exited.
func (s *BaseBPFListener) ExitRegisterA(ctx *RegisterAContext) {}

// EnterRegisterX is called when production registerX is entered.
func (s *BaseBPFListener) EnterRegisterX(ctx *RegisterXContext) {}

// ExitRegisterX is called when production registerX is exited.
func (s *BaseBPFListener) ExitRegisterX(ctx *RegisterXContext) {}

// EnterRegisterR is called when production registerR is entered.
func (s *BaseBPFListener) EnterRegisterR(ctx *RegisterRContext) {}

// ExitRegisterR is called when production registerR is exited.
func (s *BaseBPFListener) ExitRegisterR(ctx *RegisterRContext) {}

// EnterExtension is called when production extension is entered.
func (s *BaseBPFListener) EnterExtension(ctx *ExtensionContext) {}

// ExitExtension is called when production extension is exited.
func (s *BaseBPFListener) ExitExtension(ctx *ExtensionContext) {}

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

@@ -1,116 +0,0 @@
// Code generated from parser/BPF.g4 by ANTLR 4.7.2. DO NOT EDIT.

package parser // BPF
import "github.com/antlr/antlr4/runtime/Go/antlr"

type BaseBPFVisitor struct {
*antlr.BaseParseTreeVisitor
}

func (v *BaseBPFVisitor) VisitProgram(ctx *ProgramContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseBPFVisitor) VisitLabelDefinition(ctx *LabelDefinitionContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseBPFVisitor) VisitLabel(ctx *LabelContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseBPFVisitor) VisitComment(ctx *CommentContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseBPFVisitor) VisitInstruction(ctx *InstructionContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseBPFVisitor) VisitAluOperation(ctx *AluOperationContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseBPFVisitor) VisitAluOperator(ctx *AluOperatorContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseBPFVisitor) VisitJumpOperation(ctx *JumpOperationContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseBPFVisitor) VisitJumpOperator(ctx *JumpOperatorContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseBPFVisitor) VisitJumpConditionalOperation(ctx *JumpConditionalOperationContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseBPFVisitor) VisitJumpConditionalOperator(ctx *JumpConditionalOperatorContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseBPFVisitor) VisitIfTrue(ctx *IfTrueContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseBPFVisitor) VisitIfFalse(ctx *IfFalseContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseBPFVisitor) VisitLoadOperation(ctx *LoadOperationContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseBPFVisitor) VisitLoadOperator(ctx *LoadOperatorContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseBPFVisitor) VisitStoreOperation(ctx *StoreOperationContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseBPFVisitor) VisitStoreOperator(ctx *StoreOperatorContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseBPFVisitor) VisitSimpleOperation(ctx *SimpleOperationContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseBPFVisitor) VisitReturnOperation(ctx *ReturnOperationContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseBPFVisitor) VisitNumber(ctx *NumberContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseBPFVisitor) VisitLiteralNumber(ctx *LiteralNumberContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseBPFVisitor) VisitIndirectX(ctx *IndirectXContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseBPFVisitor) VisitAbsoluteNumber(ctx *AbsoluteNumberContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseBPFVisitor) VisitRegisterA(ctx *RegisterAContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseBPFVisitor) VisitRegisterX(ctx *RegisterXContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseBPFVisitor) VisitRegisterR(ctx *RegisterRContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseBPFVisitor) VisitExtension(ctx *ExtensionContext) interface{} {
return v.VisitChildren(ctx)
}

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

@@ -1,90 +0,0 @@
// Code generated from parser/BPF.g4 by ANTLR 4.7.2. DO NOT EDIT.

package parser // BPF
import "github.com/antlr/antlr4/runtime/Go/antlr"

// A complete Visitor for a parse tree produced by BPFParser.
type BPFVisitor interface {
antlr.ParseTreeVisitor

// Visit a parse tree produced by BPFParser#program.
VisitProgram(ctx *ProgramContext) interface{}

// Visit a parse tree produced by BPFParser#labelDefinition.
VisitLabelDefinition(ctx *LabelDefinitionContext) interface{}

// Visit a parse tree produced by BPFParser#label.
VisitLabel(ctx *LabelContext) interface{}

// Visit a parse tree produced by BPFParser#comment.
VisitComment(ctx *CommentContext) interface{}

// Visit a parse tree produced by BPFParser#instruction.
VisitInstruction(ctx *InstructionContext) interface{}

// Visit a parse tree produced by BPFParser#aluOperation.
VisitAluOperation(ctx *AluOperationContext) interface{}

// Visit a parse tree produced by BPFParser#aluOperator.
VisitAluOperator(ctx *AluOperatorContext) interface{}

// Visit a parse tree produced by BPFParser#jumpOperation.
VisitJumpOperation(ctx *JumpOperationContext) interface{}

// Visit a parse tree produced by BPFParser#jumpOperator.
VisitJumpOperator(ctx *JumpOperatorContext) interface{}

// Visit a parse tree produced by BPFParser#jumpConditionalOperation.
VisitJumpConditionalOperation(ctx *JumpConditionalOperationContext) interface{}

// Visit a parse tree produced by BPFParser#jumpConditionalOperator.
VisitJumpConditionalOperator(ctx *JumpConditionalOperatorContext) interface{}

// Visit a parse tree produced by BPFParser#ifTrue.
VisitIfTrue(ctx *IfTrueContext) interface{}

// Visit a parse tree produced by BPFParser#ifFalse.
VisitIfFalse(ctx *IfFalseContext) interface{}

// Visit a parse tree produced by BPFParser#loadOperation.
VisitLoadOperation(ctx *LoadOperationContext) interface{}

// Visit a parse tree produced by BPFParser#loadOperator.
VisitLoadOperator(ctx *LoadOperatorContext) interface{}

// Visit a parse tree produced by BPFParser#storeOperation.
VisitStoreOperation(ctx *StoreOperationContext) interface{}

// Visit a parse tree produced by BPFParser#storeOperator.
VisitStoreOperator(ctx *StoreOperatorContext) interface{}

// Visit a parse tree produced by BPFParser#simpleOperation.
VisitSimpleOperation(ctx *SimpleOperationContext) interface{}

// Visit a parse tree produced by BPFParser#returnOperation.
VisitReturnOperation(ctx *ReturnOperationContext) interface{}

// Visit a parse tree produced by BPFParser#number.
VisitNumber(ctx *NumberContext) interface{}

// Visit a parse tree produced by BPFParser#literalNumber.
VisitLiteralNumber(ctx *LiteralNumberContext) interface{}

// Visit a parse tree produced by BPFParser#indirectX.
VisitIndirectX(ctx *IndirectXContext) interface{}

// Visit a parse tree produced by BPFParser#absoluteNumber.
VisitAbsoluteNumber(ctx *AbsoluteNumberContext) interface{}

// Visit a parse tree produced by BPFParser#registerA.
VisitRegisterA(ctx *RegisterAContext) interface{}

// Visit a parse tree produced by BPFParser#registerX.
VisitRegisterX(ctx *RegisterXContext) interface{}

// Visit a parse tree produced by BPFParser#registerR.
VisitRegisterR(ctx *RegisterRContext) interface{}

// Visit a parse tree produced by BPFParser#extension.
VisitExtension(ctx *ExtensionContext) interface{}
}

Loading…
Cancel
Save