postalcode

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

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

type exampleListener struct {
	*postalcode.BasepostalcodeListener
}

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

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

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

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewpostalcodeLexer

func NewpostalcodeLexer(input antlr.CharStream) *postalcodeLexer

func NewpostalcodeParser

func NewpostalcodeParser(input antlr.TokenStream) *postalcodeParser

Types

type BasepostalcodeListener

type BasepostalcodeListener struct{}

BasepostalcodeListener is a complete listener for a parse tree produced by postalcodeParser.

func (*BasepostalcodeListener) EnterEveryRule

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

EnterEveryRule is called when any rule is entered.

func (*BasepostalcodeListener) EnterPostalcode

func (s *BasepostalcodeListener) EnterPostalcode(ctx *PostalcodeContext)

EnterPostalcode is called when production postalcode is entered.

func (*BasepostalcodeListener) ExitEveryRule

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

ExitEveryRule is called when any rule is exited.

func (*BasepostalcodeListener) ExitPostalcode

func (s *BasepostalcodeListener) ExitPostalcode(ctx *PostalcodeContext)

ExitPostalcode is called when production postalcode is exited.

func (*BasepostalcodeListener) VisitErrorNode

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

VisitErrorNode is called when an error node is visited.

func (*BasepostalcodeListener) VisitTerminal

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

VisitTerminal is called when a terminal node is visited.

type IPostalcodeContext

type IPostalcodeContext interface {
	antlr.ParserRuleContext

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

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

IPostalcodeContext is an interface to support dynamic dispatch.

type PostalcodeContext

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

func NewEmptyPostalcodeContext

func NewEmptyPostalcodeContext() *PostalcodeContext

func NewPostalcodeContext

func NewPostalcodeContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *PostalcodeContext

func (*PostalcodeContext) AllDIGIT

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

func (*PostalcodeContext) AllLETTER

func (s *PostalcodeContext) AllLETTER() []antlr.TerminalNode

func (*PostalcodeContext) DIGIT

func (*PostalcodeContext) EnterRule

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

func (*PostalcodeContext) ExitRule

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

func (*PostalcodeContext) GetParser

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

func (*PostalcodeContext) GetRuleContext

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

func (*PostalcodeContext) IsPostalcodeContext

func (*PostalcodeContext) IsPostalcodeContext()

func (*PostalcodeContext) LETTER

func (s *PostalcodeContext) LETTER(i int) antlr.TerminalNode

func (*PostalcodeContext) ToStringTree

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