antlr4 grammar match any character question

Viewed 18

I think .*? can match any characters except \n, but follow can not parse '{' and '}'

enter image description here

1 Answers

Inside a parser rule, the . matches any token, not any character. Change the rule into a lexer rule instead:

HeadDesc : '<?' .*? '?>';

And then the . will also match line breaks.

Related