What is wrong with whitespaces in ANTLR?

Attadsded

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