I'm working on the lexer for a language which allows abbreviated keywords Any suggestions for handling this in ANTLR's lexer?
Created May 4, 2012
Monty Zukowski There is a method called testLiteralsTable() which looks in the "literals" Hashtable to match keywords. Override that for the behavior you want.
// Test the token text against the literals table // Override this method to perform a different literals test public int testLiteralsTable(int ttype) { hashString.setBuffer(text.getBuffer(), text.length()); Integer literalsIndex = (Integer)literals.get(hashString); if (literalsIndex != null) { ttype = literalsIndex.intValue(); } return ttype; }