help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Whether to Parser


From: Prashant Shah
Subject: Whether to Parser
Date: Sat, 13 May 2017 18:24:44 +0530

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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]