diff --git a/runtime/Go/src/antlr4/ATNConfig.go b/runtime/Go/src/antlr4/ATNConfig.go index ae0958c1b..5949b6f6b 100644 --- a/runtime/Go/src/antlr4/ATNConfig.go +++ b/runtime/Go/src/antlr4/ATNConfig.go @@ -15,6 +15,8 @@ import ( // type IATNConfig interface { + Hasher + getPrecedenceFilterSuppressed() bool setPrecedenceFilterSuppressed(bool) @@ -30,7 +32,7 @@ type IATNConfig interface { String() string - shortHashString() string + shortHash() string } type ATNConfig struct { @@ -152,17 +154,17 @@ func (this *ATNConfig) equals(other interface{}) bool { } } -func (this *ATNConfig) shortHashString() string { +func (this *ATNConfig) shortHash() string { return strconv.Itoa(this.state.GetStateNumber()) + "/" + strconv.Itoa(this.alt) + "/" + this.semanticContext.String() } -func (this *ATNConfig) hashString() string { +func (this *ATNConfig) Hash() string { var c string if this.context == nil { c = "" } else { - c = this.context.hashString() + c = this.context.Hash() } return strconv.Itoa(this.state.GetStateNumber()) + "/" + strconv.Itoa(this.alt) + "/" + c + "/" + this.semanticContext.String() @@ -262,7 +264,7 @@ func NewLexerATNConfig1(state IATNState, alt int, context IPredictionContext) *L return this } -func (this *LexerATNConfig) hashString() string { +func (this *LexerATNConfig) Hash() string { var f string if this.passedThroughNonGreedyDecision { diff --git a/runtime/Go/src/antlr4/ATNConfigSet.go b/runtime/Go/src/antlr4/ATNConfigSet.go index b081642de..6b46a5a49 100644 --- a/runtime/Go/src/antlr4/ATNConfigSet.go +++ b/runtime/Go/src/antlr4/ATNConfigSet.go @@ -11,7 +11,7 @@ import ( /// func hashATNConfig(c interface{}) string { - return c.(IATNConfig).shortHashString() + return c.(IATNConfig).shortHash() } func equalATNConfigs(a, b interface{}) bool { @@ -197,7 +197,7 @@ func (this *ATNConfigSet) equals(other interface{}) bool { this.dipsIntoOuterContext == other2.dipsIntoOuterContext } -func (this *ATNConfigSet) hashString() string { +func (this *ATNConfigSet) Hash() string { if this.readOnly { if this.cachedHashString == "-1" { this.cachedHashString = this.hashConfigs() diff --git a/runtime/Go/src/antlr4/BufferedTokenStream.go b/runtime/Go/src/antlr4/BufferedTokenStream.go deleted file mode 100644 index 071325aa3..000000000 --- a/runtime/Go/src/antlr4/BufferedTokenStream.go +++ /dev/null @@ -1,396 +0,0 @@ -// This implementation of {@link TokenStream} loads tokens from a -// {@link TokenSource} on-demand, and places the tokens in a buffer to provide -// access to any previous token by index. -// -//

-// This token stream ignores the value of {@link Token//getChannel}. If your -// parser requires the token stream filter tokens to only those on a particular -// channel, such as {@link Token//DEFAULT_CHANNEL} or -// {@link Token//HIDDEN_CHANNEL}, use a filtering token stream such a -// {@link CommonTokenStream}.

- -package antlr4 - -import ( - "strconv" - "fmt" -) - -// bt is just to keep meaningful parameter types to Parser -type BufferedTokenStream struct { - tokenSource TokenSource - - tokens []IToken - index int - fetchedEOF bool - channel int -} - -func NewBufferedTokenStream(tokenSource TokenSource) *BufferedTokenStream { - - ts := new(BufferedTokenStream) - - // The {@link TokenSource} from which tokens for bt stream are fetched. - ts.tokenSource = tokenSource - - // A collection of all tokens fetched from the token source. The list is - // considered a complete view of the input once {@link //fetchedEOF} is set - // to {@code true}. - ts.tokens = make([]IToken, 0) - - // The index into {@link //tokens} of the current token (next token to - // {@link //consume}). {@link //tokens}{@code [}{@link //p}{@code ]} should - // be - // {@link //LT LT(1)}. - // - //

This field is set to -1 when the stream is first constructed or when - // {@link //SetTokenSource} is called, indicating that the first token has - // not yet been fetched from the token source. For additional information, - // see the documentation of {@link IntStream} for a description of - // Initializing Methods.

- ts.index = -1 - - // Indicates whether the {@link Token//EOF} token has been fetched from - // {@link //tokenSource} and added to {@link //tokens}. This field improves - // performance for the following cases: - // - //