Categorygithub.com/antlr4-go/antlr/v4
modulepackage
4.13.1
Repository: https://github.com/antlr4-go/antlr.git
Documentation: pkg.go.dev

# README

Go Report Card PkgGoDev Release Release Maintenance License GitHub stars

ANTLR4 Go Runtime Module Repo

IMPORTANT: Please submit PRs via a clone of the https://github.com/antlr/antlr4 repo, and not here.

  • Do not submit PRs or any change requests to this repo
  • This repo is read only and is updated by the ANTLR team to create a new release of the Go Runtime for ANTLR
  • This repo contains the Go runtime that your generated projects should import

Introduction

This repo contains the official modules for the Go Runtime for ANTLR. It is a copy of the runtime maintained at: https://github.com/antlr/antlr4/tree/master/runtime/Go/antlr and is automatically updated by the ANTLR team to create the official Go runtime release only. No development work is carried out in this repo and PRs are not accepted here.

The dev branch of this repo is kept in sync with the dev branch of the main ANTLR repo and is updated periodically.

Why?

The go get command is unable to retrieve the Go runtime when it is embedded so deeply in the main repo. A go get against the antlr/antlr4 repo, while retrieving the correct source code for the runtime, does not correctly resolve tags and will create a reference in your go.mod file that is unclear, will not upgrade smoothly and causes confusion.

For instance, the current Go runtime release, which is tagged with v4.13.0 in antlr/antlr4 is retrieved by go get as:

require (
	github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230219212500-1f9a474cc2dc
)

Where you would expect to see:

require (
    github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.13.0
)

The decision was taken to create a separate org in a separate repo to hold the official Go runtime for ANTLR and from whence users can expect go get to behave as expected.

Documentation

Please read the official documentation at: https://github.com/antlr/antlr4/blob/master/doc/index.md for tips on migrating existing projects to use the new module location and for information on how to use the Go runtime in general.

# Functions

ConfigureRuntime allows the runtime to be configured globally setting things like trace and statistics options.
goland:noinspection GoUnusedExportedFunction.
No description provided by the author
No description provided by the author
LexerActionExecutorappend creates a [LexerActionExecutor] which executes the actions for the input [LexerActionExecutor] followed by a specified [LexerAction].
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewATN returns a new ATN struct representing the given grammarType and is used for runtime deserialization of ATNs from the code generated by the ANTLR tool.
NewATNConfig creates a new ATNConfig instance given an existing config, a state, a context and a semantic context, other 'constructors' are just wrappers around this one.
NewATNConfig1 creates a new ATNConfig instance given an existing config, a state, and a context only.
NewATNConfig2 creates a new ATNConfig instance given an existing config, and a context only.
NewATNConfig3 creates a new ATNConfig instance given an existing config, a state and a semantic context.
NewATNConfig4 creates a new ATNConfig instance given an existing config, and a state only.
NewATNConfig5 creates a new ATNConfig instance given a state, alt, context and semantic context.
NewATNConfig6 creates a new ATNConfig instance given a state, alt and context only.
NewATNConfigSet creates a new ATNConfigSet instance.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
goland:noinspection GoUnusedExportedFunction.
No description provided by the author
goland:noinspection GoUnusedExportedFunction.
No description provided by the author
No description provided by the author
NewBaseParser contains all the parsing support code to embed in parsers.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewBitSet creates a new bitwise set TODO: See if we can replace with the standard library's BitSet.
No description provided by the author
No description provided by the author
NewClosureBusy creates a new ClosureBusy instance used to avoid infinite recursion for right-recursive rules.
No description provided by the author
No description provided by the author
NewCommonTokenStream creates a new CommonTokenStream instance using the supplied lexer to produce tokens and will pull tokens from the given lexer channel.
No description provided by the author
goland:noinspection GoUnusedExportedFunction.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
goland:noinspection GoUnusedExportedFunction.
No description provided by the author
No description provided by the author
No description provided by the author
goland:noinspection GoUnusedExportedFunction.
goland:noinspection GoUnusedExportedFunction.
NewInputMisMatchException creates an exception that signifies any kind of mismatched input exceptions such as when the current input does not Match the expected token.
NewInputStream creates a new input stream from the given string.
No description provided by the author
No description provided by the author
NewInterval creates a new interval with the given start and stop values.
NewIntervalSet creates a new empty, writable, interval set.
NewIoStream creates a new input stream from the given io.Reader reader.
goland:noinspection GoUnusedExportedFunction.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
goland:noinspection GoUnusedExportedFunction.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewLexerChannelAction creates a channel lexer action by calling [Lexer.setChannel] with the assigned channel.
No description provided by the author
No description provided by the author
NewLexerIndexedCustomAction constructs a new indexed custom action by associating a character offset with a [LexerAction].
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewNoViableAltException creates an exception indicating that the parser could not decide which of two or more paths to take based upon the remaining input.
No description provided by the author
NewOrderedATNConfigSet creates a config set with a slightly different Hash/Equal pair for use in lexers.
No description provided by the author
goland:noinspection GoUnusedExportedFunction.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewVisitRecord returns a new VisitRecord instance from the pool if available.
No description provided by the author
No description provided by the author
PredictionModeallConfigsInRuleStopStates checks if all configurations in configs are in a [RuleStopState].
PredictionModeallSubsetsConflict determines if every alternative subset in altsets contains more than one alternative.
PredictionModeallSubsetsEqual determines if every alternative subset in altsets is equivalent.
PredictionModeGetAlts returns the complete set of represented alternatives for a collection of alternative subsets.
PredictionModegetConflictingAltSubsets gets the conflicting alt subsets from a configuration set.
PredictionModegetSingleViableAlt gets the single alternative predicted by all alternative subsets in altsets if there is one.
PredictionModeGetStateToAltMap gets a map from state to alt subset from a configuration set.
PredictionModegetUniqueAlt returns the unique alternative predicted by all alternative subsets in altsets.
PredictionModehasConfigInRuleStopState checks if any configuration in the given configs is in a [RuleStopState].
PredictionModehasConflictingAltSet determines if any single alternative subset in altsets contains more than one alternative.
PredictionModehasNonConflictingAltSet determines if any single alternative subset in altsets contains exactly one alternative.
PredictionModehasSLLConflictTerminatingPrediction computes the SLL prediction termination condition.
No description provided by the author
PredictionModeresolvesToJustOneViableAlt checks full LL prediction termination.
goland:noinspection GoUnusedExportedFunction.
No description provided by the author
No description provided by the author
No description provided by the author
goland:noinspection GoUnusedExportedFunction.
goland:noinspection GoUnusedExportedFunction.
No description provided by the author
goland:noinspection GoUnusedExportedFunction.
goland:noinspection GoUnusedExportedFunction.
TreesgetAncestors returns a list of all ancestors of this node.
TreesGetChildren returns am ordered list of all children of this node goland:noinspection GoUnusedExportedFunction.
No description provided by the author
TreesStringTree prints out a whole tree in LISP form.
WithLexerATNSimulatorDebug sets the global flag indicating whether to log debug information from the lexer [ATN] simulator.
WithLexerATNSimulatorDFADebug sets the global flag indicating whether to log debug information from the lexer [ATN] [DFA] simulator.
WithLRLoopEntryBranchOpt sets the global flag indicating whether let recursive loop operations should be optimized or not.
WithMemoryManager sets the global flag indicating whether to use the memory manager or not.
WithParserATNSimulatorDebug sets the global flag indicating whether to log debug information from the parser [ATN] simulator.
WithParserATNSimulatorDFADebug sets the global flag indicating whether to log debug information from the parser [ATN] [DFA] simulator.
WithParserATNSimulatorRetryDebug sets the global flag indicating whether to log debug information from the parser [ATN] [DFA] simulator when retrying a decision.
WithParserATNSimulatorTraceATNSim sets the global flag indicating whether to log trace information from the parser [ATN] simulator [DFA].
WithStatsTraceStacks sets the global flag indicating whether to collect stack traces at the create-point of certain structs, such as collections, or the use point of certain methods such as Put().
No description provided by the author

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
Constants for serialization.
Constants for serialization.
Constants for serialization.
No description provided by the author
Constants for serialization.
Constants for serialization.
Constants for serialization.
Constants for serialization.
Constants for serialization.
Constants for serialization.
Constants for serialization.
Constants for serialization.
Constants for serialization.
Constants for serialization.
Constants for serialization.
Represent the type of recognizer an ATN applies to.
Represent the type of recognizer an ATN applies to.
BasePredictionContextEmptyReturnState represents {@code $} in an array in full context mode, $ doesn't mean wildcard: $ + x = [$,x] Here, $ = EmptyReturnState.
No description provided by the author
No description provided by the author
No description provided by the author
LexerActionTypeChannel represents a [LexerChannelAction] action.
LexerActionTypeCustom represents a [LexerCustomAction] action.
LexerActionTypeMode represents a [LexerModeAction] action.
LexerActionTypeMore represents a [LexerMoreAction] action.
LexerActionTypePopMode represents a [LexerPopModeAction] action.
LexerActionTypePushMode represents a [LexerPushModeAction] action.
LexerActionTypeSkip represents a [LexerSkipAction] action.
LexerActionTypeType represents a [LexerTypeAction] action.
No description provided by the author
goland:noinspection GoUnusedConst.
goland:noinspection GoUnusedConst.
goland:noinspection GoUnusedConst.
goland:noinspection GoUnusedConst.
No description provided by the author
No description provided by the author
LL1AnalyzerHitPred is a special value added to the lookahead sets to indicate that we hit a predicate during analysis if seeThruPreds==false.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
PredictionModeLL represents the LL(*) prediction mode.
PredictionModeLLExactAmbigDetection represents the LL(*) prediction mode with exact ambiguity detection.
PredictionModeSLL represents the SLL(*) prediction mode.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
TokenDefaultChannel is the default channel upon which tokens are sent to the parser.
No description provided by the author
TokenEpsilon - during lookahead operations, this "token" signifies we hit the rule end [ATN] state and did not follow it despite needing to.
TokenHiddenChannel defines the normal hidden channel - the parser wil not see tokens that are not on [TokenDefaultChannel].
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
e.g., {isType(input.LT(1))}?.
No description provided by the author
No description provided by the author
~(A|B) or ~atom, wildcard, which convert to next 2.
No description provided by the author
No description provided by the author

# Variables

ATNInvalidAltNumber is used to represent an ALT number that has yet to be calculated or which is invalid for a particular struct such as [*antlr.BaseRuleContext].
No description provided by the author
goland:noinspection GoUnusedGlobalVariable.
No description provided by the author
TODO: JI These are meant to be atomics - this does not seem to match the Java runtime here goland:noinspection GoUnusedGlobalVariable.
TODO: JI These are meant to be atomics - this does not seem to match the Java runtime here goland:noinspection GoUnusedGlobalVariable.
No description provided by the author
CommonTokenFactoryDEFAULT is the default CommonTokenFactory.
ConsoleErrorListenerINSTANCE provides a default instance of {@link ConsoleErrorListener}.
No description provided by the author
goland:noinspection GoUnusedGlobalVariable.
forces unicode to stay in ATN.
goland:noinspection GoUnusedGlobalVariable.
No description provided by the author
No description provided by the author
LexerSkipActionINSTANCE provides a singleton instance of this parameterless lexer action.
No description provided by the author
goland:noinspection GoUnusedGlobalVariable.
No description provided by the author
No description provided by the author
goland:noinspection GoUnusedGlobalVariable.
No description provided by the author

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
ATN represents an “[Augmented Transition Network]”, though general in ANTLR the term “Augmented Recursive Transition Network” though there are some descriptions of “[Recursive Transition Network]” in existence.
ATNAltConfigComparator is used as the comparator for mapping configs to Alt Bitsets.
ATNConfig is a tuple: (ATN state, predicted alt, syntactic, semantic context).
ATNConfigComparator is used as the comparator for the configLookup field of an ATNConfigSet and has a custom Equals() and Hash() implementation, because equality is not based on the standard Hash() and Equals() methods of the ATNConfig type.
ATNConfigSet is a specialized set of ATNConfig that tracks information about its elements and can combine similar configurations using a graph-structured stack.
No description provided by the author
No description provided by the author
No description provided by the author
AtomTransition TODO: make all transitions sets? no, should remove set edges.
The BailErrorStrategy implementation of ANTLRErrorStrategy responds to syntax errors by immediately canceling the parse operation with a [ParseCancellationException].
No description provided by the author
BaseATNConfigComparator is used as the comparator for the configLookup field of a ATNConfigSet and has a custom Equals() and Hash() implementation, because equality is not based on the standard Hash() and Equals() methods of the ATNConfig type.
No description provided by the author
No description provided by the author
BaseBlockStartState is the start of a regular (...) block.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
BlockEndState is a terminal node of a simple (a|b|c) block.
ClosureBusy is a store of ATNConfigs and is a tiny abstraction layer over a standard JStore so that we can use Lazy instantiation of the JStore, mostly to avoid polluting the stats module with a ton of JStore instances with nothing in them.
No description provided by the author
No description provided by the author
CommonTokenFactory is the default TokenFactory implementation.
CommonTokenStream is an implementation of TokenStream that loads tokens from a TokenSource on-demand and places the tokens in a buffer to provide access to any previous token by index.
No description provided by the author
No description provided by the author
DefaultErrorStrategy is the default implementation of ANTLRErrorStrategy used for error reporting and recovery in ANTLR parsers.
DFA represents the Deterministic Finite Automaton used by the recognizer, including all the states it can reach and the transitions between them.
DFASerializer is a DFA walker that knows how to dump the DFA states to serialized strings.
DFAState represents a set of possible [ATN] configurations.
No description provided by the author
No description provided by the author
No description provided by the author
FailedPredicateException indicates that a semantic predicate failed during validation.
No description provided by the author
No description provided by the author
No description provided by the author
InsertAfterOp distinguishes between insert after/before to do the "insert after" instructions first and then the "insert before" instructions at same index.
No description provided by the author
No description provided by the author
IntervalSet represents a collection of [Intervals], which may be read-only.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
A JStatRec is a record of a particular use of a [JStore], [JMap] or JPCMap] collection.
JStore implements a container that allows the use of a struct to calculate the key for a collection of values akin to map.
No description provided by the author
No description provided by the author
LexerChannelAction implements the channel lexer action by calling [Lexer.setChannel] with the assigned channel.
No description provided by the author
No description provided by the author
No description provided by the author
LexerModeAction implements the mode lexer action by calling [Lexer.mode] with the assigned mode.
No description provided by the author
No description provided by the author
LexerPopModeAction implements the popMode lexer action by calling [Lexer.popMode].
LexerPushModeAction implements the pushMode lexer action by calling [Lexer.pushMode] with the assigned mode.
LexerSkipAction implements the [BaseLexerAction.Skip] lexer action by calling [Lexer.Skip].
Implements the {@code type} lexer action by calling {@link Lexer//setType} with the assigned type.
No description provided by the author
LoopEndState marks the end of a * or + loop.
Mutex is a simple mutex implementation which just delegates to sync.Mutex, it is used to provide a mutex implementation for the antlr package, which users can turn off with the build tag -tags antlr.nomutex.
No description provided by the author
No description provided by the author
ObjEqComparator is the equivalent of the Java ObjectEqualityComparator, which is the default instance of Equality comparator.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
PlusBlockStartState is the start of a (A|B|...)+ loop.
PlusLoopbackState is a decision state for A+ and (A|B)+.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
PredictionContext is a go idiomatic implementation of PredictionContext that does not rty to emulate inheritance from Java, and can be used without an interface definition.
PredictionContextCache is Used to cache [PredictionContext] objects.
PredPrediction maps a predicate to a predicted alternative.
No description provided by the author
No description provided by the author
ReplaceOp tries to replace range from x..y with (y-x)+1 ReplaceOp instructions.
No description provided by the author
RuleStopState is the last node in the ATN for a rule, unless that rule is the start symbol.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
StarBlockStartState is the block that begins a closure loop.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
TokensStartState is the Tokens rule start state linking to each lexer rule start state.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Interfaces

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Collectable is an interface that a struct should implement if it is to be usable as a key in these collections.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
RuleContext is a record of a single rule invocation.
No description provided by the author
SemanticContext is a tree structure used to record the semantic context in which an ATN configuration is valid.
No description provided by the author
No description provided by the author
No description provided by the author
TokenFactory creates CommonToken objects.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Type aliases

No description provided by the author
No description provided by the author