[antlr-interest] NoViableAltException in tree grammar
Tom Smith
yotommy at gmail.com
Thu Jul 10 07:05:38 PDT 2008
Hello,
I'm stumped by the case below. I had assumed the difficulties would begin
with ambiguities in my grammars, but I'm already stuck with a
NoViableAltException.
I need to be able to handle the following cases:
- a followed by b
- a only
- b only
My initial parser works OK on all three types of input, but my tree parser
yields a NoViableAltException when presented with the third case. That is
surprising to me since the alternatives have the same form in both parsers.
Suggestions welcome!
Thanks,
Tom.
===
grammar Test;
options {
output = AST;
}
top
: before after
-> before after
| before
-> before
| after
-> after
;
before
: 'before'
;
after
: 'after'
;
WS
: (' '|'\r'|'\t'|'\u000C'|'\n') {$channel=HIDDEN;}
;
===
tree grammar TestTree;
options {
ASTLabelType = CommonTree;
}
top
: before after
| before
| after
;
before
: 'before'
;
after
: 'after'
;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080710/9a73968e/attachment.html
More information about the antlr-interest
mailing list