help-bison
[Top][All Lists]
Advanced

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

Expression grammar with call


From: Philip Herron
Subject: Expression grammar with call
Date: Fri, 29 Nov 2013 08:54:16 +0000

Hey all,

Its been a while since i've really seriously been working with bison but
say i have the grammar:

%right '='
%left '+'

expression: IDENTIFIER '=' expression
                | expression '+' expression
                | ...
                | '( ' expression ')'
                | primary

primary: IDENTIFIER
           | INTEGER

What way should i go about adding support for something like:

x = call ( )

I get a shift/reduce conflict on this. Currently i have and it mostly works.

parameter: expression

parameter_list: parameter_list ',' parameter
                    | parameter

call: IDENTIFIER '(' parameter_list ')'

primary: IDENTIFIER
           | INTEGER
           | call

Then if i want something like:

x = mytype { x = 1, y = 2; }

I was able to use %right '{' for this to work. But i am not sure how calls
should be implemented.

Thanks

--Phil


reply via email to

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