1

i use a definition so called

message : '"'.* '"';

that represents every little thing inside " " is message , terminals it works well with "lkjaldjfa kajf " something common but when i met "\n" it turns to a nightmare -- which cause infinitive loop ,eat up my memory .

I dont know why .. thanks

Yank
  • 718
  • 6
  • 17

1 Answers1

1

... it turns to a nightmare -- which cause infinitive loop, eat up my memory.

Hard to comment on that without being able to reproduce it.

However, the parser rule:

message : '"' .* '"';

matches the token '"' followed by zero or more other tokens ending with the token '"'.

Unless you have a very good reason to keep it as a parser rule (which I'd like to hear then), change it to a lexer rule:

Message : '"' .* '"';

which matches the character '"' followed by zero or more other characters ending with the character '"'.


Also see: Practical difference between parser rules and lexer rules in ANTLR?

Community
  • 1
  • 1
Bart Kiers
  • 166,582
  • 36
  • 299
  • 288