help-bison
[Top][All Lists]
Advanced

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

Re: Whether to Parser


From: Mike Aubury
Subject: Re: Whether to Parser
Date: Sat, 13 May 2017 17:18:23 +0100

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 <address@hidden> 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.
> _______________________________________________
> address@hidden https://lists.gnu.org/mailman/listinfo/help-bison
>


reply via email to

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