Quantcast
Channel: ANTLR wildcard operator not consuming expected input - Stack Overflow
Viewing all articles
Browse latest Browse all 2

ANTLR wildcard operator not consuming expected input

$
0
0

I'm writing an antlr grammar that reads in yacc specification file. Yacc spec files are of the form

declarations %%rules %%programs 

However, I'm only interested in the declarations and rules sections of the yacc spec file. I have defined rules which match the declarations and rules well but I was trying to match everything that comes after the second '%%' using a wildcard operator (.*?). This fails. Here's the
Link to my anltr grammar for yacc grammars

How can I match whatever that comes after the second '%%'.

I have also tried matching anything but the EOF using

<some_rule> : ~(EOF)* ;

Here's an example of the file that fails


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images