From 8fc2dc2cd1addd92171ba11cf105f26a00634b2f Mon Sep 17 00:00:00 2001 From: steve Date: Tue, 23 May 2000 16:03:13 +0000 Subject: [PATCH] Better parsing of expressions lists will empty expressoins. --- parse.y | 43 +++++++++++++++---------------------------- pform.cc | 14 +++++++++++++- pform_dump.cc | 7 +++++-- 3 files changed, 33 insertions(+), 31 deletions(-) diff --git a/parse.y b/parse.y index 17e1f3a65..7cb6ebef0 100644 --- a/parse.y +++ b/parse.y @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: parse.y,v 1.97 2000/05/16 04:05:16 steve Exp $" +#ident "$Id: parse.y,v 1.98 2000/05/23 16:03:13 steve Exp $" #endif # include "parse_misc.h" @@ -714,7 +714,9 @@ expression ; - + /* Many contexts take a comma separated list of expressions. Null + expressions can happen anywhere in the list, so there are two + extra rules for parsing and installing those nulls. */ expression_list : expression_list ',' expression { svector*tmp = new svector(*$1, $3); @@ -726,11 +728,17 @@ expression_list (*tmp)[0] = $1; $$ = tmp; } + | + { svector*tmp = new svector(1); + (*tmp)[0] = 0; + $$ = tmp; + } + | expression_list ',' { svector*tmp = new svector(*$1, 0); delete $1; $$ = tmp; - } + } ; @@ -882,15 +890,7 @@ gate_instance delete $1; $$ = tmp; } - | IDENTIFIER '(' ')' - { lgate*tmp = new lgate; - tmp->name = $1; - tmp->parms = 0; - tmp->file = @1.text; - tmp->lineno = @1.first_line; - delete $1; - $$ = tmp; - } + | IDENTIFIER range '(' expression_list ')' { lgate*tmp = new lgate; svector*rng = $2; @@ -912,6 +912,9 @@ gate_instance tmp->lineno = @1.first_line; $$ = tmp; } + + /* Modules can also take ports by port-name expressions. */ + | IDENTIFIER '(' port_name_list ')' { lgate*tmp = new lgate; tmp->name = $1; @@ -2080,14 +2083,6 @@ statement delete $3; $$ = tmp; } - | SYSTEM_IDENTIFIER '(' ')' ';' - { svectorpt (0); - PCallTask*tmp = new PCallTask($1, pt); - tmp->set_file(@1.text); - tmp->set_lineno(@1.first_line); - delete $1; - $$ = tmp; - } | SYSTEM_IDENTIFIER ';' { svectorpt (0); PCallTask*tmp = new PCallTask($1, pt); @@ -2104,14 +2099,6 @@ statement delete $3; $$ = tmp; } - | identifier '(' ')' ';' - { svectorpt (0); - PCallTask*tmp = new PCallTask($1, pt); - tmp->set_file(@1.text); - tmp->set_lineno(@1.first_line); - delete $1; - $$ = tmp; - } | identifier ';' { svectorpt (0); PCallTask*tmp = new PCallTask($1, pt); diff --git a/pform.cc b/pform.cc index 53cfa817c..18f88c6d2 100644 --- a/pform.cc +++ b/pform.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: pform.cc,v 1.60 2000/05/16 04:05:16 steve Exp $" +#ident "$Id: pform.cc,v 1.61 2000/05/23 16:03:13 steve Exp $" #endif # include "compiler.h" @@ -439,10 +439,19 @@ void pform_make_modgates(const string&type, cur.file, cur.lineno); } else if (cur.parms) { + + /* If there are no parameters, the parser will be + tricked into thinking it is one empty + parameter. This fixes that. */ + if ((cur.parms->count() == 1) && (cur.parms[0][0] == 0)) { + delete cur.parms; + cur.parms = new svector(0); + } pform_make_modgate(type, cur.name, overrides, cur.parms, cur.range[0], cur.range[1], cur.file, cur.lineno); + } else { svector*wires = new svector(0); pform_make_modgate(type, cur.name, overrides, @@ -865,6 +874,9 @@ int pform_parse(const char*path, map&modules, /* * $Log: pform.cc,v $ + * Revision 1.61 2000/05/23 16:03:13 steve + * Better parsing of expressions lists will empty expressoins. + * * Revision 1.60 2000/05/16 04:05:16 steve * Module ports are really special PEIdent * expressions, because a name can be used diff --git a/pform_dump.cc b/pform_dump.cc index b8ad64e9d..f9f51d464 100644 --- a/pform_dump.cc +++ b/pform_dump.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: pform_dump.cc,v 1.59 2000/05/16 04:05:16 steve Exp $" +#ident "$Id: pform_dump.cc,v 1.60 2000/05/23 16:03:13 steve Exp $" #endif /* @@ -242,7 +242,7 @@ void PWire::dump(ostream&out) const void PGate::dump_pins(ostream&out) const { if (pin_count()) { - out << *pin(0); + if (pin(0)) out << *pin(0); for (unsigned idx = 1 ; idx < pin_count() ; idx += 1) { out << ", "; @@ -774,6 +774,9 @@ void PUdp::dump(ostream&out) const /* * $Log: pform_dump.cc,v $ + * Revision 1.60 2000/05/23 16:03:13 steve + * Better parsing of expressions lists will empty expressoins. + * * Revision 1.59 2000/05/16 04:05:16 steve * Module ports are really special PEIdent * expressions, because a name can be used