Hi Folks,

When trying to code a c language parser I got a issue with shift/reduce
conflict in bison, which actually hurts me.

It happens when parsing this:

int main( int a,[XXX] int b)

[XXX] is the pointer of the issue:
When reading the comma it does not know wether to continue iterating in
vardeclarationlist or in identifierlist.
If the software looked one token ahead to see if after the ',' there is a
type it should proceed iterating the vardeclarationlist, else proceed with
the identifierlist.
How can i improve my situation ?

best regards Günther

Rules below



my rules are like this:

functiondefinition:
type_ptr identifier '(' vardeclarationlist ')' compound_statement ;

vardeclarationlist :
vardeclaration |
vardeclarationlist ',' vardeclaration  ;
example: int a, int b=2

vardeclaration:
type_ptr identifierlist  ;
example: int *b

identifierlist :
identifierwithdefault |
identifierlist ',' identifierwithdefault

identifierwithdefault:
identifier |
identifier '=' expression |
identifier '[' INTNUM ']'


type_ptr :
type_ptr '*' |
type ;
example: int

Reply via email to