Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Allow CommonTokenStream to reset properly #4245

Merged
merged 1 commit into from
Apr 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion runtime/Go/antlr/v4/common_token_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ func (c *CommonTokenStream) Mark() int {

func (c *CommonTokenStream) Release(_ int) {}

func (c *CommonTokenStream) reset() {
func (c *CommonTokenStream) Reset() {
c.fetchedEOF = false
c.tokens = make([]Token, 0)
c.Seek(0)
}

Expand Down Expand Up @@ -196,6 +198,7 @@ func (c *CommonTokenStream) SetTokenSource(tokenSource TokenSource) {
c.tokenSource = tokenSource
c.tokens = make([]Token, 0)
c.index = -1
c.fetchedEOF = false
}

// NextTokenOnChannel returns the index of the next token on channel given a
Expand Down
1 change: 1 addition & 0 deletions runtime/Go/antlr/v4/token_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ type TokenStream interface {
IntStream

LT(k int) Token
Reset()

Get(index int) Token
GetTokenSource() TokenSource
Expand Down
2 changes: 1 addition & 1 deletion runtime/Go/antlr/v4/tokenstream_rewriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ func (tsr *TokenStreamRewriter) RollbackDefault(instructionIndex int) {
tsr.Rollback(DefaultProgramName, instructionIndex)
}

// DeleteProgram reset the program so that no instructions exist
// DeleteProgram Reset the program so that no instructions exist
func (tsr *TokenStreamRewriter) DeleteProgram(programName string) {
tsr.Rollback(programName, MinTokenIndex) //TODO: double test on that cause lower bound is not included
}
Expand Down