remove string from lexical phase.

This commit is contained in:
steve 1999-07-10 01:03:18 +00:00
parent 15e6c7d4b0
commit 46df679fc5
5 changed files with 110 additions and 87 deletions

View File

@ -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) #if !defined(WINNT)
#ident "$Id: lexor.lex,v 1.30 1999/07/08 02:06:39 steve Exp $" #ident "$Id: lexor.lex,v 1.31 1999/07/10 01:03:18 steve Exp $"
#endif #endif
//# define YYSTYPE lexval //# define YYSTYPE lexval
@ -29,6 +29,7 @@
# include "parse_misc.h" # include "parse_misc.h"
# include "parse.h" # include "parse.h"
# include <ctype.h> # include <ctype.h>
# include <string.h>
extern FILE*vl_input; extern FILE*vl_input;
extern string vl_file; extern string vl_file;
@ -99,11 +100,12 @@ static int comment_enter;
\" { BEGIN(CSTRING); } \" { BEGIN(CSTRING); }
<CSTRING>\\\" { yymore(); } <CSTRING>\\\" { yymore(); }
<CSTRING>\n { BEGIN(0); <CSTRING>\n { BEGIN(0);
yylval.text = new string(yytext, strlen(yytext)); yylval.text = strdup(yytext);
VLerror(yylloc, "Missing close quote of string."); VLerror(yylloc, "Missing close quote of string.");
return STRING; } return STRING; }
<CSTRING>\" { BEGIN(0); <CSTRING>\" { BEGIN(0);
yylval.text = new string(yytext, strlen(yytext)-1); yylval.text = strdup(yytext);
yylval.text[strlen(yytext)-1] = 0;
return STRING; } return STRING; }
<CSTRING>. { yymore(); } <CSTRING>. { yymore(); }
@ -126,28 +128,28 @@ static int comment_enter;
[a-zA-Z_][a-zA-Z0-9$_]* { [a-zA-Z_][a-zA-Z0-9$_]* {
int rc = check_identifier(yytext); int rc = check_identifier(yytext);
if (rc == IDENTIFIER) if (rc == IDENTIFIER)
yylval.text = new string(yytext); yylval.text = strdup(yytext);
else else
yylval.text = 0; yylval.text = 0;
return rc; } return rc; }
[a-zA-Z_][a-zA-Z0-9$_]*(\.[a-zA-Z_][a-zA-Z0-9$_]*)+ { [a-zA-Z_][a-zA-Z0-9$_]*(\.[a-zA-Z_][a-zA-Z0-9$_]*)+ {
yylval.text = new string(yytext); yylval.text = strdup(yytext);
return HIDENTIFIER; } return HIDENTIFIER; }
\\[^ \t\b\f\r]+ { \\[^ \t\b\f\r]+ {
yylval.text = new string(yytext); yylval.text = strdup(yytext);
return IDENTIFIER; } return IDENTIFIER; }
\$([a-zA-Z0-9$_]+) { \$([a-zA-Z0-9$_]+) {
if (strcmp(yytext,"$attribute") == 0) if (strcmp(yytext,"$attribute") == 0)
return KK_attribute; return KK_attribute;
yylval.text = new string(yytext); yylval.text = strdup(yytext);
return SYSTEM_IDENTIFIER; } return SYSTEM_IDENTIFIER; }
\.[a-zA-Z_][a-zA-Z0-9$_]* { \.[a-zA-Z_][a-zA-Z0-9$_]* {
yylval.text = new string(yytext+1); yylval.text = strdup(yytext+1);
return PORTNAME; } return PORTNAME; }
[0-9][0-9_]*[ \t]*\'d[ \t]*[0-9][0-9_]* { [0-9][0-9_]*[ \t]*\'d[ \t]*[0-9][0-9_]* {

152
parse.y
View File

@ -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) #if !defined(WINNT)
#ident "$Id: parse.y,v 1.48 1999/07/03 02:12:51 steve Exp $" #ident "$Id: parse.y,v 1.49 1999/07/10 01:03:18 steve Exp $"
#endif #endif
# include "parse_misc.h" # include "parse_misc.h"
@ -31,7 +31,7 @@ extern void lex_end_table();
%union { %union {
char letter; char letter;
string*text; char*text;
list<string>*strings; list<string>*strings;
PCase::Item*citem; PCase::Item*citem;
@ -266,7 +266,7 @@ delay_value
} }
} }
| IDENTIFIER | IDENTIFIER
{ PEIdent*tmp = new PEIdent(*$1); { PEIdent*tmp = new PEIdent($1);
tmp->set_file(@1.text); tmp->set_file(@1.text);
tmp->set_lineno(@1.first_line); tmp->set_lineno(@1.first_line);
$$ = tmp; $$ = tmp;
@ -288,7 +288,7 @@ description
: module : module
| udp_primitive | udp_primitive
| KK_attribute '(' IDENTIFIER ',' STRING ',' STRING ')' | KK_attribute '(' IDENTIFIER ',' STRING ',' STRING ')'
{ pform_set_type_attrib(*$3, *$5, *$7); { pform_set_type_attrib($3, $5, $7);
delete $3; delete $3;
delete $5; delete $5;
delete $7; delete $7;
@ -568,28 +568,28 @@ expr_primary
$$ = 0; $$ = 0;
} }
| STRING | STRING
{ PEString*tmp = new PEString(*$1); { PEString*tmp = new PEString($1);
tmp->set_file(@1.text); tmp->set_file(@1.text);
tmp->set_lineno(@1.first_line); tmp->set_lineno(@1.first_line);
$$ = tmp; $$ = tmp;
delete $1; delete $1;
} }
| identifier | identifier
{ PEIdent*tmp = new PEIdent(*$1); { PEIdent*tmp = new PEIdent($1);
tmp->set_file(@1.text); tmp->set_file(@1.text);
tmp->set_lineno(@1.first_line); tmp->set_lineno(@1.first_line);
$$ = tmp; $$ = tmp;
delete $1; delete $1;
} }
| SYSTEM_IDENTIFIER | SYSTEM_IDENTIFIER
{ PEIdent*tmp = new PEIdent(*$1); { PEIdent*tmp = new PEIdent($1);
tmp->set_file(@1.text); tmp->set_file(@1.text);
tmp->set_lineno(@1.first_line); tmp->set_lineno(@1.first_line);
$$ = tmp; $$ = tmp;
delete $1; delete $1;
} }
| identifier '[' expression ']' | identifier '[' expression ']'
{ PEIdent*tmp = new PEIdent(*$1); { PEIdent*tmp = new PEIdent($1);
tmp->set_file(@1.text); tmp->set_file(@1.text);
tmp->set_lineno(@1.first_line); tmp->set_lineno(@1.first_line);
tmp->msb_ = $3; tmp->msb_ = $3;
@ -597,7 +597,7 @@ expr_primary
$$ = tmp; $$ = tmp;
} }
| identifier '[' expression ':' expression ']' | identifier '[' expression ':' expression ']'
{ PEIdent*tmp = new PEIdent(*$1); { PEIdent*tmp = new PEIdent($1);
tmp->set_file(@1.text); tmp->set_file(@1.text);
tmp->set_lineno(@1.first_line); tmp->set_lineno(@1.first_line);
tmp->msb_ = $3; tmp->msb_ = $3;
@ -792,13 +792,13 @@ list_of_ports_opt
list_of_variables list_of_variables
: IDENTIFIER : IDENTIFIER
{ list<string>*tmp = new list<string>; { list<string>*tmp = new list<string>;
tmp->push_back(*$1); tmp->push_back($1);
delete $1; delete $1;
$$ = tmp; $$ = tmp;
} }
| list_of_variables ',' IDENTIFIER | list_of_variables ',' IDENTIFIER
{ list<string>*tmp = $1; { list<string>*tmp = $1;
tmp->push_back(*$3); tmp->push_back($3);
delete $3; delete $3;
$$ = tmp; $$ = tmp;
} }
@ -809,14 +809,14 @@ list_of_variables
expression meets the constraints of continuous assignments. */ expression meets the constraints of continuous assignments. */
lavalue lavalue
: identifier : identifier
{ PEIdent*tmp = new PEIdent(*$1); { PEIdent*tmp = new PEIdent($1);
tmp->set_file(@1.text); tmp->set_file(@1.text);
tmp->set_lineno(@1.first_line); tmp->set_lineno(@1.first_line);
delete $1; delete $1;
$$ = tmp; $$ = tmp;
} }
| identifier '[' expression ']' | identifier '[' expression ']'
{ PEIdent*tmp = new PEIdent(*$1); { PEIdent*tmp = new PEIdent($1);
PExpr*sel = $3; PExpr*sel = $3;
if (! pform_expression_is_constant(sel)) { if (! pform_expression_is_constant(sel)) {
yyerror(@2, "Bit select in lvalue must " yyerror(@2, "Bit select in lvalue must "
@ -831,7 +831,7 @@ lavalue
$$ = tmp; $$ = tmp;
} }
| identifier range | identifier range
{ PEIdent*tmp = new PEIdent(*$1); { PEIdent*tmp = new PEIdent($1);
assert($2->count() == 2); assert($2->count() == 2);
tmp->msb_ = (*$2)[0]; tmp->msb_ = (*$2)[0];
tmp->lsb_ = (*$2)[1]; tmp->lsb_ = (*$2)[1];
@ -853,14 +853,14 @@ lavalue
procedural assignment. This rule handles only procedural assignments. */ procedural assignment. This rule handles only procedural assignments. */
lpvalue lpvalue
: identifier : identifier
{ PEIdent*tmp = new PEIdent(*$1); { PEIdent*tmp = new PEIdent($1);
tmp->set_file(@1.text); tmp->set_file(@1.text);
tmp->set_lineno(@1.first_line); tmp->set_lineno(@1.first_line);
delete $1; delete $1;
$$ = tmp; $$ = tmp;
} }
| identifier '[' expression ']' | identifier '[' expression ']'
{ PEIdent*tmp = new PEIdent(*$1); { PEIdent*tmp = new PEIdent($1);
tmp->msb_ = $3; tmp->msb_ = $3;
tmp->set_file(@1.text); tmp->set_file(@1.text);
tmp->set_lineno(@1.first_line); tmp->set_lineno(@1.first_line);
@ -869,7 +869,7 @@ lpvalue
$$ = tmp; $$ = tmp;
} }
| identifier '[' expression ':' expression ']' | identifier '[' expression ':' expression ']'
{ PEIdent*tmp = new PEIdent(*$1); { PEIdent*tmp = new PEIdent($1);
tmp->msb_ = $3; tmp->msb_ = $3;
tmp->lsb_ = $5; tmp->lsb_ = $5;
tmp->set_file(@1.text); tmp->set_file(@1.text);
@ -887,18 +887,18 @@ lpvalue
module module
: K_module IDENTIFIER list_of_ports_opt ';' : K_module IDENTIFIER list_of_ports_opt ';'
{ pform_startmodule(*$2, $3); { pform_startmodule($2, $3);
} }
module_item_list module_item_list
K_endmodule K_endmodule
{ pform_endmodule(*$2); { pform_endmodule($2);
delete $2; delete $2;
} }
| K_module IDENTIFIER list_of_ports_opt ';' | K_module IDENTIFIER list_of_ports_opt ';'
{ pform_startmodule(*$2, $3); { pform_startmodule($2, $3);
} }
K_endmodule K_endmodule
{ pform_endmodule(*$2); { pform_endmodule($2);
delete $2; delete $2;
} }
; ;
@ -953,7 +953,7 @@ module_item
{ pform_makegates($1, $2, $3); { pform_makegates($1, $2, $3);
} }
| IDENTIFIER delay_opt gate_instance_list ';' | IDENTIFIER delay_opt gate_instance_list ';'
{ pform_make_modgates(*$1, $3); { pform_make_modgates($1, $3);
delete $1; delete $1;
if ($2) { if ($2) {
yyerror(@2, "Sorry, parameter override not supported."); yyerror(@2, "Sorry, parameter override not supported.");
@ -981,14 +981,14 @@ module_item
tmp->set_lineno(@1.first_line); tmp->set_lineno(@1.first_line);
} }
| K_task IDENTIFIER ';' | K_task IDENTIFIER ';'
{ pform_push_scope(*$2); } { pform_push_scope($2); }
task_body task_body
{ pform_pop_scope(); } { pform_pop_scope(); }
K_endtask K_endtask
{ PTask*tmp = $5; { PTask*tmp = $5;
tmp->set_file(@1.text); tmp->set_file(@1.text);
tmp->set_lineno(@1.first_line); tmp->set_lineno(@1.first_line);
pform_set_task(*$2, $5); pform_set_task($2, $5);
delete $2; delete $2;
} }
| K_function range_or_type_opt IDENTIFIER ';' func_body K_endfunction | K_function range_or_type_opt IDENTIFIER ';' func_body K_endfunction
@ -998,7 +998,7 @@ module_item
{ {
} }
| KK_attribute '(' IDENTIFIER ',' STRING ',' STRING ')' ';' | KK_attribute '(' IDENTIFIER ',' STRING ',' STRING ')' ';'
{ pform_set_attrib(*$3, *$5, *$7); { pform_set_attrib($3, $5, $7);
delete $3; delete $3;
delete $5; delete $5;
delete $7; delete $7;
@ -1017,14 +1017,14 @@ module_item_list
statement. */ statement. */
net_decl_assign net_decl_assign
: IDENTIFIER '=' expression : IDENTIFIER '=' expression
{ PEIdent*id = new PEIdent(*$1); { PEIdent*id = new PEIdent($1);
PGAssign*tmp = pform_make_pgassign(id, $3); PGAssign*tmp = pform_make_pgassign(id, $3);
tmp->set_file(@1.text); tmp->set_file(@1.text);
tmp->set_lineno(@1.first_line); tmp->set_lineno(@1.first_line);
$$ = $1; $$ = $1;
} }
| delay IDENTIFIER '=' expression | delay IDENTIFIER '=' expression
{ PEIdent*id = new PEIdent(*$2); { PEIdent*id = new PEIdent($2);
PGAssign*tmp = pform_make_pgassign(id, $4); PGAssign*tmp = pform_make_pgassign(id, $4);
tmp->set_file(@2.text); tmp->set_file(@2.text);
tmp->set_lineno(@2.first_line); tmp->set_lineno(@2.first_line);
@ -1036,13 +1036,13 @@ net_decl_assign
net_decl_assigns net_decl_assigns
: net_decl_assigns ',' net_decl_assign : net_decl_assigns ',' net_decl_assign
{ list<string>*tmp = $1; { list<string>*tmp = $1;
tmp->push_back(*$3); tmp->push_back($3);
delete $3; delete $3;
$$ = tmp; $$ = tmp;
} }
| net_decl_assign | net_decl_assign
{ list<string>*tmp = new list<string>; { list<string>*tmp = new list<string>;
tmp->push_back(*$1); tmp->push_back($1);
delete $1; delete $1;
$$ = tmp; $$ = tmp;
} }
@ -1069,7 +1069,7 @@ parameter_assign
delete tmp; delete tmp;
tmp = 0; tmp = 0;
} }
pform_set_parameter(*$1, tmp); pform_set_parameter($1, tmp);
delete $1; delete $1;
} }
; ;
@ -1086,13 +1086,13 @@ parameter_assign_list
port port
: IDENTIFIER : IDENTIFIER
{ $$ = new PWire(*$1, NetNet::IMPLICIT, NetNet::PIMPLICIT); { $$ = new PWire($1, NetNet::IMPLICIT, NetNet::PIMPLICIT);
$$->set_file(@1.text); $$->set_file(@1.text);
$$->set_lineno(@1.first_line); $$->set_lineno(@1.first_line);
delete $1; delete $1;
} }
| IDENTIFIER '[' expression ':' expression ']' | IDENTIFIER '[' expression ':' expression ']'
{ PWire*tmp = new PWire(*$1, NetNet::IMPLICIT, { PWire*tmp = new PWire($1, NetNet::IMPLICIT,
NetNet::PIMPLICIT); NetNet::PIMPLICIT);
tmp->set_file(@1.text); tmp->set_file(@1.text);
tmp->set_lineno(@1.first_line); tmp->set_lineno(@1.first_line);
@ -1110,7 +1110,7 @@ port
} }
| IDENTIFIER '[' error ']' | IDENTIFIER '[' error ']'
{ yyerror(@1, "invalid port bit select"); { yyerror(@1, "invalid port bit select");
$$ = new PWire(*$1, NetNet::IMPLICIT, NetNet::PIMPLICIT); $$ = new PWire($1, NetNet::IMPLICIT, NetNet::PIMPLICIT);
$$->set_file(@1.text); $$->set_file(@1.text);
$$->set_lineno(@1.first_line); $$->set_lineno(@1.first_line);
delete $1; delete $1;
@ -1199,22 +1199,22 @@ range_or_type_opt
so that bit ranges can be assigned. */ so that bit ranges can be assigned. */
register_variable register_variable
: IDENTIFIER : IDENTIFIER
{ pform_makewire(@1, *$1, NetNet::REG); { pform_makewire(@1, $1, NetNet::REG);
$$ = $1; $$ = $1;
} }
| IDENTIFIER '=' expression | IDENTIFIER '=' expression
{ pform_makewire(@1, *$1, NetNet::REG); { pform_makewire(@1, $1, NetNet::REG);
yyerror(@2, "net declaration assignment to reg/integer not allowed."); yyerror(@2, "net declaration assignment to reg/integer not allowed.");
delete $3; delete $3;
$$ = $1; $$ = $1;
} }
| IDENTIFIER '[' expression ':' expression ']' | IDENTIFIER '[' expression ':' expression ']'
{ pform_makewire(@1, *$1, NetNet::REG); { pform_makewire(@1, $1, NetNet::REG);
if (! pform_expression_is_constant($3)) if (! pform_expression_is_constant($3))
yyerror(@3, "msb of register range must be constant."); yyerror(@3, "msb of register range must be constant.");
if (! pform_expression_is_constant($5)) if (! pform_expression_is_constant($5))
yyerror(@3, "lsb of register range must be constant."); yyerror(@3, "lsb of register range must be constant.");
pform_set_reg_idx(*$1, $3, $5); pform_set_reg_idx($1, $3, $5);
$$ = $1; $$ = $1;
} }
; ;
@ -1222,13 +1222,13 @@ register_variable
register_variable_list register_variable_list
: register_variable : register_variable
{ list<string>*tmp = new list<string>; { list<string>*tmp = new list<string>;
tmp->push_back(*$1); tmp->push_back($1);
delete $1; delete $1;
$$ = tmp; $$ = tmp;
} }
| register_variable_list ',' register_variable | register_variable_list ',' register_variable
{ list<string>*tmp = $1; { list<string>*tmp = $1;
tmp->push_back(*$3); tmp->push_back($3);
delete $3; delete $3;
$$ = tmp; $$ = tmp;
} }
@ -1280,11 +1280,11 @@ statement
$$ = tmp; $$ = tmp;
} }
| K_begin ':' IDENTIFIER | K_begin ':' IDENTIFIER
{ pform_push_scope(*$3); } { pform_push_scope($3); }
block_item_decls_opt block_item_decls_opt
statement_list K_end statement_list K_end
{ pform_pop_scope(); { pform_pop_scope();
PBlock*tmp = new PBlock(*$3, PBlock::BL_SEQ, *$6); PBlock*tmp = new PBlock($3, PBlock::BL_SEQ, *$6);
tmp->set_file(@1.text); tmp->set_file(@1.text);
tmp->set_lineno(@1.first_line); tmp->set_lineno(@1.first_line);
delete $3; delete $3;
@ -1465,7 +1465,7 @@ statement
$$ = tmp; $$ = tmp;
} }
| SYSTEM_IDENTIFIER '(' expression_list ')' ';' | SYSTEM_IDENTIFIER '(' expression_list ')' ';'
{ PCallTask*tmp = new PCallTask(*$1, *$3); { PCallTask*tmp = new PCallTask($1, *$3);
tmp->set_file(@1.text); tmp->set_file(@1.text);
tmp->set_lineno(@1.first_line); tmp->set_lineno(@1.first_line);
delete $1; delete $1;
@ -1474,7 +1474,7 @@ statement
} }
| SYSTEM_IDENTIFIER '(' ')' ';' | SYSTEM_IDENTIFIER '(' ')' ';'
{ svector<PExpr*>pt (0); { svector<PExpr*>pt (0);
PCallTask*tmp = new PCallTask(*$1, pt); PCallTask*tmp = new PCallTask($1, pt);
tmp->set_file(@1.text); tmp->set_file(@1.text);
tmp->set_lineno(@1.first_line); tmp->set_lineno(@1.first_line);
delete $1; delete $1;
@ -1482,14 +1482,14 @@ statement
} }
| SYSTEM_IDENTIFIER ';' | SYSTEM_IDENTIFIER ';'
{ svector<PExpr*>pt (0); { svector<PExpr*>pt (0);
PCallTask*tmp = new PCallTask(*$1, pt); PCallTask*tmp = new PCallTask($1, pt);
tmp->set_file(@1.text); tmp->set_file(@1.text);
tmp->set_lineno(@1.first_line); tmp->set_lineno(@1.first_line);
delete $1; delete $1;
$$ = tmp; $$ = tmp;
} }
| identifier '(' expression_list ')' ';' | identifier '(' expression_list ')' ';'
{ PCallTask*tmp = new PCallTask(*$1, *$3); { PCallTask*tmp = new PCallTask($1, *$3);
tmp->set_file(@1.text); tmp->set_file(@1.text);
tmp->set_lineno(@1.first_line); tmp->set_lineno(@1.first_line);
delete $1; delete $1;
@ -1498,7 +1498,7 @@ statement
} }
| identifier '(' ')' ';' | identifier '(' ')' ';'
{ svector<PExpr*>pt (0); { svector<PExpr*>pt (0);
PCallTask*tmp = new PCallTask(*$1, pt); PCallTask*tmp = new PCallTask($1, pt);
tmp->set_file(@1.text); tmp->set_file(@1.text);
tmp->set_lineno(@1.first_line); tmp->set_lineno(@1.first_line);
delete $1; delete $1;
@ -1506,7 +1506,7 @@ statement
} }
| identifier ';' | identifier ';'
{ svector<PExpr*>pt (0); { svector<PExpr*>pt (0);
PCallTask*tmp = new PCallTask(*$1, pt); PCallTask*tmp = new PCallTask($1, pt);
tmp->set_file(@1.text); tmp->set_file(@1.text);
tmp->set_lineno(@1.first_line); tmp->set_lineno(@1.first_line);
delete $1; delete $1;
@ -1580,9 +1580,13 @@ udp_entry_list
udp_comb_entry udp_comb_entry
: udp_input_list ':' udp_output_sym ';' : udp_input_list ':' udp_output_sym ';'
{ string*tmp = $1; { char*tmp = new char[strlen($1)+3];
*tmp += ':'; strcpy(tmp, $1);
*tmp += $3; char*tp = tmp+strlen(tmp);
*tp++ = ':';
*tp++ = $3;
*tp++ = 0;
delete[]$1;
$$ = tmp; $$ = tmp;
} }
; ;
@ -1590,13 +1594,13 @@ udp_comb_entry
udp_comb_entry_list udp_comb_entry_list
: udp_comb_entry : udp_comb_entry
{ list<string>*tmp = new list<string>; { list<string>*tmp = new list<string>;
tmp->push_back(*$1); tmp->push_back($1);
delete $1; delete $1;
$$ = tmp; $$ = tmp;
} }
| udp_comb_entry_list udp_comb_entry | udp_comb_entry_list udp_comb_entry
{ list<string>*tmp = $1; { list<string>*tmp = $1;
tmp->push_back(*$2); tmp->push_back($2);
delete $2; delete $2;
$$ = tmp; $$ = tmp;
} }
@ -1605,13 +1609,13 @@ udp_comb_entry_list
udp_sequ_entry_list udp_sequ_entry_list
: udp_sequ_entry : udp_sequ_entry
{ list<string>*tmp = new list<string>; { list<string>*tmp = new list<string>;
tmp->push_back(*$1); tmp->push_back($1);
delete $1; delete $1;
$$ = tmp; $$ = tmp;
} }
| udp_sequ_entry_list udp_sequ_entry | udp_sequ_entry_list udp_sequ_entry
{ list<string>*tmp = $1; { list<string>*tmp = $1;
tmp->push_back(*$2); tmp->push_back($2);
delete $2; delete $2;
$$ = tmp; $$ = tmp;
} }
@ -1619,11 +1623,14 @@ udp_sequ_entry_list
udp_sequ_entry udp_sequ_entry
: udp_input_list ':' udp_input_sym ':' udp_output_sym ';' : udp_input_list ':' udp_input_sym ':' udp_output_sym ';'
{ string*tmp = $1; { char*tmp = new char[strlen($1)+5];
*tmp += ':'; strcpy(tmp, $1);
*tmp += $3; char*tp = tmp+strlen(tmp);
*tmp += ':'; *tp++ = ':';
*tmp += $5; *tp++ = $3;
*tp++ = ':';
*tp++ = $5;
*tp++ = 0;
$$ = tmp; $$ = tmp;
} }
; ;
@ -1631,7 +1638,7 @@ udp_sequ_entry
udp_initial udp_initial
: K_initial IDENTIFIER '=' NUMBER ';' : K_initial IDENTIFIER '=' NUMBER ';'
{ PExpr*etmp = new PENumber($4); { PExpr*etmp = new PENumber($4);
PEIdent*itmp = new PEIdent(*$2); PEIdent*itmp = new PEIdent($2);
PAssign*atmp = new PAssign(itmp, etmp); PAssign*atmp = new PAssign(itmp, etmp);
atmp->set_file(@2.text); atmp->set_file(@2.text);
atmp->set_lineno(@2.first_line); atmp->set_lineno(@2.first_line);
@ -1647,13 +1654,18 @@ udp_init_opt
udp_input_list udp_input_list
: udp_input_sym : udp_input_sym
{ string*tmp = new string; { char*tmp = new char[2];
*tmp += $1; tmp[0] = $1;
tmp[1] = 0;
$$ = tmp; $$ = tmp;
} }
| udp_input_list udp_input_sym | udp_input_list udp_input_sym
{ string*tmp = $1; { char*tmp = new char[strlen($1)+2];
*tmp += $2; strcpy(tmp, $1);
char*tp = tmp+strlen(tmp);
*tp++ = $2;
*tp++ = 0;
delete[]$1;
$$ = tmp; $$ = tmp;
} }
; ;
@ -1683,14 +1695,14 @@ udp_port_decl
: K_input list_of_variables ';' : K_input list_of_variables ';'
{ $$ = pform_make_udp_input_ports($2); } { $$ = pform_make_udp_input_ports($2); }
| K_output IDENTIFIER ';' | K_output IDENTIFIER ';'
{ PWire*pp = new PWire(*$2, NetNet::IMPLICIT, NetNet::POUTPUT); { PWire*pp = new PWire($2, NetNet::IMPLICIT, NetNet::POUTPUT);
svector<PWire*>*tmp = new svector<PWire*>(1); svector<PWire*>*tmp = new svector<PWire*>(1);
(*tmp)[0] = pp; (*tmp)[0] = pp;
delete $2; delete $2;
$$ = tmp; $$ = tmp;
} }
| K_reg IDENTIFIER ';' | K_reg IDENTIFIER ';'
{ PWire*pp = new PWire(*$2, NetNet::REG, NetNet::PIMPLICIT); { PWire*pp = new PWire($2, NetNet::REG, NetNet::PIMPLICIT);
svector<PWire*>*tmp = new svector<PWire*>(1); svector<PWire*>*tmp = new svector<PWire*>(1);
(*tmp)[0] = pp; (*tmp)[0] = pp;
delete $2; delete $2;
@ -1712,13 +1724,13 @@ udp_port_decls
udp_port_list udp_port_list
: IDENTIFIER : IDENTIFIER
{ list<string>*tmp = new list<string>; { list<string>*tmp = new list<string>;
tmp->push_back(*$1); tmp->push_back($1);
delete $1; delete $1;
$$ = tmp; $$ = tmp;
} }
| udp_port_list ',' IDENTIFIER | udp_port_list ',' IDENTIFIER
{ list<string>*tmp = $1; { list<string>*tmp = $1;
tmp->push_back(*$3); tmp->push_back($3);
delete $3; delete $3;
$$ = tmp; $$ = tmp;
} }
@ -1730,5 +1742,7 @@ udp_primitive
udp_init_opt udp_init_opt
udp_body udp_body
K_endprimitive K_endprimitive
{ pform_make_udp($2, $4, $7, $9, $8); } { pform_make_udp($2, $4, $7, $9, $8);
delete[]$2;
}
; ;

View File

@ -19,10 +19,9 @@
* 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) #if !defined(WINNT)
#ident "$Id: parse_misc.h,v 1.2 1998/11/07 17:05:05 steve Exp $" #ident "$Id: parse_misc.h,v 1.3 1999/07/10 01:03:18 steve Exp $"
#endif #endif
# include <string>
# include <list> # include <list>
# include "pform.h" # include "pform.h"
@ -54,6 +53,9 @@ extern unsigned error_count, warn_count;
/* /*
* $Log: parse_misc.h,v $ * $Log: parse_misc.h,v $
* Revision 1.3 1999/07/10 01:03:18 steve
* remove string from lexical phase.
*
* Revision 1.2 1998/11/07 17:05:05 steve * Revision 1.2 1998/11/07 17:05:05 steve
* Handle procedural conditional, and some * Handle procedural conditional, and some
* of the conditional expressions. * of the conditional expressions.

View File

@ -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) #if !defined(WINNT)
#ident "$Id: pform.cc,v 1.31 1999/07/03 02:12:52 steve Exp $" #ident "$Id: pform.cc,v 1.32 1999/07/10 01:03:18 steve Exp $"
#endif #endif
# include "compiler.h" # include "compiler.h"
@ -121,7 +121,7 @@ bool pform_expression_is_constant(const PExpr*ex)
return ex->is_constant(pform_cur_module); return ex->is_constant(pform_cur_module);
} }
void pform_make_udp(string*name, list<string>*parms, void pform_make_udp(const char*name, list<string>*parms,
svector<PWire*>*decl, list<string>*table, svector<PWire*>*decl, list<string>*table,
Statement*init_expr) Statement*init_expr)
{ {
@ -232,11 +232,11 @@ void pform_make_udp(string*name, list<string>*parms,
} }
// Put the primitive into the primitives table // Put the primitive into the primitives table
if (vl_primitives[*name]) { if (vl_primitives[name]) {
VLerror("UDP primitive already exists."); VLerror("UDP primitive already exists.");
} else { } else {
PUdp*udp = new PUdp(*name, parms->size()); PUdp*udp = new PUdp(name, parms->size());
// Detect sequential udp. // Detect sequential udp.
if (pins[0]->get_wire_type() == NetNet::REG) if (pins[0]->get_wire_type() == NetNet::REG)
@ -251,11 +251,10 @@ void pform_make_udp(string*name, list<string>*parms,
udp->toutput = output; udp->toutput = output;
udp->initial = init; udp->initial = init;
vl_primitives[*name] = udp; vl_primitives[name] = udp;
} }
/* Delete the excess tables and lists from the parser. */ /* Delete the excess tables and lists from the parser. */
delete name;
delete parms; delete parms;
delete decl; delete decl;
delete table; delete table;
@ -594,6 +593,9 @@ int pform_parse(const char*path, map<string,Module*>&modules,
/* /*
* $Log: pform.cc,v $ * $Log: pform.cc,v $
* Revision 1.32 1999/07/10 01:03:18 steve
* remove string from lexical phase.
*
* Revision 1.31 1999/07/03 02:12:52 steve * Revision 1.31 1999/07/03 02:12:52 steve
* Elaborate user defined tasks. * Elaborate user defined tasks.
* *

View File

@ -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) #if !defined(WINNT)
#ident "$Id: pform.h,v 1.22 1999/07/03 02:12:52 steve Exp $" #ident "$Id: pform.h,v 1.23 1999/07/10 01:03:18 steve Exp $"
#endif #endif
# include "netlist.h" # include "netlist.h"
@ -98,7 +98,7 @@ struct lgate {
extern void pform_startmodule(const string&, svector<PWire*>*ports); extern void pform_startmodule(const string&, svector<PWire*>*ports);
extern void pform_endmodule(const string&); extern void pform_endmodule(const string&);
extern void pform_make_udp(string*name, list<string>*parms, extern void pform_make_udp(const char*name, list<string>*parms,
svector<PWire*>*decl, list<string>*table, svector<PWire*>*decl, list<string>*table,
Statement*init); Statement*init);
@ -157,6 +157,9 @@ extern void pform_dump(ostream&out, Module*mod);
/* /*
* $Log: pform.h,v $ * $Log: pform.h,v $
* Revision 1.23 1999/07/10 01:03:18 steve
* remove string from lexical phase.
*
* Revision 1.22 1999/07/03 02:12:52 steve * Revision 1.22 1999/07/03 02:12:52 steve
* Elaborate user defined tasks. * Elaborate user defined tasks.
* *