tsv

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

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

type exampleListener struct {
	*tsv.BasetsvListener
}

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

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

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

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewtsvLexer

func NewtsvLexer(input antlr.CharStream) *tsvLexer

func NewtsvParser

func NewtsvParser(input antlr.TokenStream) *tsvParser

Types

type BasetsvListener

type BasetsvListener struct{}

BasetsvListener is a complete listener for a parse tree produced by tsvParser.

func (*BasetsvListener) EnterEveryRule

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

EnterEveryRule is called when any rule is entered.

func (*BasetsvListener) EnterField

func (s *BasetsvListener) EnterField(ctx *FieldContext)

EnterField is called when production field is entered.

func (*BasetsvListener) EnterHdr

func (s *BasetsvListener) EnterHdr(ctx *HdrContext)

EnterHdr is called when production hdr is entered.

func (*BasetsvListener) EnterRow

func (s *BasetsvListener) EnterRow(ctx *RowContext)

EnterRow is called when production row is entered.

func (*BasetsvListener) EnterTsvFile

func (s *BasetsvListener) EnterTsvFile(ctx *TsvFileContext)

EnterTsvFile is called when production tsvFile is entered.

func (*BasetsvListener) ExitEveryRule

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

ExitEveryRule is called when any rule is exited.

func (*BasetsvListener) ExitField

func (s *BasetsvListener) ExitField(ctx *FieldContext)

ExitField is called when production field is exited.

func (*BasetsvListener) ExitHdr

func (s *BasetsvListener) ExitHdr(ctx *HdrContext)

ExitHdr is called when production hdr is exited.

func (*BasetsvListener) ExitRow

func (s *BasetsvListener) ExitRow(ctx *RowContext)

ExitRow is called when production row is exited.

func (*BasetsvListener) ExitTsvFile

func (s *BasetsvListener) ExitTsvFile(ctx *TsvFileContext)

ExitTsvFile is called when production tsvFile is exited.

func (*BasetsvListener) VisitErrorNode

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

VisitErrorNode is called when an error node is visited.

func (*BasetsvListener) VisitTerminal

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

VisitTerminal is called when a terminal node is visited.

type FieldContext

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

func NewEmptyFieldContext

func NewEmptyFieldContext() *FieldContext

func NewFieldContext

func NewFieldContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *FieldContext

func (*FieldContext) EnterRule

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

func (*FieldContext) ExitRule

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

func (*FieldContext) GetParser

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

func (*FieldContext) GetRuleContext

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

func (*FieldContext) IsFieldContext

func (*FieldContext) IsFieldContext()

func (*FieldContext) STRING

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

func (*FieldContext) TEXT

func (s *FieldContext) TEXT() antlr.TerminalNode

func (*FieldContext) ToStringTree

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

type HdrContext

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

func NewEmptyHdrContext

func NewEmptyHdrContext() *HdrContext

func NewHdrContext

func NewHdrContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *HdrContext

func (*HdrContext) EnterRule

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

func (*HdrContext) ExitRule

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

func (*HdrContext) GetParser

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

func (*HdrContext) GetRuleContext

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

func (*HdrContext) IsHdrContext

func (*HdrContext) IsHdrContext()

func (*HdrContext) Row

func (s *HdrContext) Row() IRowContext

func (*HdrContext) ToStringTree

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

type IFieldContext

type IFieldContext interface {
	antlr.ParserRuleContext

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

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

IFieldContext is an interface to support dynamic dispatch.

type IHdrContext

type IHdrContext interface {
	antlr.ParserRuleContext

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

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

IHdrContext is an interface to support dynamic dispatch.

type IRowContext

type IRowContext interface {
	antlr.ParserRuleContext

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

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

IRowContext is an interface to support dynamic dispatch.

type ITsvFileContext

type ITsvFileContext interface {
	antlr.ParserRuleContext

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

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

ITsvFileContext is an interface to support dynamic dispatch.

type RowContext

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

func NewEmptyRowContext

func NewEmptyRowContext() *RowContext

func NewRowContext

func NewRowContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *RowContext

func (*RowContext) AllField

func (s *RowContext) AllField() []IFieldContext

func (*RowContext) AllTAB

func (s *RowContext) AllTAB() []antlr.TerminalNode

func (*RowContext) EOL

func (s *RowContext) EOL() antlr.TerminalNode

func (*RowContext) EnterRule

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

func (*RowContext) ExitRule

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

func (*RowContext) Field

func (s *RowContext) Field(i int) IFieldContext

func (*RowContext) GetParser

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

func (*RowContext) GetRuleContext

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

func (*RowContext) IsRowContext

func (*RowContext) IsRowContext()

func (*RowContext) TAB

func (s *RowContext) TAB(i int) antlr.TerminalNode

func (*RowContext) ToStringTree

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

type TsvFileContext

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

func NewEmptyTsvFileContext

func NewEmptyTsvFileContext() *TsvFileContext

func NewTsvFileContext

func NewTsvFileContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TsvFileContext

func (*TsvFileContext) AllRow

func (s *TsvFileContext) AllRow() []IRowContext

func (*TsvFileContext) EnterRule

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

func (*TsvFileContext) ExitRule

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

func (*TsvFileContext) GetParser

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

func (*TsvFileContext) GetRuleContext

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

func (*TsvFileContext) Hdr

func (s *TsvFileContext) Hdr() IHdrContext

func (*TsvFileContext) IsTsvFileContext

func (*TsvFileContext) IsTsvFileContext()

func (*TsvFileContext) Row

func (s *TsvFileContext) Row(i int) IRowContext

func (*TsvFileContext) ToStringTree

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