From 6625ea71c29ec84aeddb4a5cdc64f5ed5f27ebae Mon Sep 17 00:00:00 2001 From: steve Date: Sat, 8 May 1999 20:19:20 +0000 Subject: [PATCH] Parse more things. --- lexor.lex | 7 ++++++- parse.y | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- pform.cc | 7 +++++-- 3 files changed, 68 insertions(+), 5 deletions(-) diff --git a/lexor.lex b/lexor.lex index 768220233..c7e6c5beb 100644 --- a/lexor.lex +++ b/lexor.lex @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: lexor.lex,v 1.12 1999/05/06 04:09:28 steve Exp $" +#ident "$Id: lexor.lex,v 1.13 1999/05/08 20:19:20 steve Exp $" #endif //# define YYSTYPE lexval @@ -125,6 +125,10 @@ static verinum*make_unsized_hex(const char*txt); yylval.text = new string(yytext); return SYSTEM_IDENTIFIER; } +\.[a-zA-Z_][a-zA-Z0-9$_]* { + yylval.text = new string(yytext+1); + return PORTNAME; } + [0-9][0-9_]*\'d[0-9][0-9_]* { yylval.number = make_sized_dec(yytext); return NUMBER; } [0-9][0-9_]*\'[bB][0-1xz_]+ { yylval.number = make_sized_binary(yytext); @@ -222,6 +226,7 @@ static const struct { const char*name; int code; } key_table[] = { { "endprimitive", K_endprimitive }, { "endspecify", K_endspecify }, { "endtable", K_endtable }, + { "endtask", K_endtask }, { "event", K_event }, { "for", K_for }, { "force", K_force }, diff --git a/parse.y b/parse.y index 49b5b7fa3..88d22333f 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) -#ident "$Id: parse.y,v 1.23 1999/05/07 04:26:49 steve Exp $" +#ident "$Id: parse.y,v 1.24 1999/05/08 20:19:20 steve Exp $" #endif # include "parse_misc.h" @@ -59,7 +59,7 @@ extern void lex_end_table(); verinum* number; }; -%token IDENTIFIER SYSTEM_IDENTIFIER STRING +%token IDENTIFIER PORTNAME SYSTEM_IDENTIFIER STRING %token NUMBER %token K_LE K_GE K_EQ K_NE K_CEQ K_CNE %token K_LOR K_LAND @@ -225,6 +225,13 @@ delay $$ = tmp; delete $2; } + | '#' '(' IDENTIFIER ')' + { PEIdent*tmp = new PEIdent(*$3); + tmp->set_file(@1.text); + tmp->set_lineno(@1.first_line); + $$ = tmp; + delete $3; + } ; delay_opt @@ -327,6 +334,12 @@ expression | expression '|' expression { $$ = new PEBinary('|', $1, $3); } + | expression '<' expression + { $$ = new PEBinary('<', $1, $3); + } + | expression '>' expression + { $$ = new PEBinary('>', $1, $3); + } | expression K_EQ expression { $$ = new PEBinary('e', $1, $3); } @@ -410,6 +423,8 @@ expr_primary } ; + /* A gate_instance is a module instantiation or a built in part + type. In any case, the gate has a set of connections to ports. */ gate_instance : IDENTIFIER '(' expression_list ')' { lgate*tmp = new lgate; @@ -443,6 +458,16 @@ gate_instance tmp->lineno = @1.first_line; $$ = tmp; } + | IDENTIFIER '(' port_name_list ')' + { lgate*tmp = new lgate; + tmp->name = *$1; + tmp->parms = 0; + tmp->file = @1.text; + tmp->lineno = @1.first_line; + delete $1; + yyerror(@1, "Sorry, named port connections not supported."); + $$ = tmp; + } ; gate_instance_list @@ -641,6 +666,9 @@ module_item tmp->set_file(@1.text); tmp->set_lineno(@1.first_line); } + | K_task IDENTIFIER ';' statement K_endtask + { yyerror(@1, "Sorry, task declarations not supported."); + } | KK_attribute '(' IDENTIFIER ',' STRING ',' STRING ')' ';' { pform_set_attrib(*$3, *$5, *$7); delete $3; @@ -702,6 +730,21 @@ port } ; +port_name + : PORTNAME '(' IDENTIFIER ')' + { delete $1; + delete $3; + } + | PORTNAME '(' ')' + { delete $1; + } + ; + +port_name_list + : port_name_list ',' port_name + | port_name + ; + port_type : K_input { $$ = NetNet::PINPUT; } | K_output { $$ = NetNet::POUTPUT; } @@ -839,6 +882,10 @@ statement { $$ = pform_make_assignment($1, $3); yyerror(@1, "Sorry, non-blocking assignment not implemented."); } + | lpvalue '=' delay expression ';' + { $$ = pform_make_assignment($1, $3); + yyerror(@1, "Sorry, assignment timing control not implemented."); + } | K_wait '(' expression ')' statement_opt { PEventStatement*tmp; PEEvent*etmp = new PEEvent(NetNEvent::POSITIVE, $3); @@ -852,6 +899,14 @@ statement | SYSTEM_IDENTIFIER ';' { $$ = pform_make_calltask($1); } + | IDENTIFIER '(' expression_list ')' ';' + { yyerror(@1, "Sorry, task enabling not implemented."); + $$ = new PNoop; + } + | IDENTIFIER ';' + { yyerror(@1, "Sorry, task enabling not implemented."); + $$ = new PNoop; + } | error ';' { yyerror(@1, "malformed statement"); $$ = new PNoop; diff --git a/pform.cc b/pform.cc index dd1a9ec92..da2235679 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) -#ident "$Id: pform.cc,v 1.15 1999/05/07 04:26:49 steve Exp $" +#ident "$Id: pform.cc,v 1.16 1999/05/08 20:19:20 steve Exp $" #endif # include "pform.h" @@ -289,7 +289,7 @@ void pform_make_modgates(const string&type, svector*gates) for (unsigned idx = 0 ; idx < gates->count() ; idx += 1) { lgate cur = (*gates)[idx]; - vectorwires (cur.parms->size()); + vectorwires (cur.parms? cur.parms->size() : 0); for (unsigned idx = 0 ; idx < wires.size() ; idx += 1) { PExpr*ep = cur.parms->front(); cur.parms->pop_front(); @@ -533,6 +533,9 @@ int pform_parse(const char*path, map&modules, /* * $Log: pform.cc,v $ + * Revision 1.16 1999/05/08 20:19:20 steve + * Parse more things. + * * Revision 1.15 1999/05/07 04:26:49 steve * Parse more complex continuous assign lvalues. *