i am not experienced and still learning about grammar. i just need an example grammar that support for whitespace and special character like !,",#,$,^,&. Because with my current grammar and the rules inside i cant print out some string that support white space and special symbol. i know whitespace are tossed).
For example if i give input : Hello World!!!!!
the output is HelloWorld <-- the whitespace & char (!) tossed
look at this image : problem
why??
here is my current grammar example.g4
string
: '"' (~'"'|'\"')* '"'
;
Id
: Letter(Letter|Digit)*
;
Num
: Digit
;
fragment
Digit
: [0-9]+
;
Letter
: [a-zA-Z]
;
LINE_COMMENT
: '//' ~[\r\n]* -> skip
;
i was read this link : ANTLR parse strings (keep whitespaces) and parse normal identifiers
but i cant understand what happen. i need an advice. thanks.
WS: [ \t\r\n]+;- Lucas Trzesniewski