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

kferrio at gmail.com kferrio at gmail.com
Sun Jan 17 13:20:14 PST 2010


You probably want to make ANY_CHAR a lexer fragment so that it does not consume input except as part of a larger rule which calls it.  Or maybe I missed your intent.

Kyle
------Original Message------
From: Michael C. Starkie
Sender: ANTLR
To: antlr-interest at antlr.org
Subject: [antlr-interest] Syntactic Predicates for matching literals withinchar sequences?
Sent: Jan 17, 2010 2:04 PM

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

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address


Sent from my Verizon Wireless BlackBerry


More information about the antlr-interest mailing list