Handle comments

Ignore C/C++ style comments, and also handle a few error
cases a slight bit more elegently.

Signed-off-by: Stephen Williams <steve@icarus.com>
This commit is contained in:
Stephen Williams 2007-11-26 17:59:53 -08:00
parent 79232f46d8
commit ca10a6867a
2 changed files with 16 additions and 1 deletions

View File

@ -41,8 +41,19 @@ static int yywrap(void)
# define yylval sdflval
%}
%x CCOMMENT
%%
/* Skip C++-style comments. */
"//".* { sdflloc.first_line += 1; }
/* Skip C-style comments. */
"/*" { BEGIN(CCOMMENT); }
<CCOMMENT>. { yymore(); }
<CCOMMENT>\n { sdflloc.first_line += 1; yymore(); }
<CCOMMENT>"*/" { BEGIN(0); }
[ \m\t] { /* Skip white space. */; }
/* Count lines so that the parser can assign line numbers. */

View File

@ -62,6 +62,10 @@ static char use_hchar = '.';
source_file
: '(' K_DELAYFILE sdf_header_list cell_list ')'
| '(' K_DELAYFILE error ')'
{ vpi_printf("%s:%d:SDF ERROR: Invalid DELAYFILE format\n",
sdf_parse_path, @2.first_line);
}
;
sdf_header_list
@ -304,5 +308,5 @@ signed_real_number
void yyerror(const char*msg)
{
fprintf(stderr, "SDF ERROR: %s\n", msg);
vpi_printf("%s:SDF ERROR: Too many errors: %s\n", sdf_parse_path, msg);
}