[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: concatenating string into $$
From: |
Hans Aberg |
Subject: |
Re: concatenating string into $$ |
Date: |
Sat, 28 Feb 2004 12:17:19 +0100 |
At 14:50 -0800 2004/02/27, Tom Jackson wrote:
>On Fri, 2004-02-27 at 10:53, Hans Aberg wrote:
>> You can write it as you suggest, in one single statement:
>> ifcmd:
>> IFCMD ARGUMENT ENDCMD statements ENDIF {...}
>
>The above does work, and I had tried it, the problem is I can't figure
>out a way (good or bad) to print out the result. Here is what I am doing
>now, but it doesn't validate the if:
>
>(I've looked at gcc java's parse.y, a very complex example. It looks
>like it stores everything in various structures. In my case I wouldn't
>mind reading and validating an entire file at a time. Are there any
>examples less advanced?
>I also tried
>sprintf($$,"some string %s", $2)... Not sure if this worked or not.
>)
The problem is that you do not tell how you hook up your lexer: A lot of
people forget copying the token that the Flex lexer identifies in its
buffer. A single Bison parser rule will typically call the lexer several
times before proceeding to the action. Thus, without copying, one gets
funny answers.
If all your tokens and variables make a printout, and your lexer is
correctly hooked up, you may simply write
ifcmd:
IFCMD ARGUMENT ENDCMD statements ENDIF {
sprintf($$,"if %s then %s", $2, $4);
}
And so forth.
You might benefit by using Bison's debugging features (see manual).
Hans Aberg
Re: concatenating string into $$, Hans Aberg, 2004/02/28