internal

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: 11 Imported by: 0

Documentation

Index

Constants

View Source
const COMBINED = grammarType("COMBINED")
View Source
const LEXER = grammarType("LEXER")
View Source
const PARSER = grammarType("PARSER")

Variables

This section is empty.

Functions

func PrintAllTokens

func PrintAllTokens(lexer antlr.Lexer)

PrintAllTokens consumes all the tokens from the lexer and prints them to stdout.

Types

type CaseChangingStream

type CaseChangingStream struct {
	antlr.CharStream
	// contains filtered or unexported fields
}

CaseChangingStream wraps an existing CharStream, but upper cases, or lower cases the input before it is tokenized.

It would be useful if this was part of the core antlr library, but it was rejected in https://github.com/antlr/antlr4/pull/2046 as users can trivial strings.ToUpper(...) the input, or write their own version of this stream.

func NewCaseChangingStream

func NewCaseChangingStream(in antlr.CharStream, upper bool) *CaseChangingStream

func (*CaseChangingStream) LA

func (is *CaseChangingStream) LA(offset int) int

type Grammar

type Grammar struct {
	Name     string // name of this grammar
	Filename string
	Type     grammarType // one of PARSER, LEXER or COMBINED
}

Grammar represents a Antlr G4 grammar file.

func ParseG4

func ParseG4(path string) (*Grammar, error)

func (*Grammar) DependentFilenames

func (g *Grammar) DependentFilenames() []string

func (*Grammar) GeneratedFilenames

func (g *Grammar) GeneratedFilenames() []string

GeneratedFilenames returns the list of generated files.

func (*Grammar) String

func (g *Grammar) String() string

type Project

type Project struct {
	FileName string // Filename of the pom.xml.

	LongName string     // Name of the grammar defined in the pom.xml
	Includes []string   // List of included g4 files
	Grammars []*Grammar // Parsed grammars

	// Test related info
	EntryPoint          string
	Examples            []string
	CaseInsensitiveType string

	FoundAntlr4MavenPlugin bool // Did we find the Antlr Maven plugin?
}

Project represents one of language grammars defined by a pom.xml file and a set of g4 files.

func ParsePom

func ParsePom(path string) (*Project, error)

ParsePom extracts information about the grammar in a very lazy way!

func (*Project) AddGrammar

func (p *Project) AddGrammar(filename string)

func (*Project) GeneratedFilenames

func (p *Project) GeneratedFilenames() []string

GeneratedFilenames returns the list of generated files.

func (*Project) HasLexer

func (p *Project) HasLexer() bool

func (*Project) HasParser

func (p *Project) HasParser() bool

func (*Project) LexerName

func (p *Project) LexerName() string

LexerName returns the name of the generated Lexer.

func (*Project) ListenerName

func (p *Project) ListenerName() string

ListenerName returns the name of the of the generated Listener. See https://github.com/antlr/antlr4/blob/master/tool/src/org/antlr/v4/codegen/target/GoTarget.java#L168

func (*Project) ParserName

func (p *Project) ParserName() string

ParserName returns the name of the generated Parser.

type TestingErrorListener

type TestingErrorListener struct {
	*antlr.DefaultErrorListener
	// contains filtered or unexported fields
}

TestingErrorListener is a antlr.ErrorListener which fails a given test if a SyntaxError is found. The other Report errors are ignored.

func NewTestingErrorListener

func NewTestingErrorListener(t *testing.T, name string) *TestingErrorListener

func (*TestingErrorListener) SyntaxError

func (l *TestingErrorListener) SyntaxError(recognizer antlr.Recognizer, offendingSymbol interface{}, line, column int, msg string, e antlr.RecognitionException)

Directories

Path Synopsis
make creates the test and example files for the given grammar.
make creates the test and example files for the given grammar.

Jump to

Keyboard shortcuts

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