Skip to content

Conversation

@bramp
Copy link
Contributor

@bramp bramp commented Oct 7, 2017

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

…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
@bramp
Copy link
Contributor Author

bramp commented Oct 21, 2017

Per discussion on #2046 this can be implemented on a case-by-case bases by the users of the grammar.

@scadgek
Copy link
Contributor

scadgek commented Nov 23, 2017

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.
Copy link
Member

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."?

Copy link
Contributor Author

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;

/**
Copy link
Member

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.

Copy link
Contributor Author

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) {
Copy link
Member

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?

Copy link
Contributor Author

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 bramp reopened this Nov 30, 2017
@KvanTTT
Copy link
Member

KvanTTT commented Dec 2, 2017

@bramp could you also add a test with Turkish culture and I letter? See this java sample.

@parrt
Copy link
Member

parrt commented Dec 6, 2017

I'm closing as I'm going the documentation route per #2146

@parrt parrt closed this Dec 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants