Doesn't that depend on whether you want to allow : char a=5555; int i='A'
? On 13 May 2017 at 13:54, Prashant Shah <pshah.mum...@gmail.com> wrote: > 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 > _______________________________________________ help-bison@gnu.org https://lists.gnu.org/mailman/listinfo/help-bison