[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
$1 is not $1 but $1+$2
From: |
Gianni Pucciani |
Subject: |
$1 is not $1 but $1+$2 |
Date: |
Fri, 29 Jul 2005 10:53:11 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040113 |
Hi all,
I'm quite new in using bison/flex and I'm getting crazy doing a simple
parser for a configuration file.
The problem is with these few rules (I wouldn't bored you with the whole
problem explanation and I guess I can skip it):
linedbfilter: dbname { printf("DBNAME is (%s)\n",$1); }
|
dbname tablelist { printf("DBNAME is (%s) with table list:
%s\n",$1,$2); }
|
COMMENT
;
dbname: VALUE { printf("dbname is: (%s)\n", $1);
$$ = $1 }
;
tablelist: O_PAR tables C_PAR { printf("Table list found: %s\n", $$); }
;
The message in the rule for dbname is correct but that in linedbfilter
is not. In short, in the line:
dbname tablelist { printf("DBNAME is (%s) with table list: %s\n",$1,$2); }
the value in $1 is not that retrieved by the rule dbname. What happens
is that in that rule, the value of $1 is not "$$ of dbname rule" but $1
+ $2 , that is the two strings "dbname tablelist" concatenated.
In other words, in the passage from one rule to another, the value of
dbname is lost.
Any advice?
Thanks a lot.
Gianni
- $1 is not $1 but $1+$2,
Gianni Pucciani <=