r5766 - trunk/eda/fped
werner at docs.openmoko.org
werner at docs.openmoko.org
Thu Dec 31 17:24:23 CET 2009
Author: werner
Date: 2009-12-31 17:24:23 +0100 (Thu, 31 Dec 2009)
New Revision: 5766
Modified:
trunk/eda/fped/fpd.y
Log:
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
Modified: trunk/eda/fped/fpd.y
===================================================================
--- trunk/eda/fped/fpd.y 2009-12-31 16:13:49 UTC (rev 5765)
+++ trunk/eda/fped/fpd.y 2009-12-31 16:24:23 UTC (rev 5766)
@@ -68,6 +68,23 @@
}
+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 @@
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 @@
var:
ID
{
+ if (find_var(curr_frame, $1)) {
+ yyerrorf("duplicate variable \"%s\"", $1);
+ YYABORT;
+ }
$$ = zalloc_type(struct var);
$$->name = $1;
$$->frame = curr_frame;
More information about the commitlog
mailing list