Skip to content
This repository has been archived by the owner on Apr 3, 2018. It is now read-only.

Commit

Permalink
Add lastEvaluatedWord
Browse files Browse the repository at this point in the history
  • Loading branch information
bruno-medeiros committed Dec 16, 2016
1 parent f3ed0b1 commit 032ca51
Showing 1 changed file with 5 additions and 3 deletions.
Expand Up @@ -20,6 +20,8 @@ public class WordLexerRule<TOKEN> implements ILexingRule2<TOKEN> {
protected final TOKEN defaultWordToken;
protected final HashMap2<String, TOKEN> tokenMap = new HashMap2<>();

protected String lastEvaluatedWord;

public WordLexerRule(TOKEN whitespaceToken, TOKEN defaultWordToken) {
this.whitespaceToken = whitespaceToken;
this.defaultWordToken = defaultWordToken;
Expand All @@ -41,12 +43,12 @@ public TOKEN doEvaluateToken(ICharacterReader reader) {
return whitespaceToken;
}

String word = LexingUtils.readJavaIdentifier(reader);
if(word.isEmpty()) {
lastEvaluatedWord = LexingUtils.readJavaIdentifier(reader);
if(lastEvaluatedWord.isEmpty()) {
return null;
}

TOKEN keywordToken = tokenMap.get(word);
TOKEN keywordToken = tokenMap.get(lastEvaluatedWord);
return (keywordToken == null) ? defaultWordToken : keywordToken;
}

Expand Down

0 comments on commit 032ca51

Please sign in to comment.