[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: |
27 Feb 2004 14:50:24 -0800 |
Thanks for the help everyone!
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.
)
statements:
statement
|
statements statement
;
statement:
string
|
command
|
variable
;
string:
STRING
{
char * string;
if (strlen($1) > 0) {
sprintf(string, "\n%%-%dsappend string {%%s}\n", (4*level));
printf(string,blank,$1);
}
}
;
command:
setcmd
|
ifcmd
|
endif
;
variable:
VARIABLE
{
char * string;
sprintf(string,"\n%%-%dsappend string %%s\n", (4*level) );
printf(string,blank, $1);
}
;
ifcmd:
IFCMD ARGUMENT ENDCMD
{
char * string;
sprintf(string,"\n%%-%dsif %%s {\n", (4*level) );
printf(string,blank, $2);
level++;
}
;
setcmd:
SETCMD ARGUMENT ENDCMD
{
char * string;
sprintf(string,"\n%%-%dsset %%s\n",(4*level) );
printf(string, blank, $2);
}
|
SETCMD ARGUMENT ARGUMENT ENDCMD
{
char * string;
sprintf(string, "\n%%-%dsset %%s %%s\n", (4*level) );
printf(string, blank, $2, $3);
}
;
endif:
ENDIF
{
char * string;
level--;
sprintf(string, "\n%%-%ds}\n", (4*level) );
printf(string, blank);
}
;
Thanks again,
tom jackson
Re: concatenating string into $$, Hans Aberg, 2004/02/28