tnt

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

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

type exampleListener struct {
	*tnt.BasetntListener
}

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

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

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

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewtntLexer

func NewtntLexer(input antlr.CharStream) *tntLexer

func NewtntParser

func NewtntParser(input antlr.TokenStream) *tntParser

Types

type AtomContext

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

func NewAtomContext

func NewAtomContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *AtomContext

func NewEmptyAtomContext

func NewEmptyAtomContext() *AtomContext

func (*AtomContext) EnterRule

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

func (*AtomContext) ExitRule

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

func (*AtomContext) GetParser

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

func (*AtomContext) GetRuleContext

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

func (*AtomContext) IsAtomContext

func (*AtomContext) IsAtomContext()

func (*AtomContext) Number

func (s *AtomContext) Number() INumberContext

func (*AtomContext) ToStringTree

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

func (*AtomContext) Variable

func (s *AtomContext) Variable() IVariableContext

type BasetntListener

type BasetntListener struct{}

BasetntListener is a complete listener for a parse tree produced by tntParser.

func (*BasetntListener) EnterAtom

func (s *BasetntListener) EnterAtom(ctx *AtomContext)

EnterAtom is called when production atom is entered.

func (*BasetntListener) EnterEquation

func (s *BasetntListener) EnterEquation(ctx *EquationContext)

EnterEquation is called when production equation is entered.

func (*BasetntListener) EnterEveryRule

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

EnterEveryRule is called when any rule is entered.

func (*BasetntListener) EnterExists

func (s *BasetntListener) EnterExists(ctx *ExistsContext)

EnterExists is called when production exists is entered.

func (*BasetntListener) EnterExpression

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

EnterExpression is called when production expression is entered.

func (*BasetntListener) EnterForevery

func (s *BasetntListener) EnterForevery(ctx *ForeveryContext)

EnterForevery is called when production forevery is entered.

func (*BasetntListener) EnterNumber

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

EnterNumber is called when production number is entered.

func (*BasetntListener) EnterVariable

func (s *BasetntListener) EnterVariable(ctx *VariableContext)

EnterVariable is called when production variable is entered.

func (*BasetntListener) ExitAtom

func (s *BasetntListener) ExitAtom(ctx *AtomContext)

ExitAtom is called when production atom is exited.

func (*BasetntListener) ExitEquation

func (s *BasetntListener) ExitEquation(ctx *EquationContext)

ExitEquation is called when production equation is exited.

func (*BasetntListener) ExitEveryRule

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

ExitEveryRule is called when any rule is exited.

func (*BasetntListener) ExitExists

func (s *BasetntListener) ExitExists(ctx *ExistsContext)

ExitExists is called when production exists is exited.

func (*BasetntListener) ExitExpression

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

ExitExpression is called when production expression is exited.

func (*BasetntListener) ExitForevery

func (s *BasetntListener) ExitForevery(ctx *ForeveryContext)

ExitForevery is called when production forevery is exited.

func (*BasetntListener) ExitNumber

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

ExitNumber is called when production number is exited.

func (*BasetntListener) ExitVariable

func (s *BasetntListener) ExitVariable(ctx *VariableContext)

ExitVariable is called when production variable is exited.

func (*BasetntListener) VisitErrorNode

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

VisitErrorNode is called when an error node is visited.

func (*BasetntListener) VisitTerminal

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

VisitTerminal is called when a terminal node is visited.

type EquationContext

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

func NewEmptyEquationContext

func NewEmptyEquationContext() *EquationContext

func NewEquationContext

func NewEquationContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *EquationContext

func (*EquationContext) AllExpression

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

func (*EquationContext) EnterRule

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

func (*EquationContext) ExitRule

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

func (*EquationContext) Expression

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

func (*EquationContext) GetParser

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

func (*EquationContext) GetRuleContext

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

func (*EquationContext) IsEquationContext

func (*EquationContext) IsEquationContext()

func (*EquationContext) ToStringTree

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

type ExistsContext

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

func NewEmptyExistsContext

func NewEmptyExistsContext() *ExistsContext

func NewExistsContext

func NewExistsContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ExistsContext

func (*ExistsContext) EXISTS

func (s *ExistsContext) EXISTS() antlr.TerminalNode

func (*ExistsContext) EnterRule

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

func (*ExistsContext) ExitRule

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

func (*ExistsContext) GetParser

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

func (*ExistsContext) GetRuleContext

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

func (*ExistsContext) IsExistsContext

func (*ExistsContext) IsExistsContext()

func (*ExistsContext) ToStringTree

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

func (*ExistsContext) Variable

func (s *ExistsContext) Variable() IVariableContext

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

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

func (*ExpressionContext) Atom

func (s *ExpressionContext) Atom() IAtomContext

func (*ExpressionContext) EnterRule

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

func (*ExpressionContext) Exists

func (s *ExpressionContext) Exists() IExistsContext

func (*ExpressionContext) ExitRule

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

func (*ExpressionContext) Expression

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

func (*ExpressionContext) Forevery

func (s *ExpressionContext) Forevery() IForeveryContext

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

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

type ForeveryContext

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

func NewEmptyForeveryContext

func NewEmptyForeveryContext() *ForeveryContext

func NewForeveryContext

func NewForeveryContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ForeveryContext

func (*ForeveryContext) EnterRule

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

func (*ForeveryContext) ExitRule

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

func (*ForeveryContext) FOREVERY

func (s *ForeveryContext) FOREVERY() antlr.TerminalNode

func (*ForeveryContext) GetParser

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

func (*ForeveryContext) GetRuleContext

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

func (*ForeveryContext) IsForeveryContext

func (*ForeveryContext) IsForeveryContext()

func (*ForeveryContext) ToStringTree

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

func (*ForeveryContext) Variable

func (s *ForeveryContext) Variable() IVariableContext

type IAtomContext

type IAtomContext interface {
	antlr.ParserRuleContext

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

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

IAtomContext is an interface to support dynamic dispatch.

type IEquationContext

type IEquationContext interface {
	antlr.ParserRuleContext

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

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

IEquationContext is an interface to support dynamic dispatch.

type IExistsContext

type IExistsContext interface {
	antlr.ParserRuleContext

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

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

IExistsContext is an interface to support dynamic dispatch.

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 IForeveryContext

type IForeveryContext interface {
	antlr.ParserRuleContext

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

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

IForeveryContext 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 IVariableContext

type IVariableContext interface {
	antlr.ParserRuleContext

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

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

IVariableContext is an interface to support dynamic dispatch.

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

func (s *NumberContext) AllSUCCESSOR() []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) SUCCESSOR

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

func (*NumberContext) ToStringTree

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

func (*NumberContext) ZERO

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

type VariableContext

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

func NewEmptyVariableContext

func NewEmptyVariableContext() *VariableContext

func NewVariableContext

func NewVariableContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *VariableContext

func (*VariableContext) A

func (*VariableContext) AllPRIME

func (s *VariableContext) AllPRIME() []antlr.TerminalNode

func (*VariableContext) AllSUCCESSOR

func (s *VariableContext) AllSUCCESSOR() []antlr.TerminalNode

func (*VariableContext) B

func (*VariableContext) C

func (*VariableContext) D

func (*VariableContext) E

func (*VariableContext) EnterRule

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

func (*VariableContext) ExitRule

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

func (*VariableContext) GetParser

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

func (*VariableContext) GetRuleContext

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

func (*VariableContext) IsVariableContext

func (*VariableContext) IsVariableContext()

func (*VariableContext) PRIME

func (s *VariableContext) PRIME(i int) antlr.TerminalNode

func (*VariableContext) SUCCESSOR

func (s *VariableContext) SUCCESSOR(i int) antlr.TerminalNode

func (*VariableContext) ToStringTree

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