Skip to content

Commit

Permalink
ESQL: Remove unused option for lexer util
Browse files Browse the repository at this point in the history
This removes the option to match `UPPER_CASE` tokens from a lexer utility.
We only match `lower_case` tokens.
  • Loading branch information
nik9000 committed Jul 8, 2024
1 parent 3802d84 commit 33c7070
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,24 @@

/**
* 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'.
* {@link CharStream} and forcing the lexer to see lowercase characters
* Grammar literals should then be lower case such as {@code begin}.
* The text of the character stream is unaffected.
* <p>Example: input {@code BeGiN} would match lexer rule {@code begin}
* but {@link CharStream#getText} will return {@code BeGiN}.
* </p>
*/
public class CaseChangingCharStream implements CharStream {

private final CharStream stream;
private final boolean upper;

/**
* Constructs a new CaseChangingCharStream wrapping the given {@link CharStream} forcing
* all characters to upper case or lower case.
* @param stream The stream to wrap.
* @param upper If true force each symbol to upper case, otherwise force to lower.
*/
public CaseChangingCharStream(CharStream stream, boolean upper) {
public CaseChangingCharStream(CharStream stream) {
this.stream = stream;
this.upper = upper;
}

@Override
Expand All @@ -57,7 +54,7 @@ public int LA(int i) {
if (c <= 0) {
return c;
}
return upper ? Character.toUpperCase(c) : Character.toLowerCase(c);
return Character.toLowerCase(c);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private <T> T invokeParser(
BiFunction<AstBuilder, ParserRuleContext, T> result
) {
try {
EsqlBaseLexer lexer = new EsqlBaseLexer(new CaseChangingCharStream(CharStreams.fromString(query), false));
EsqlBaseLexer lexer = new EsqlBaseLexer(new CaseChangingCharStream(CharStreams.fromString(query)));

lexer.removeErrorListeners();
lexer.addErrorListener(ERROR_LISTENER);
Expand Down

0 comments on commit 33c7070

Please sign in to comment.