[antlr-interest] Syntactic Predicates for matching literals within char sequences?

Michael C. Starkie hikemike at gmail.com
Sun Jan 17 13:04:35 PST 2010


Hi,
I'm new to Antlr and I'm trying to match the string literal 'DATA_IN'
which appears multiple times in a sequence of ASCII chars.  However,
the parser get's confused when it encounters strings like 'DAP' or
'DA<any char>':

mismatched character 'P' expecting 'T'

lexer:
DATA_IN : 'DATA_IN';
ANY_CHAR : '\u0002'..'\u007F';

parser:
rule: line+ ;
line: data_in check;
data_in_check
options { backtrack=true; }
: data_in | any_char;

data_in : DATA_IN
any_char : ANY_CHAR;

Mike


More information about the antlr-interest mailing list