-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
#4078 [runtime/java] fixed npe due to CommonToken.getText() returning null when inputStream is null #4251
Conversation
The badge in the README suggests that ANTLR requires Java 7 or higher, whereas since ANTLR v4.10 Java 11 or higher is required. Signed-off-by: Robert Adam <dev@robert-adam.de> Signed-off-by: Victor Smirnov <vityaman.dev@yandex.ru>
Allow user to subclass and consume differently. Useful for CR handling as suggested in antlr#2519 Signed-off-by: Alberto Simões <Alberto.Simoes@checkmarx.com> Signed-off-by: Victor Smirnov <vityaman.dev@yandex.ru>
…g null when inputStream is null Signed-off-by: Victor Smirnov <vityaman.dev@yandex.ru>
86e2795
to
e25f89d
Compare
@@ -1,6 +1,6 @@ | |||
# ANTLR v4 | |||
|
|||
[![Java 7+](https://img.shields.io/badge/java-7+-4c7e9f.svg)](http://java.oracle.com) | |||
[![Java 11+](https://img.shields.io/badge/java-11+-4c7e9f.svg)](http://java.oracle.com) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it doesn't look a change related to the title of the current pull request.
@@ -779,7 +779,7 @@ public int Column | |||
} | |||
|
|||
|
|||
public void Consume(ICharStream input) | |||
public virtual void Consume(ICharStream input) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It relates neither to PR nor to the Java target.
if ( c==' ' && escapeSpaces ) buf.append('\u00B7'); | ||
else if ( c=='\t' ) buf.append("\\t"); | ||
else if ( c=='\n' ) buf.append("\\n"); | ||
else if ( c=='\r' ) buf.append("\\r"); | ||
if (c == ' ' && escapeSpaces) buf.append('\u00B7'); | ||
else if (c == '\t') buf.append("\\t"); | ||
else if (c == '\n') buf.append("\\n"); | ||
else if (c == '\r') buf.append("\\r"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't mix whitespace and semantics changes (ideally, don't change whitespaces without need).
if ( symbol.getType() == Token.EOF ) return "<EOF>"; | ||
return symbol.getText(); | ||
if (symbol.getType() == Token.EOF) { | ||
return "<EOF>"; | ||
} | ||
return symbol.getText(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, please revert this change.
Will close this and resolve issues in PR #4252 as here I have problems with commit history and it is easier to solve them by creating a fresh one. |
Solution of Issue 4078: #4078
The problem was that CommonToken::getText() returns null if and only if it has InputStream field null, what happens when we call CommonToken(int type) as there source is equal to