Hello,
I have been writing a simple compiler for a CS class and have run into a few
problems that I can't figure out how to solve. %left does not seem to be
working as Bison is derivating immediately.
For example:
a := b + c + d
expr : expr ADDOP expr
expr: ref_name
ref_name: IDENTIFIER
ADDOP
On 2 Aug 2010, at 15:52, u...@jona-mission.de wrote:
Das läuft auch ganz prima durch, aber beim Ende (eof) gibt es einen
seg-fault.
...
%%
...
ipadr: VALID_IP { sprintf($$,"valid-ip=%s",$1); };
You haven't allocated $$ here. In the other cases, you just hand over
an allocated pointer, s
On 3 Aug 2010, at 18:54, Sasan Forghani wrote:
I have been writing a simple compiler for a CS class and have run
into a few
problems that I can't figure out how to solve. %left does not seem
to be
working as Bison is derivating immediately.
For example:
a := b + c + d
expr : expr ADDOP e
[Please keep the cc to the list so that others may follow.]
On 3 Aug 2010, at 22:26, Sasan Forghani wrote:
Thank you for the response. However, I don't understand your second
statement about properly allocating. In the Bison script, I have
IDENTIFIER specified as type . And in the ( expr
On 3 Aug 2010, at 18:54, Sasan Forghani wrote:
| ( expr)
as long as there isn't ( expr ) in the input input move up without
problem.
However once input does have an ( expr) part, $1 at
the ADDOP
level has the value of $1 at the ASSIGNMENT level.
When I add
the following action to the ( e
You seem to do it already by the strdup(). The next step would be to
clean it up in the actions.
On 3 Aug 2010, at 23:13, Sasan Forghani wrote:
Yes the lexer is generated by flex. In flex script, I have the
actions:
{addop} {yylval.blOperator = strdup(yytext); return BL_ADDOP;}
{identifie