Better parsing of expressions lists will empty expressoins.
This commit is contained in:
parent
092b1bded5
commit
8fc2dc2cd1
41
parse.y
41
parse.y
|
|
@ -19,7 +19,7 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#if !defined(WINNT) && !defined(macintosh)
|
#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
|
#endif
|
||||||
|
|
||||||
# include "parse_misc.h"
|
# 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_list ',' expression
|
: expression_list ',' expression
|
||||||
{ svector<PExpr*>*tmp = new svector<PExpr*>(*$1, $3);
|
{ svector<PExpr*>*tmp = new svector<PExpr*>(*$1, $3);
|
||||||
|
|
@ -726,6 +728,12 @@ expression_list
|
||||||
(*tmp)[0] = $1;
|
(*tmp)[0] = $1;
|
||||||
$$ = tmp;
|
$$ = tmp;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
{ svector<PExpr*>*tmp = new svector<PExpr*>(1);
|
||||||
|
(*tmp)[0] = 0;
|
||||||
|
$$ = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
| expression_list ','
|
| expression_list ','
|
||||||
{ svector<PExpr*>*tmp = new svector<PExpr*>(*$1, 0);
|
{ svector<PExpr*>*tmp = new svector<PExpr*>(*$1, 0);
|
||||||
delete $1;
|
delete $1;
|
||||||
|
|
@ -882,15 +890,7 @@ gate_instance
|
||||||
delete $1;
|
delete $1;
|
||||||
$$ = tmp;
|
$$ = 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 ')'
|
| IDENTIFIER range '(' expression_list ')'
|
||||||
{ lgate*tmp = new lgate;
|
{ lgate*tmp = new lgate;
|
||||||
svector<PExpr*>*rng = $2;
|
svector<PExpr*>*rng = $2;
|
||||||
|
|
@ -912,6 +912,9 @@ gate_instance
|
||||||
tmp->lineno = @1.first_line;
|
tmp->lineno = @1.first_line;
|
||||||
$$ = tmp;
|
$$ = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Modules can also take ports by port-name expressions. */
|
||||||
|
|
||||||
| IDENTIFIER '(' port_name_list ')'
|
| IDENTIFIER '(' port_name_list ')'
|
||||||
{ lgate*tmp = new lgate;
|
{ lgate*tmp = new lgate;
|
||||||
tmp->name = $1;
|
tmp->name = $1;
|
||||||
|
|
@ -2080,14 +2083,6 @@ statement
|
||||||
delete $3;
|
delete $3;
|
||||||
$$ = tmp;
|
$$ = 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 ';'
|
| SYSTEM_IDENTIFIER ';'
|
||||||
{ svector<PExpr*>pt (0);
|
{ svector<PExpr*>pt (0);
|
||||||
PCallTask*tmp = new PCallTask($1, pt);
|
PCallTask*tmp = new PCallTask($1, pt);
|
||||||
|
|
@ -2104,14 +2099,6 @@ statement
|
||||||
delete $3;
|
delete $3;
|
||||||
$$ = tmp;
|
$$ = 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 ';'
|
| identifier ';'
|
||||||
{ svector<PExpr*>pt (0);
|
{ svector<PExpr*>pt (0);
|
||||||
PCallTask*tmp = new PCallTask($1, pt);
|
PCallTask*tmp = new PCallTask($1, pt);
|
||||||
|
|
|
||||||
14
pform.cc
14
pform.cc
|
|
@ -17,7 +17,7 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#if !defined(WINNT) && !defined(macintosh)
|
#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
|
#endif
|
||||||
|
|
||||||
# include "compiler.h"
|
# include "compiler.h"
|
||||||
|
|
@ -439,10 +439,19 @@ void pform_make_modgates(const string&type,
|
||||||
cur.file, cur.lineno);
|
cur.file, cur.lineno);
|
||||||
|
|
||||||
} else if (cur.parms) {
|
} 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,
|
pform_make_modgate(type, cur.name, overrides,
|
||||||
cur.parms,
|
cur.parms,
|
||||||
cur.range[0], cur.range[1],
|
cur.range[0], cur.range[1],
|
||||||
cur.file, cur.lineno);
|
cur.file, cur.lineno);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
svector<PExpr*>*wires = new svector<PExpr*>(0);
|
svector<PExpr*>*wires = new svector<PExpr*>(0);
|
||||||
pform_make_modgate(type, cur.name, overrides,
|
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 $
|
* $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
|
* Revision 1.60 2000/05/16 04:05:16 steve
|
||||||
* Module ports are really special PEIdent
|
* Module ports are really special PEIdent
|
||||||
* expressions, because a name can be used
|
* expressions, because a name can be used
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#if !defined(WINNT) && !defined(macintosh)
|
#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
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -242,7 +242,7 @@ void PWire::dump(ostream&out) const
|
||||||
void PGate::dump_pins(ostream&out) const
|
void PGate::dump_pins(ostream&out) const
|
||||||
{
|
{
|
||||||
if (pin_count()) {
|
if (pin_count()) {
|
||||||
out << *pin(0);
|
if (pin(0)) out << *pin(0);
|
||||||
|
|
||||||
for (unsigned idx = 1 ; idx < pin_count() ; idx += 1) {
|
for (unsigned idx = 1 ; idx < pin_count() ; idx += 1) {
|
||||||
out << ", ";
|
out << ", ";
|
||||||
|
|
@ -774,6 +774,9 @@ void PUdp::dump(ostream&out) const
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: pform_dump.cc,v $
|
* $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
|
* Revision 1.59 2000/05/16 04:05:16 steve
|
||||||
* Module ports are really special PEIdent
|
* Module ports are really special PEIdent
|
||||||
* expressions, because a name can be used
|
* expressions, because a name can be used
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue