1
0
mirror of git://projects.qi-hardware.com/fped.git synced 2024-11-22 11:41:52 +02:00

The comment of the previous commit contained a slight exaggeration: we did

in fact let duplicate variable names pass.

- fpd.y: report duplicate variable/loop/column names



git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5766 99fdad57-331a-0410-800a-d7fa5415bdb3
This commit is contained in:
werner 2009-12-31 16:24:23 +00:00
parent 325a732e1c
commit 40028ed18f

29
fpd.y
View File

@ -68,6 +68,23 @@ static struct vec *find_vec(const struct frame *frame, const char *name)
}
static struct var *find_var(const struct frame *frame, const char *name)
{
const struct table *table;
struct var *var;
struct loop *loop;
for (table = frame->tables; table; table = table->next)
for (var = table->vars; var; var = var->next)
if (var->name == name)
return var;
for (loop = frame->loops; loop; loop = loop->next)
if (loop->var.name == name)
return &loop->var;
return NULL;
}
static void set_frame(struct frame *frame)
{
curr_frame = frame;
@ -289,10 +306,18 @@ frame_item:
table
| TOK_SET ID '=' expr
{
if (find_var(curr_frame, $2)) {
yyerrorf("duplicate variable \"%s\"", $2);
YYABORT;
}
make_var($2, $4);
}
| TOK_LOOP ID '=' expr ',' expr
{
if (find_var(curr_frame, $2)) {
yyerrorf("duplicate variable \"%s\"", $2);
YYABORT;
}
make_loop($2, $4, $6);
}
| vec
@ -347,6 +372,10 @@ vars:
var:
ID
{
if (find_var(curr_frame, $1)) {
yyerrorf("duplicate variable \"%s\"", $1);
YYABORT;
}
$$ = zalloc_type(struct var);
$$->name = $1;
$$->frame = curr_frame;