brainfuck

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/brainfuck"

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

type exampleListener struct {
	*brainfuck.BasebrainfuckListener
}

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 := brainfuck.NewbrainfuckLexer(is)
	stream := antlr.NewCommonTokenStream(lexer, antlr.TokenDefaultChannel)

	// Create the Parser
	p := brainfuck.NewbrainfuckParser(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 NewbrainfuckLexer

func NewbrainfuckLexer(input antlr.CharStream) *brainfuckLexer

func NewbrainfuckParser

func NewbrainfuckParser(input antlr.TokenStream) *brainfuckParser

Types

type BasebrainfuckListener

type BasebrainfuckListener struct{}

BasebrainfuckListener is a complete listener for a parse tree produced by brainfuckParser.

func (*BasebrainfuckListener) EnterEveryRule

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

EnterEveryRule is called when any rule is entered.

func (*BasebrainfuckListener) EnterFile

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

EnterFile is called when production file is entered.

func (*BasebrainfuckListener) EnterOpcode

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

EnterOpcode is called when production opcode is entered.

func (*BasebrainfuckListener) EnterStatement

func (s *BasebrainfuckListener) EnterStatement(ctx *StatementContext)

EnterStatement is called when production statement is entered.

func (*BasebrainfuckListener) ExitEveryRule

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

ExitEveryRule is called when any rule is exited.

func (*BasebrainfuckListener) ExitFile

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

ExitFile is called when production file is exited.

func (*BasebrainfuckListener) ExitOpcode

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

ExitOpcode is called when production opcode is exited.

func (*BasebrainfuckListener) ExitStatement

func (s *BasebrainfuckListener) ExitStatement(ctx *StatementContext)

ExitStatement is called when production statement is exited.

func (*BasebrainfuckListener) VisitErrorNode

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

VisitErrorNode is called when an error node is visited.

func (*BasebrainfuckListener) VisitTerminal

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

VisitTerminal is called when a terminal node is visited.

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) AllStatement

func (s *FileContext) AllStatement() []IStatementContext

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) Statement

func (s *FileContext) Statement(i int) IStatementContext

func (*FileContext) ToStringTree

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

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 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 IStatementContext

type IStatementContext interface {
	antlr.ParserRuleContext

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

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

IStatementContext is an interface to support dynamic dispatch.

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) COMMA

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

func (*OpcodeContext) DOT

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

func (*OpcodeContext) EnterRule

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

func (*OpcodeContext) ExitRule

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

func (*OpcodeContext) GT

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) LT

func (*OpcodeContext) MINUS

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

func (*OpcodeContext) PLUS

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

func (*OpcodeContext) ToStringTree

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

type StatementContext

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

func NewEmptyStatementContext

func NewEmptyStatementContext() *StatementContext

func NewStatementContext

func NewStatementContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *StatementContext

func (*StatementContext) AllStatement

func (s *StatementContext) AllStatement() []IStatementContext

func (*StatementContext) EnterRule

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

func (*StatementContext) ExitRule

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

func (*StatementContext) GetParser

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

func (*StatementContext) GetRuleContext

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

func (*StatementContext) IsStatementContext

func (*StatementContext) IsStatementContext()

func (*StatementContext) LPAREN

func (s *StatementContext) LPAREN() antlr.TerminalNode

func (*StatementContext) Opcode

func (s *StatementContext) Opcode() IOpcodeContext

func (*StatementContext) RPAREN

func (s *StatementContext) RPAREN() antlr.TerminalNode

func (*StatementContext) Statement

func (s *StatementContext) Statement(i int) IStatementContext

func (*StatementContext) ToStringTree

func (s *StatementContext) 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