redcode

package
v0.0.0-...-4c43aeb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 4, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Example
package main

import (
	"bramp.net/antlr4/redcode"

	"fmt"
	"github.com/antlr/antlr4/runtime/Go/antlr"
)

type exampleListener struct {
	*redcode.BaseredcodeListener
}

func (l *exampleListener) EnterEveryRule(ctx antlr.ParserRuleContext) {
	fmt.Println(ctx.GetText())
}
func main() {
	// Setup the input
	is := antlr.NewInputStream("...some text to parse...")

	// Create the Lexer
	lexer := redcode.NewredcodeLexer(is)
	stream := antlr.NewCommonTokenStream(lexer, antlr.TokenDefaultChannel)

	// Create the Parser
	p := redcode.NewredcodeParser(stream)
	p.BuildParseTrees = true
	p.AddErrorListener(antlr.NewDiagnosticErrorListener(true))

	// Finally walk the tree
	tree := p.File()
	antlr.ParseTreeWalkerDefault.Walk(&exampleListener{}, tree)
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewredcodeLexer

func NewredcodeLexer(input antlr.CharStream) *redcodeLexer

func NewredcodeParser

func NewredcodeParser(input antlr.TokenStream) *redcodeParser

Types

type BaseredcodeListener

type BaseredcodeListener struct{}

BaseredcodeListener is a complete listener for a parse tree produced by redcodeParser.

func (*BaseredcodeListener) EnterComment

func (s *BaseredcodeListener) EnterComment(ctx *CommentContext)

EnterComment is called when production comment is entered.

func (*BaseredcodeListener) EnterEveryRule

func (s *BaseredcodeListener) EnterEveryRule(ctx antlr.ParserRuleContext)

EnterEveryRule is called when any rule is entered.

func (*BaseredcodeListener) EnterFile

func (s *BaseredcodeListener) EnterFile(ctx *FileContext)

EnterFile is called when production file is entered.

func (*BaseredcodeListener) EnterInstruction

func (s *BaseredcodeListener) EnterInstruction(ctx *InstructionContext)

EnterInstruction is called when production instruction is entered.

func (*BaseredcodeListener) EnterLine

func (s *BaseredcodeListener) EnterLine(ctx *LineContext)

EnterLine is called when production line is entered.

func (*BaseredcodeListener) EnterMmode

func (s *BaseredcodeListener) EnterMmode(ctx *MmodeContext)

EnterMmode is called when production mmode is entered.

func (*BaseredcodeListener) EnterModifier

func (s *BaseredcodeListener) EnterModifier(ctx *ModifierContext)

EnterModifier is called when production modifier is entered.

func (*BaseredcodeListener) EnterNumber

func (s *BaseredcodeListener) EnterNumber(ctx *NumberContext)

EnterNumber is called when production number is entered.

func (*BaseredcodeListener) EnterOpcode

func (s *BaseredcodeListener) EnterOpcode(ctx *OpcodeContext)

EnterOpcode is called when production opcode is entered.

func (*BaseredcodeListener) ExitComment

func (s *BaseredcodeListener) ExitComment(ctx *CommentContext)

ExitComment is called when production comment is exited.

func (*BaseredcodeListener) ExitEveryRule

func (s *BaseredcodeListener) ExitEveryRule(ctx antlr.ParserRuleContext)

ExitEveryRule is called when any rule is exited.

func (*BaseredcodeListener) ExitFile

func (s *BaseredcodeListener) ExitFile(ctx *FileContext)

ExitFile is called when production file is exited.

func (*BaseredcodeListener) ExitInstruction

func (s *BaseredcodeListener) ExitInstruction(ctx *InstructionContext)

ExitInstruction is called when production instruction is exited.

func (*BaseredcodeListener) ExitLine

func (s *BaseredcodeListener) ExitLine(ctx *LineContext)

ExitLine is called when production line is exited.

func (*BaseredcodeListener) ExitMmode

func (s *BaseredcodeListener) ExitMmode(ctx *MmodeContext)

ExitMmode is called when production mmode is exited.

func (*BaseredcodeListener) ExitModifier

func (s *BaseredcodeListener) ExitModifier(ctx *ModifierContext)

ExitModifier is called when production modifier is exited.

func (*BaseredcodeListener) ExitNumber

func (s *BaseredcodeListener) ExitNumber(ctx *NumberContext)

ExitNumber is called when production number is exited.

func (*BaseredcodeListener) ExitOpcode

func (s *BaseredcodeListener) ExitOpcode(ctx *OpcodeContext)

ExitOpcode is called when production opcode is exited.

func (*BaseredcodeListener) VisitErrorNode

func (s *BaseredcodeListener) VisitErrorNode(node antlr.ErrorNode)

VisitErrorNode is called when an error node is visited.

func (*BaseredcodeListener) VisitTerminal

func (s *BaseredcodeListener) VisitTerminal(node antlr.TerminalNode)

VisitTerminal is called when a terminal node is visited.

type CommentContext

type CommentContext struct {
	*antlr.BaseParserRuleContext
	// contains filtered or unexported fields
}

func NewCommentContext

func NewCommentContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *CommentContext

func NewEmptyCommentContext

func NewEmptyCommentContext() *CommentContext

func (*CommentContext) COMMENT

func (s *CommentContext) COMMENT() antlr.TerminalNode

func (*CommentContext) EnterRule

func (s *CommentContext) EnterRule(listener antlr.ParseTreeListener)

func (*CommentContext) ExitRule

func (s *CommentContext) ExitRule(listener antlr.ParseTreeListener)

func (*CommentContext) GetParser

func (s *CommentContext) GetParser() antlr.Parser

func (*CommentContext) GetRuleContext

func (s *CommentContext) GetRuleContext() antlr.RuleContext

func (*CommentContext) IsCommentContext

func (*CommentContext) IsCommentContext()

func (*CommentContext) ToStringTree

func (s *CommentContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string

type FileContext

type FileContext struct {
	*antlr.BaseParserRuleContext
	// contains filtered or unexported fields
}

func NewEmptyFileContext

func NewEmptyFileContext() *FileContext

func NewFileContext

func NewFileContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *FileContext

func (*FileContext) AllLine

func (s *FileContext) AllLine() []ILineContext

func (*FileContext) EnterRule

func (s *FileContext) EnterRule(listener antlr.ParseTreeListener)

func (*FileContext) ExitRule

func (s *FileContext) ExitRule(listener antlr.ParseTreeListener)

func (*FileContext) GetParser

func (s *FileContext) GetParser() antlr.Parser

func (*FileContext) GetRuleContext

func (s *FileContext) GetRuleContext() antlr.RuleContext

func (*FileContext) IsFileContext

func (*FileContext) IsFileContext()

func (*FileContext) Line

func (s *FileContext) Line(i int) ILineContext

func (*FileContext) ToStringTree

func (s *FileContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string

type ICommentContext

type ICommentContext interface {
	antlr.ParserRuleContext

	// GetParser returns the parser.
	GetParser() antlr.Parser

	// IsCommentContext differentiates from other interfaces.
	IsCommentContext()
}

ICommentContext is an interface to support dynamic dispatch.

type IFileContext

type IFileContext interface {
	antlr.ParserRuleContext

	// GetParser returns the parser.
	GetParser() antlr.Parser

	// IsFileContext differentiates from other interfaces.
	IsFileContext()
}

IFileContext is an interface to support dynamic dispatch.

type IInstructionContext

type IInstructionContext interface {
	antlr.ParserRuleContext

	// GetParser returns the parser.
	GetParser() antlr.Parser

	// IsInstructionContext differentiates from other interfaces.
	IsInstructionContext()
}

IInstructionContext is an interface to support dynamic dispatch.

type ILineContext

type ILineContext interface {
	antlr.ParserRuleContext

	// GetParser returns the parser.
	GetParser() antlr.Parser

	// IsLineContext differentiates from other interfaces.
	IsLineContext()
}

ILineContext is an interface to support dynamic dispatch.

type IMmodeContext

type IMmodeContext interface {
	antlr.ParserRuleContext

	// GetParser returns the parser.
	GetParser() antlr.Parser

	// IsMmodeContext differentiates from other interfaces.
	IsMmodeContext()
}

IMmodeContext is an interface to support dynamic dispatch.

type IModifierContext

type IModifierContext interface {
	antlr.ParserRuleContext

	// GetParser returns the parser.
	GetParser() antlr.Parser

	// IsModifierContext differentiates from other interfaces.
	IsModifierContext()
}

IModifierContext is an interface to support dynamic dispatch.

type INumberContext

type INumberContext interface {
	antlr.ParserRuleContext

	// GetParser returns the parser.
	GetParser() antlr.Parser

	// IsNumberContext differentiates from other interfaces.
	IsNumberContext()
}

INumberContext is an interface to support dynamic dispatch.

type IOpcodeContext

type IOpcodeContext interface {
	antlr.ParserRuleContext

	// GetParser returns the parser.
	GetParser() antlr.Parser

	// IsOpcodeContext differentiates from other interfaces.
	IsOpcodeContext()
}

IOpcodeContext is an interface to support dynamic dispatch.

type InstructionContext

type InstructionContext struct {
	*antlr.BaseParserRuleContext
	// contains filtered or unexported fields
}

func NewEmptyInstructionContext

func NewEmptyInstructionContext() *InstructionContext

func NewInstructionContext

func NewInstructionContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *InstructionContext

func (*InstructionContext) AllMmode

func (s *InstructionContext) AllMmode() []IMmodeContext

func (*InstructionContext) AllNumber

func (s *InstructionContext) AllNumber() []INumberContext

func (*InstructionContext) Comment

func (s *InstructionContext) Comment() ICommentContext

func (*InstructionContext) EnterRule

func (s *InstructionContext) EnterRule(listener antlr.ParseTreeListener)

func (*InstructionContext) ExitRule

func (s *InstructionContext) ExitRule(listener antlr.ParseTreeListener)

func (*InstructionContext) GetParser

func (s *InstructionContext) GetParser() antlr.Parser

func (*InstructionContext) GetRuleContext

func (s *InstructionContext) GetRuleContext() antlr.RuleContext

func (*InstructionContext) IsInstructionContext

func (*InstructionContext) IsInstructionContext()

func (*InstructionContext) Mmode

func (s *InstructionContext) Mmode(i int) IMmodeContext

func (*InstructionContext) Modifier

func (s *InstructionContext) Modifier() IModifierContext

func (*InstructionContext) Number

func (s *InstructionContext) Number(i int) INumberContext

func (*InstructionContext) Opcode

func (s *InstructionContext) Opcode() IOpcodeContext

func (*InstructionContext) ToStringTree

func (s *InstructionContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string

type LineContext

type LineContext struct {
	*antlr.BaseParserRuleContext
	// contains filtered or unexported fields
}

func NewEmptyLineContext

func NewEmptyLineContext() *LineContext

func NewLineContext

func NewLineContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *LineContext

func (*LineContext) Comment

func (s *LineContext) Comment() ICommentContext

func (*LineContext) EOL

func (s *LineContext) EOL() antlr.TerminalNode

func (*LineContext) EnterRule

func (s *LineContext) EnterRule(listener antlr.ParseTreeListener)

func (*LineContext) ExitRule

func (s *LineContext) ExitRule(listener antlr.ParseTreeListener)

func (*LineContext) GetParser

func (s *LineContext) GetParser() antlr.Parser

func (*LineContext) GetRuleContext

func (s *LineContext) GetRuleContext() antlr.RuleContext

func (*LineContext) Instruction

func (s *LineContext) Instruction() IInstructionContext

func (*LineContext) IsLineContext

func (*LineContext) IsLineContext()

func (*LineContext) ToStringTree

func (s *LineContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string

type MmodeContext

type MmodeContext struct {
	*antlr.BaseParserRuleContext
	// contains filtered or unexported fields
}

func NewEmptyMmodeContext

func NewEmptyMmodeContext() *MmodeContext

func NewMmodeContext

func NewMmodeContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *MmodeContext

func (*MmodeContext) EnterRule

func (s *MmodeContext) EnterRule(listener antlr.ParseTreeListener)

func (*MmodeContext) ExitRule

func (s *MmodeContext) ExitRule(listener antlr.ParseTreeListener)

func (*MmodeContext) GetParser

func (s *MmodeContext) GetParser() antlr.Parser

func (*MmodeContext) GetRuleContext

func (s *MmodeContext) GetRuleContext() antlr.RuleContext

func (*MmodeContext) IsMmodeContext

func (*MmodeContext) IsMmodeContext()

func (*MmodeContext) ToStringTree

func (s *MmodeContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string

type ModifierContext

type ModifierContext struct {
	*antlr.BaseParserRuleContext
	// contains filtered or unexported fields
}

func NewEmptyModifierContext

func NewEmptyModifierContext() *ModifierContext

func NewModifierContext

func NewModifierContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ModifierContext

func (*ModifierContext) A

func (*ModifierContext) AB

func (*ModifierContext) B

func (*ModifierContext) BA

func (*ModifierContext) EnterRule

func (s *ModifierContext) EnterRule(listener antlr.ParseTreeListener)

func (*ModifierContext) ExitRule

func (s *ModifierContext) ExitRule(listener antlr.ParseTreeListener)

func (*ModifierContext) F

func (*ModifierContext) GetParser

func (s *ModifierContext) GetParser() antlr.Parser

func (*ModifierContext) GetRuleContext

func (s *ModifierContext) GetRuleContext() antlr.RuleContext

func (*ModifierContext) I

func (*ModifierContext) IsModifierContext

func (*ModifierContext) IsModifierContext()

func (*ModifierContext) ToStringTree

func (s *ModifierContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string

func (*ModifierContext) X

type NumberContext

type NumberContext struct {
	*antlr.BaseParserRuleContext
	// contains filtered or unexported fields
}

func NewEmptyNumberContext

func NewEmptyNumberContext() *NumberContext

func NewNumberContext

func NewNumberContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *NumberContext

func (*NumberContext) EnterRule

func (s *NumberContext) EnterRule(listener antlr.ParseTreeListener)

func (*NumberContext) ExitRule

func (s *NumberContext) ExitRule(listener antlr.ParseTreeListener)

func (*NumberContext) GetParser

func (s *NumberContext) GetParser() antlr.Parser

func (*NumberContext) GetRuleContext

func (s *NumberContext) GetRuleContext() antlr.RuleContext

func (*NumberContext) IsNumberContext

func (*NumberContext) IsNumberContext()

func (*NumberContext) NUMBER

func (s *NumberContext) NUMBER() antlr.TerminalNode

func (*NumberContext) ToStringTree

func (s *NumberContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string

type OpcodeContext

type OpcodeContext struct {
	*antlr.BaseParserRuleContext
	// contains filtered or unexported fields
}

func NewEmptyOpcodeContext

func NewEmptyOpcodeContext() *OpcodeContext

func NewOpcodeContext

func NewOpcodeContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *OpcodeContext

func (*OpcodeContext) ADD

func (s *OpcodeContext) ADD() antlr.TerminalNode

func (*OpcodeContext) CMP

func (s *OpcodeContext) CMP() antlr.TerminalNode

func (*OpcodeContext) DAT

func (s *OpcodeContext) DAT() antlr.TerminalNode

func (*OpcodeContext) DIV

func (s *OpcodeContext) DIV() antlr.TerminalNode

func (*OpcodeContext) DJN

func (s *OpcodeContext) DJN() antlr.TerminalNode

func (*OpcodeContext) DJZ

func (s *OpcodeContext) DJZ() antlr.TerminalNode

func (*OpcodeContext) EnterRule

func (s *OpcodeContext) EnterRule(listener antlr.ParseTreeListener)

func (*OpcodeContext) ExitRule

func (s *OpcodeContext) ExitRule(listener antlr.ParseTreeListener)

func (*OpcodeContext) GetParser

func (s *OpcodeContext) GetParser() antlr.Parser

func (*OpcodeContext) GetRuleContext

func (s *OpcodeContext) GetRuleContext() antlr.RuleContext

func (*OpcodeContext) IsOpcodeContext

func (*OpcodeContext) IsOpcodeContext()

func (*OpcodeContext) JMN

func (s *OpcodeContext) JMN() antlr.TerminalNode

func (*OpcodeContext) JMP

func (s *OpcodeContext) JMP() antlr.TerminalNode

func (*OpcodeContext) JMZ

func (s *OpcodeContext) JMZ() antlr.TerminalNode

func (*OpcodeContext) MOD

func (s *OpcodeContext) MOD() antlr.TerminalNode

func (*OpcodeContext) MOV

func (s *OpcodeContext) MOV() antlr.TerminalNode

func (*OpcodeContext) MUL

func (s *OpcodeContext) MUL() antlr.TerminalNode

func (*OpcodeContext) ORG

func (s *OpcodeContext) ORG() antlr.TerminalNode

func (*OpcodeContext) SLT

func (s *OpcodeContext) SLT() antlr.TerminalNode

func (*OpcodeContext) SPL

func (s *OpcodeContext) SPL() antlr.TerminalNode

func (*OpcodeContext) SUB

func (s *OpcodeContext) SUB() antlr.TerminalNode

func (*OpcodeContext) ToStringTree

func (s *OpcodeContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL