Hi everyone,
I'm new to the mailing list and am just getting starting with ANTLR (day 2)
and I've run into an issue I'm having some trouble wrapping my head around.
I think it's related to how ANTLR looks-ahead to predict tokens, but I think
I'm overlaying my familiarity with regular expressions onto ANTLR in a way
that is clouding up my understanding of what ANTLR does and needs in order
to do this right.
I'm trying to parse out a collection of "words" on a single line as a
"phrase", ignoring whitespace at the beginning and end of the lines, but
I'm getting an error while parsing what I think is a line that should match
the grammar.
My grammar:
grammar Phrase;
WS : (' '|'\t')+;
DIGIT : ('0'..'9');
LETTER : ('a'..'z'|'A'..'Z');
NEWLINE : '\r'? '\n';
WORD : (LETTER|DIGIT)+;
EOL : WS? NEWLINE?;
PHRASE : WORD (WS WORD)*;
line : WS? PHRASE EOL?;
The line of text I am parsing (note whitespace at the ends): " This is a
phrase "
Error I get during parse:
line 1:18 required (...)+ loop did not match anything at character
'<EOF>'
line 0:-1 missing PHRASE at '<EOF>'
What might be causing this error, and what might be a good, clean way to
parse out the "phrase" in the input text?
Sean O'Dell
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address