Better parsing of expressions lists will empty expressoins.

This commit is contained in:
steve 2000-05-23 16:03:13 +00:00
parent 092b1bded5
commit 8fc2dc2cd1
3 changed files with 33 additions and 31 deletions

43
parse.y
View File

@ -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<PExpr*>*tmp = new svector<PExpr*>(*$1, $3);
@ -726,11 +728,17 @@ expression_list
(*tmp)[0] = $1;
$$ = tmp;
}
|
{ svector<PExpr*>*tmp = new svector<PExpr*>(1);
(*tmp)[0] = 0;
$$ = tmp;
}
| expression_list ','
{ svector<PExpr*>*tmp = new svector<PExpr*>(*$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<PExpr*>*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 '(' ')' ';'
{ svector<PExpr*>pt (0);
PCallTask*tmp = new PCallTask($1, pt);
tmp->set_file(@1.text);
tmp->set_lineno(@1.first_line);
delete $1;
$$ = tmp;
}
| SYSTEM_IDENTIFIER ';'
{ svector<PExpr*>pt (0);
PCallTask*tmp = new PCallTask($1, pt);
@ -2104,14 +2099,6 @@ statement
delete $3;
$$ = tmp;
}
| identifier '(' ')' ';'
{ svector<PExpr*>pt (0);
PCallTask*tmp = new PCallTask($1, pt);
tmp->set_file(@1.text);
tmp->set_lineno(@1.first_line);
delete $1;
$$ = tmp;
}
| identifier ';'
{ svector<PExpr*>pt (0);
PCallTask*tmp = new PCallTask($1, pt);

View File

@ -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<PExpr*>(0);
}
pform_make_modgate(type, cur.name, overrides,
cur.parms,
cur.range[0], cur.range[1],
cur.file, cur.lineno);
} else {
svector<PExpr*>*wires = new svector<PExpr*>(0);
pform_make_modgate(type, cur.name, overrides,
@ -865,6 +874,9 @@ int pform_parse(const char*path, map<string,Module*>&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

View File

@ -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