antlr / antlr/antlr3

C++ runtime: For UNWANTED_TOKEN_EXCEPTION, expected token is printed instead of seen token.

Open
#219 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
253
Forks
178
PR merge metrics
No merged PRs in 30d

Description

The ScyllaDB project uses Antlr3 with the C++ runtime.
In https://github.com/scylladb/scylladb/issues/1703 it was noted that ugly error messages are reported. One of the strange error messages is:
```
line 1:71 extraneous input 'STORAGE' expecting
```

This is ScyllaDB's own (broken in its own way) error message printer, but when I try to use displayRecognitionError() from /usr/include/antlr3exception.inl, it's even worse - only this wrong "Expected" is printed. A snippted from that function:
```c++
case UNWANTED_TOKEN_EXCEPTION:
...
str_stream << " : Extraneous input - expected "
<< tokenNames[ BaseType::m_expecting] << " ...\n";
```
So in UNWANTED_TOKEN_EXCEPTION this function prints, instead of the seen (and unwanted) token, the "expected" token, which isn't available in the case of this exception, which is why it's printed as ". What needs to be printed in this case is the seen token, not the expected token.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in antlr3exception.inl and inspect the UNWANTED_TOKEN_EXCEPTION branch of displayRecognitionError(), focusing on the token data available for that exception. Reproduce the reported error if possible, then verify that the resulting message identifies the seen unwanted token rather than the unavailable expected token.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.