-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[Java] Add a new CharStream that converts the symbols to upper or lower case. #2048
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
Conversation
…er case. This is useful for many of the case insensitive grammars found at https://github.com/antlr/grammars-v4/ which assume the input would be all upper or lower case. Related discussion can be found at antlr/antlr4test-maven-plugin#1
|
Per discussion on #2046 this can be implemented on a case-by-case bases by the users of the grammar. |
|
Apparently these changes should be moved to #2046 according to the last Mr. Parr's comment. |
| } | ||
|
|
||
| /** | ||
| * Takes the stream and forces all symbols to uppercase. |
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.
perhaps say "Takes the stream and forces all symbols to uppercase for lexing purposes but leaves the original text as-is."?
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.
Done.
|
|
||
| import org.antlr.v4.runtime.misc.Interval; | ||
|
|
||
| /** |
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.
Perhaps we could change the comment as follows?
This class supports case-insensitive lexing by wrapping an existing
{@link CharStream} and forcing the lexer to see either upper or
lowercase characters. Grammar literals should then be either upper or
lower case such as 'BEGIN' or 'begin'. The text of the character
stream is unaffected. Example: input BeGiN would match lexer rule
'BEGIN' if constructor parameter upper=true but getText() would return
BeGiN.
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.
SGTM.
| * @param in | ||
| * @return | ||
| */ | ||
| public static CharStream forceUpper(CharStream in) { |
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.
Could we use toUpper perhaps? asUpper?
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.
toUpper it is., and changed forceLower to toLower.
|
@bramp could you also add a test with Turkish culture and |
|
I'm closing as I'm going the documentation route per #2146 |
This is useful for many of the case insensitive grammars found at https://github.com/antlr/grammars-v4/ which assume the input would be all upper or lower case. Related discussion can be found at antlr/antlr4test-maven-plugin#1
This is similar to the version for Go #2046