Skip to content

Commit

Permalink
Support explicit token assignments in combined grammars (fixes antlr#157
Browse files Browse the repository at this point in the history
)
  • Loading branch information
sharwell committed Sep 29, 2014
1 parent c10b287 commit 2331f6d
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,14 @@ protected void aliasTokenIDsAndLiterals(Grammar root) {
String tokenID = entry.getKey();
String literal = entry.getValue();
if ( literal.charAt(0)=='\'' && stringLiterals.get(literal)!=null ) {
stringLiterals.put(literal, tokens.get(tokenID));
// an alias still means you need a lexer rule for it
Integer typeI = tokens.get(tokenID);
if (typeI == null) {
// must have been imported from a tokenVocab
typeI = grammar.composite.tokenIDToTypeMap.get(tokenID);
}

stringLiterals.put(literal, typeI);
// an alias still means you need a lexer rule for it
if ( !tokenRuleDefs.contains(tokenID) ) {
root.defineLexerRuleForAliasedStringLiteral(tokenID, literal, typeI);
}
Expand Down

0 comments on commit 2331f6d

Please sign in to comment.