[antlr-interest] C grammar from antlr.org running into 'no viable alternative at input'
Sushil Bajracharya
bajracharya at gmail.com
Wed May 11 11:05:35 PDT 2011
I am relatively new to antlr, and would appreciate suggestions on
moving forward to tackle a problem I am having with 'no viable
alternative at input'.
I am trying to use the C grammar file from here
http://www.antlr.org/grammar/1153358328744/C.g to implement a parser
that extracts declarations (typedefs, functions) from C files. More
often I am running into problems, as the parser that gets generated
seems to be confused with certain forms of function declarations.
For example, when I use the following as an input code in antlrworks
debugger (using the unmodified grammar from
http://www.antlr.org/grammar/1153358328744/C.g);
static void function(some_type bus)
{
}
I see the following list of problems get reported by the debugger:
__Test___input.txt line 1:20 missing ';' at '('
__Test___input.txt line 1:20 no viable alternative at input '('
__Test___input.txt line 1:20 no viable alternative at input '('
__Test___input.txt line 1:34 no viable alternative at input ')'
I think because of this my parser fails to extract all function
definitions from the file. I am wondering if anyone here has used or
extended the grammar (http://www.antlr.org/grammar/1153358328744/C.g)
and encountered the problem I am seeing and has a fix for it.
Thank you
- sushil
More information about the antlr-interest
mailing list