[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: concatenating string into $$
From: |
Tom Jackson |
Subject: |
Re: concatenating string into $$ |
Date: |
28 Feb 2004 09:35:02 -0800 |
On Sat, 2004-02-28 at 03:17, Hans Aberg wrote:
> 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.
Hmm, I think I'm getting what you are saying. Right now the lexer is
reading stuff like [if $a]a[/if] or [set a "b"], etc. So the yytext is
different than what I would print, but I could substitute the yytext I
guess and simplify my parser.
So in the above, I'm guessing, if the yytext for ENDIF were '}' it
wouldn't need to be handled explicitly by the parser?
Thanks for the pointers, I knew this must be easier than I was making
it, assuming I set things up correctly.
I also got the if-elseif, etc working, I'll go back to my simplified
code and try out these ideas.
tom jackson
Re: concatenating string into $$, Hans Aberg, 2004/02/28