tinybasic

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

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

type exampleListener struct {
	*tinybasic.BasetinybasicListener
}

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

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

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

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewtinybasicLexer

func NewtinybasicLexer(input antlr.CharStream) *tinybasicLexer

func NewtinybasicParser

func NewtinybasicParser(input antlr.TokenStream) *tinybasicParser

Types

type BasetinybasicListener

type BasetinybasicListener struct{}

BasetinybasicListener is a complete listener for a parse tree produced by tinybasicParser.

func (*BasetinybasicListener) EnterEveryRule

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

EnterEveryRule is called when any rule is entered.

func (*BasetinybasicListener) EnterExpression

func (s *BasetinybasicListener) EnterExpression(ctx *ExpressionContext)

EnterExpression is called when production expression is entered.

func (*BasetinybasicListener) EnterExprlist

func (s *BasetinybasicListener) EnterExprlist(ctx *ExprlistContext)

EnterExprlist is called when production exprlist is entered.

func (*BasetinybasicListener) EnterFactor

func (s *BasetinybasicListener) EnterFactor(ctx *FactorContext)

EnterFactor is called when production factor is entered.

func (*BasetinybasicListener) EnterLine

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

EnterLine is called when production line is entered.

func (*BasetinybasicListener) EnterNumber

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

EnterNumber is called when production number is entered.

func (*BasetinybasicListener) EnterProgram

func (s *BasetinybasicListener) EnterProgram(ctx *ProgramContext)

EnterProgram is called when production program is entered.

func (*BasetinybasicListener) EnterRelop

func (s *BasetinybasicListener) EnterRelop(ctx *RelopContext)

EnterRelop is called when production relop is entered.

func (*BasetinybasicListener) EnterStatement

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

EnterStatement is called when production statement is entered.

func (*BasetinybasicListener) EnterTerm

func (s *BasetinybasicListener) EnterTerm(ctx *TermContext)

EnterTerm is called when production term is entered.

func (*BasetinybasicListener) EnterVara

func (s *BasetinybasicListener) EnterVara(ctx *VaraContext)

EnterVara is called when production vara is entered.

func (*BasetinybasicListener) EnterVarlist

func (s *BasetinybasicListener) EnterVarlist(ctx *VarlistContext)

EnterVarlist is called when production varlist is entered.

func (*BasetinybasicListener) ExitEveryRule

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

ExitEveryRule is called when any rule is exited.

func (*BasetinybasicListener) ExitExpression

func (s *BasetinybasicListener) ExitExpression(ctx *ExpressionContext)

ExitExpression is called when production expression is exited.

func (*BasetinybasicListener) ExitExprlist

func (s *BasetinybasicListener) ExitExprlist(ctx *ExprlistContext)

ExitExprlist is called when production exprlist is exited.

func (*BasetinybasicListener) ExitFactor

func (s *BasetinybasicListener) ExitFactor(ctx *FactorContext)

ExitFactor is called when production factor is exited.

func (*BasetinybasicListener) ExitLine

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

ExitLine is called when production line is exited.

func (*BasetinybasicListener) ExitNumber

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

ExitNumber is called when production number is exited.

func (*BasetinybasicListener) ExitProgram

func (s *BasetinybasicListener) ExitProgram(ctx *ProgramContext)

ExitProgram is called when production program is exited.

func (*BasetinybasicListener) ExitRelop

func (s *BasetinybasicListener) ExitRelop(ctx *RelopContext)

ExitRelop is called when production relop is exited.

func (*BasetinybasicListener) ExitStatement

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

ExitStatement is called when production statement is exited.

func (*BasetinybasicListener) ExitTerm

func (s *BasetinybasicListener) ExitTerm(ctx *TermContext)

ExitTerm is called when production term is exited.

func (*BasetinybasicListener) ExitVara

func (s *BasetinybasicListener) ExitVara(ctx *VaraContext)

ExitVara is called when production vara is exited.

func (*BasetinybasicListener) ExitVarlist

func (s *BasetinybasicListener) ExitVarlist(ctx *VarlistContext)

ExitVarlist is called when production varlist is exited.

func (*BasetinybasicListener) VisitErrorNode

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

VisitErrorNode is called when an error node is visited.

func (*BasetinybasicListener) VisitTerminal

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

VisitTerminal is called when a terminal node is visited.

type ExpressionContext

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

func NewEmptyExpressionContext

func NewEmptyExpressionContext() *ExpressionContext

func NewExpressionContext

func NewExpressionContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ExpressionContext

func (*ExpressionContext) AllTerm

func (s *ExpressionContext) AllTerm() []ITermContext

func (*ExpressionContext) EnterRule

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

func (*ExpressionContext) ExitRule

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

func (*ExpressionContext) GetParser

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

func (*ExpressionContext) GetRuleContext

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

func (*ExpressionContext) IsExpressionContext

func (*ExpressionContext) IsExpressionContext()

func (*ExpressionContext) Term

func (s *ExpressionContext) Term(i int) ITermContext

func (*ExpressionContext) ToStringTree

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

type ExprlistContext

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

func NewEmptyExprlistContext

func NewEmptyExprlistContext() *ExprlistContext

func NewExprlistContext

func NewExprlistContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ExprlistContext

func (*ExprlistContext) AllExpression

func (s *ExprlistContext) AllExpression() []IExpressionContext

func (*ExprlistContext) AllSTRING

func (s *ExprlistContext) AllSTRING() []antlr.TerminalNode

func (*ExprlistContext) EnterRule

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

func (*ExprlistContext) ExitRule

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

func (*ExprlistContext) Expression

func (s *ExprlistContext) Expression(i int) IExpressionContext

func (*ExprlistContext) GetParser

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

func (*ExprlistContext) GetRuleContext

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

func (*ExprlistContext) IsExprlistContext

func (*ExprlistContext) IsExprlistContext()

func (*ExprlistContext) STRING

func (s *ExprlistContext) STRING(i int) antlr.TerminalNode

func (*ExprlistContext) ToStringTree

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

type FactorContext

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

func NewEmptyFactorContext

func NewEmptyFactorContext() *FactorContext

func NewFactorContext

func NewFactorContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *FactorContext

func (*FactorContext) EnterRule

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

func (*FactorContext) ExitRule

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

func (*FactorContext) GetParser

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

func (*FactorContext) GetRuleContext

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

func (*FactorContext) IsFactorContext

func (*FactorContext) IsFactorContext()

func (*FactorContext) Number

func (s *FactorContext) Number() INumberContext

func (*FactorContext) ToStringTree

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

func (*FactorContext) Vara

func (s *FactorContext) Vara() IVaraContext

type IExpressionContext

type IExpressionContext interface {
	antlr.ParserRuleContext

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

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

IExpressionContext is an interface to support dynamic dispatch.

type IExprlistContext

type IExprlistContext interface {
	antlr.ParserRuleContext

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

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

IExprlistContext is an interface to support dynamic dispatch.

type IFactorContext

type IFactorContext interface {
	antlr.ParserRuleContext

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

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

IFactorContext 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 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 IProgramContext

type IProgramContext interface {
	antlr.ParserRuleContext

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

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

IProgramContext is an interface to support dynamic dispatch.

type IRelopContext

type IRelopContext interface {
	antlr.ParserRuleContext

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

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

IRelopContext 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 ITermContext

type ITermContext interface {
	antlr.ParserRuleContext

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

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

ITermContext is an interface to support dynamic dispatch.

type IVaraContext

type IVaraContext interface {
	antlr.ParserRuleContext

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

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

IVaraContext is an interface to support dynamic dispatch.

type IVarlistContext

type IVarlistContext interface {
	antlr.ParserRuleContext

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

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

IVarlistContext is an interface to support dynamic dispatch.

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

func (s *LineContext) CR() 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) IsLineContext

func (*LineContext) IsLineContext()

func (*LineContext) Number

func (s *LineContext) Number() INumberContext

func (*LineContext) Statement

func (s *LineContext) Statement() IStatementContext

func (*LineContext) ToStringTree

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

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

func (s *NumberContext) AllDIGIT() []antlr.TerminalNode

func (*NumberContext) DIGIT

func (s *NumberContext) DIGIT(i int) antlr.TerminalNode

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

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

type ProgramContext

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

func NewEmptyProgramContext

func NewEmptyProgramContext() *ProgramContext

func NewProgramContext

func NewProgramContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ProgramContext

func (*ProgramContext) AllLine

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

func (*ProgramContext) EnterRule

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

func (*ProgramContext) ExitRule

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

func (*ProgramContext) GetParser

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

func (*ProgramContext) GetRuleContext

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

func (*ProgramContext) IsProgramContext

func (*ProgramContext) IsProgramContext()

func (*ProgramContext) Line

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

func (*ProgramContext) ToStringTree

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

type RelopContext

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

func NewEmptyRelopContext

func NewEmptyRelopContext() *RelopContext

func NewRelopContext

func NewRelopContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *RelopContext

func (*RelopContext) EnterRule

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

func (*RelopContext) ExitRule

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

func (*RelopContext) GetParser

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

func (*RelopContext) GetRuleContext

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

func (*RelopContext) IsRelopContext

func (*RelopContext) IsRelopContext()

func (*RelopContext) ToStringTree

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

func (s *StatementContext) AllExpression() []IExpressionContext

func (*StatementContext) EnterRule

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

func (*StatementContext) ExitRule

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

func (*StatementContext) Expression

func (s *StatementContext) Expression(i int) IExpressionContext

func (*StatementContext) Exprlist

func (s *StatementContext) Exprlist() IExprlistContext

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

func (s *StatementContext) Number() INumberContext

func (*StatementContext) Relop

func (s *StatementContext) Relop() IRelopContext

func (*StatementContext) Statement

func (s *StatementContext) Statement() IStatementContext

func (*StatementContext) ToStringTree

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

func (*StatementContext) Vara

func (s *StatementContext) Vara() IVaraContext

func (*StatementContext) Varlist

func (s *StatementContext) Varlist() IVarlistContext

type TermContext

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

func NewEmptyTermContext

func NewEmptyTermContext() *TermContext

func NewTermContext

func NewTermContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TermContext

func (*TermContext) AllFactor

func (s *TermContext) AllFactor() []IFactorContext

func (*TermContext) EnterRule

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

func (*TermContext) ExitRule

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

func (*TermContext) Factor

func (s *TermContext) Factor(i int) IFactorContext

func (*TermContext) GetParser

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

func (*TermContext) GetRuleContext

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

func (*TermContext) IsTermContext

func (*TermContext) IsTermContext()

func (*TermContext) ToStringTree

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

type VaraContext

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

func NewEmptyVaraContext

func NewEmptyVaraContext() *VaraContext

func NewVaraContext

func NewVaraContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *VaraContext

func (*VaraContext) EnterRule

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

func (*VaraContext) ExitRule

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

func (*VaraContext) GetParser

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

func (*VaraContext) GetRuleContext

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

func (*VaraContext) IsVaraContext

func (*VaraContext) IsVaraContext()

func (*VaraContext) STRING

func (s *VaraContext) STRING() antlr.TerminalNode

func (*VaraContext) ToStringTree

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

func (*VaraContext) VAR

func (s *VaraContext) VAR() antlr.TerminalNode

type VarlistContext

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

func NewEmptyVarlistContext

func NewEmptyVarlistContext() *VarlistContext

func NewVarlistContext

func NewVarlistContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *VarlistContext

func (*VarlistContext) AllVara

func (s *VarlistContext) AllVara() []IVaraContext

func (*VarlistContext) EnterRule

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

func (*VarlistContext) ExitRule

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

func (*VarlistContext) GetParser

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

func (*VarlistContext) GetRuleContext

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

func (*VarlistContext) IsVarlistContext

func (*VarlistContext) IsVarlistContext()

func (*VarlistContext) ToStringTree

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

func (*VarlistContext) Vara

func (s *VarlistContext) Vara(i int) IVaraContext

Jump to

Keyboard shortcuts

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