Hi,

I am using bison with flex (I am quite new with parsers).

I want to parse a grammar as given below:

char a = 'A'
int i = 5555
float f = 23.456

What is the best way to represent the grammar ?

1) declaration : datatype IDENTIFIER '=' CONSTANT;

datatype : CHAR
                | INT
                | FLOAT


2) declaration : CHAR IDENTIFIER '=' CHAR_CONST
                        | INT IDENTIFIER '=' INT_CONST
                        | FLOAT IDENTIFIER '=' FLOAT_CONST

In the (1) option above where do I parse what type of "CONSTANT" it is ?

The (2) option seems to be very verbose.

Regards.
_______________________________________________
help-bison@gnu.org https://lists.gnu.org/mailman/listinfo/help-bison

Reply via email to