I have really simple XML (HTML) parsing ANTLR grammar:
wiki: ggg+;
ggg: tag | text;
tag: '<' tx=TEXT { System.out.println($tx.getText()); } '>';
text: tx=TEXT { System.out.println($tx.getText()); };
CHAR: ~('<'|'>');
TEXT: CHAR+;
With such input: "<ggg> fff"
it works fine.
But when I start to deal with whitespaces it fails. For example:
" <ggg> fff "
- fails at beggining"<ggg> <hhh> "
- fails after<ggg>
"<ggg> fff "
- works fine"<ggg> "
- fails at end
I don't know what is wrong. Maybe there is some special grammar option to handle this. ANTLRWorks gives me NoViableAltException
.