p

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

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

type exampleListener struct {
	*p.BasepListener
}

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

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

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

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewpLexer

func NewpLexer(input antlr.CharStream) *pLexer

func NewpParser

func NewpParser(input antlr.TokenStream) *pParser

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

func (*AtomContext) R

func (*AtomContext) ToStringTree

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

type BasepListener

type BasepListener struct{}

BasepListener is a complete listener for a parse tree produced by pParser.

func (*BasepListener) EnterAtom

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

EnterAtom is called when production atom is entered.

func (*BasepListener) EnterEveryRule

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

EnterEveryRule is called when any rule is entered.

func (*BasepListener) EnterIterate

func (s *BasepListener) EnterIterate(ctx *IterateContext)

EnterIterate is called when production iterate is entered.

func (*BasepListener) EnterProg

func (s *BasepListener) EnterProg(ctx *ProgContext)

EnterProg is called when production prog is entered.

func (*BasepListener) EnterSymbol

func (s *BasepListener) EnterSymbol(ctx *SymbolContext)

EnterSymbol is called when production symbol is entered.

func (*BasepListener) ExitAtom

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

ExitAtom is called when production atom is exited.

func (*BasepListener) ExitEveryRule

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

ExitEveryRule is called when any rule is exited.

func (*BasepListener) ExitIterate

func (s *BasepListener) ExitIterate(ctx *IterateContext)

ExitIterate is called when production iterate is exited.

func (*BasepListener) ExitProg

func (s *BasepListener) ExitProg(ctx *ProgContext)

ExitProg is called when production prog is exited.

func (*BasepListener) ExitSymbol

func (s *BasepListener) ExitSymbol(ctx *SymbolContext)

ExitSymbol is called when production symbol is exited.

func (*BasepListener) VisitErrorNode

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

VisitErrorNode is called when an error node is visited.

func (*BasepListener) VisitTerminal

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

VisitTerminal is called when a terminal node is visited.

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 IIterateContext

type IIterateContext interface {
	antlr.ParserRuleContext

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

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

IIterateContext is an interface to support dynamic dispatch.

type IProgContext

type IProgContext interface {
	antlr.ParserRuleContext

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

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

IProgContext is an interface to support dynamic dispatch.

type ISymbolContext

type ISymbolContext interface {
	antlr.ParserRuleContext

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

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

ISymbolContext is an interface to support dynamic dispatch.

type IterateContext

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

func NewEmptyIterateContext

func NewEmptyIterateContext() *IterateContext

func NewIterateContext

func NewIterateContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *IterateContext

func (*IterateContext) AllSymbol

func (s *IterateContext) AllSymbol() []ISymbolContext

func (*IterateContext) EnterRule

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

func (*IterateContext) ExitRule

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

func (*IterateContext) GetParser

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

func (*IterateContext) GetRuleContext

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

func (*IterateContext) IsIterateContext

func (*IterateContext) IsIterateContext()

func (*IterateContext) Symbol

func (s *IterateContext) Symbol(i int) ISymbolContext

func (*IterateContext) ToStringTree

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

type ProgContext

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

func NewEmptyProgContext

func NewEmptyProgContext() *ProgContext

func NewProgContext

func NewProgContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ProgContext

func (*ProgContext) AllSymbol

func (s *ProgContext) AllSymbol() []ISymbolContext

func (*ProgContext) EnterRule

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

func (*ProgContext) ExitRule

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

func (*ProgContext) GetParser

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

func (*ProgContext) GetRuleContext

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

func (*ProgContext) IsProgContext

func (*ProgContext) IsProgContext()

func (*ProgContext) Symbol

func (s *ProgContext) Symbol(i int) ISymbolContext

func (*ProgContext) ToStringTree

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

type SymbolContext

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

func NewEmptySymbolContext

func NewEmptySymbolContext() *SymbolContext

func NewSymbolContext

func NewSymbolContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *SymbolContext

func (*SymbolContext) Atom

func (s *SymbolContext) Atom() IAtomContext

func (*SymbolContext) EnterRule

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

func (*SymbolContext) ExitRule

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

func (*SymbolContext) GetParser

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

func (*SymbolContext) GetRuleContext

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

func (*SymbolContext) IsSymbolContext

func (*SymbolContext) IsSymbolContext()

func (*SymbolContext) Iterate

func (s *SymbolContext) Iterate() IIterateContext

func (*SymbolContext) ToStringTree

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