Merge pull request #826 from steveicarus/parser-cleanup

Parser cleanup
This commit is contained in:
Stephen Williams 2022-12-24 17:31:17 -08:00 committed by GitHub
commit 507d8cc8ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 1552 additions and 1544 deletions

View File

@ -1,2 +1,2 @@
./ivltests/br1027a.v:1: error: missing task/function port direction.
./ivltests/br1027a.v:1: error: missing task/function port direction.
./ivltests/br1027a.v:1: error: Missing task/function port direction.
./ivltests/br1027a.v:1: error: Missing task/function port direction.

View File

@ -1 +1 @@
./ivltests/br1027c.v:1: error: missing task/function port direction.
./ivltests/br1027c.v:1: error: Missing task/function port direction.

View File

@ -1 +1 @@
./ivltests/br1027e.v:1: error: missing task/function port direction.
./ivltests/br1027e.v:1: error: Missing task/function port direction.

View File

@ -1,16 +1,16 @@
./ivltests/br_gh79.v:6: syntax error
./ivltests/br_gh79.v:6: error: malformed statement
./ivltests/br_gh79.v:6: error: Malformed statement
./ivltests/br_gh79.v:7: syntax error
./ivltests/br_gh79.v:7: error: malformed statement
./ivltests/br_gh79.v:7: error: Malformed statement
./ivltests/br_gh79.v:9: syntax error
./ivltests/br_gh79.v:9: error: malformed statement
./ivltests/br_gh79.v:9: error: Malformed statement
./ivltests/br_gh79.v:10: syntax error
./ivltests/br_gh79.v:10: error: malformed statement
./ivltests/br_gh79.v:10: error: Malformed statement
./ivltests/br_gh79.v:12: syntax error
./ivltests/br_gh79.v:12: error: malformed statement
./ivltests/br_gh79.v:12: error: Malformed statement
./ivltests/br_gh79.v:13: syntax error
./ivltests/br_gh79.v:13: error: malformed statement
./ivltests/br_gh79.v:13: error: Malformed statement
./ivltests/br_gh79.v:15: syntax error
./ivltests/br_gh79.v:15: error: malformed statement
./ivltests/br_gh79.v:15: error: Malformed statement
./ivltests/br_gh79.v:16: syntax error
./ivltests/br_gh79.v:16: error: malformed statement
./ivltests/br_gh79.v:16: error: Malformed statement

View File

@ -1,2 +1,2 @@
./ivltests/pr1792152.v:2: warning: choosing typ expression.
./ivltests/pr1792152.v:2: warning: Choosing typ expression.
2

View File

@ -1,22 +1,22 @@
./ivltests/pr3366217d.v:3: error: undefined value used in enum name sequence.
./ivltests/pr3366217d.v:4: error: undefined value used in enum name sequence.
./ivltests/pr3366217d.v:5: error: undefined value used in enum name sequence.
./ivltests/pr3366217d.v:6: error: undefined value used in enum name sequence.
./ivltests/pr3366217d.v:6: error: undefined value used in enum name sequence.
./ivltests/pr3366217d.v:7: error: undefined value used in enum name sequence.
./ivltests/pr3366217d.v:8: error: undefined value used in enum name sequence.
./ivltests/pr3366217d.v:9: error: undefined value used in enum name sequence.
./ivltests/pr3366217d.v:10: error: undefined value used in enum name sequence.
./ivltests/pr3366217d.v:10: error: undefined value used in enum name sequence.
./ivltests/pr3366217d.v:13: error: zero count used in enum name sequence.
./ivltests/pr3366217d.v:14: error: zero count used in enum name sequence.
./ivltests/pr3366217d.v:17: error: negative value used in enum name sequence.
./ivltests/pr3366217d.v:18: error: negative value used in enum name sequence.
./ivltests/pr3366217d.v:19: error: negative value used in enum name sequence.
./ivltests/pr3366217d.v:20: error: negative value used in enum name sequence.
./ivltests/pr3366217d.v:20: error: negative value used in enum name sequence.
./ivltests/pr3366217d.v:21: error: negative value used in enum name sequence.
./ivltests/pr3366217d.v:22: error: negative value used in enum name sequence.
./ivltests/pr3366217d.v:23: error: negative value used in enum name sequence.
./ivltests/pr3366217d.v:24: error: negative value used in enum name sequence.
./ivltests/pr3366217d.v:24: error: negative value used in enum name sequence.
./ivltests/pr3366217d.v:3: error: Undefined value used in enum name sequence.
./ivltests/pr3366217d.v:4: error: Undefined value used in enum name sequence.
./ivltests/pr3366217d.v:5: error: Undefined value used in enum name sequence.
./ivltests/pr3366217d.v:6: error: Undefined value used in enum name sequence.
./ivltests/pr3366217d.v:6: error: Undefined value used in enum name sequence.
./ivltests/pr3366217d.v:7: error: Undefined value used in enum name sequence.
./ivltests/pr3366217d.v:8: error: Undefined value used in enum name sequence.
./ivltests/pr3366217d.v:9: error: Undefined value used in enum name sequence.
./ivltests/pr3366217d.v:10: error: Undefined value used in enum name sequence.
./ivltests/pr3366217d.v:10: error: Undefined value used in enum name sequence.
./ivltests/pr3366217d.v:13: error: Zero count used in enum name sequence.
./ivltests/pr3366217d.v:14: error: Zero count used in enum name sequence.
./ivltests/pr3366217d.v:17: error: Negative value used in enum name sequence.
./ivltests/pr3366217d.v:18: error: Negative value used in enum name sequence.
./ivltests/pr3366217d.v:19: error: Negative value used in enum name sequence.
./ivltests/pr3366217d.v:20: error: Negative value used in enum name sequence.
./ivltests/pr3366217d.v:20: error: Negative value used in enum name sequence.
./ivltests/pr3366217d.v:21: error: Negative value used in enum name sequence.
./ivltests/pr3366217d.v:22: error: Negative value used in enum name sequence.
./ivltests/pr3366217d.v:23: error: Negative value used in enum name sequence.
./ivltests/pr3366217d.v:24: error: Negative value used in enum name sequence.
./ivltests/pr3366217d.v:24: error: Negative value used in enum name sequence.

View File

@ -1,8 +1,8 @@
./ivltests/struct_invalid_member.v:9: syntax error
./ivltests/struct_invalid_member.v:9: Error in struct/union member.
./ivltests/struct_invalid_member.v:9: error: Error in struct/union member.
./ivltests/struct_invalid_member.v:10: syntax error
./ivltests/struct_invalid_member.v:10: Error in struct/union member.
./ivltests/struct_invalid_member.v:10: error: Error in struct/union member.
./ivltests/struct_invalid_member.v:11: syntax error
./ivltests/struct_invalid_member.v:11: Error in struct/union member.
./ivltests/struct_invalid_member.v:11: error: Error in struct/union member.
./ivltests/struct_invalid_member.v:12: syntax error
./ivltests/struct_invalid_member.v:12: Error in struct/union member.
./ivltests/struct_invalid_member.v:12: error: Error in struct/union member.

View File

@ -1,3 +1,3 @@
./ivltests/sv_end_labels_unnamed.v:7: error: unnamed block must not have end label.
./ivltests/sv_end_labels_unnamed.v:11: error: unnamed block must not have end label.
./ivltests/sv_end_labels_unnamed.v:14: error: unnamed fork must not have end label.
./ivltests/sv_end_labels_unnamed.v:7: error: Unnamed block must not have end label.
./ivltests/sv_end_labels_unnamed.v:11: error: Unnamed block must not have end label.
./ivltests/sv_end_labels_unnamed.v:14: error: Unnamed fork must not have end label.

View File

@ -1,20 +1,20 @@
./ivltests/sv_timeunit_prec_fail1a.v:9: error: repeat timeunit does not match the initial timeunit for this scope.
./ivltests/sv_timeunit_prec_fail1a.v:10: error: repeat timeprecision does not match the initial timeprecision for this scope.
./ivltests/sv_timeunit_prec_fail1a.v:15: error: repeat timeunit does not match the initial timeunit for this scope.
./ivltests/sv_timeunit_prec_fail1a.v:21: error: repeat timeprecision does not match the initial timeprecision for this scope.
./ivltests/sv_timeunit_prec_fail1a.v:27: error: repeat timeunit found and the initial timeunit for this scope is missing.
./ivltests/sv_timeunit_prec_fail1a.v:33: error: repeat timeprecision found and the initial timeprecision for this scope is missing.
./ivltests/sv_timeunit_prec_fail1a.v:40: error: repeat timeprecision found and the initial timeprecision for this scope is missing.
./ivltests/sv_timeunit_prec_fail1a.v:47: error: repeat timeunit found and the initial timeunit for this scope is missing.
./ivltests/sv_timeunit_prec_fail1a.v:53: Invalid timeunit constant (1st digit).
./ivltests/sv_timeunit_prec_fail1a.v:54: Invalid timeprecision constant (1st digit).
./ivltests/sv_timeunit_prec_fail1a.v:56: Invalid timeunit constant (number of zeros).
./ivltests/sv_timeunit_prec_fail1a.v:57: Invalid timeprecision constant (number of zeros).
./ivltests/sv_timeunit_prec_fail1a.v:59: Invalid timeunit scale '2s'.
./ivltests/sv_timeunit_prec_fail1a.v:60: Invalid timeprecision scale '2s'.
./ivltests/sv_timeunit_prec_fail1a.v:63: Invalid timeunit constant ('_' is not supported).
./ivltests/sv_timeunit_prec_fail1a.v:64: Invalid timeprecision constant ('_' is not supported).
./ivltests/sv_timeunit_prec_fail1b.v:4: error: a timeprecision is missing or is too large!
./ivltests/sv_timeunit_prec_fail1c.v:4: error: a timeprecision is missing or is too large!
./ivltests/sv_timeunit_prec_fail1d.v:5: error: a timeprecision is missing or is too large!
./ivltests/sv_timeunit_prec_fail1e.v:5: error: a timeprecision is missing or is too large!
./ivltests/sv_timeunit_prec_fail1a.v:9: error: Repeat timeunit does not match the initial timeunit for this scope.
./ivltests/sv_timeunit_prec_fail1a.v:10: error: Repeat timeprecision does not match the initial timeprecision for this scope.
./ivltests/sv_timeunit_prec_fail1a.v:15: error: Repeat timeunit does not match the initial timeunit for this scope.
./ivltests/sv_timeunit_prec_fail1a.v:21: error: Repeat timeprecision does not match the initial timeprecision for this scope.
./ivltests/sv_timeunit_prec_fail1a.v:27: error: Repeat timeunit found and the initial timeunit for this scope is missing.
./ivltests/sv_timeunit_prec_fail1a.v:33: error: Repeat timeprecision found and the initial timeprecision for this scope is missing.
./ivltests/sv_timeunit_prec_fail1a.v:40: error: Repeat timeprecision found and the initial timeprecision for this scope is missing.
./ivltests/sv_timeunit_prec_fail1a.v:47: error: Repeat timeunit found and the initial timeunit for this scope is missing.
./ivltests/sv_timeunit_prec_fail1a.v:53: error: Invalid timeunit constant (1st digit).
./ivltests/sv_timeunit_prec_fail1a.v:54: error: Invalid timeprecision constant (1st digit).
./ivltests/sv_timeunit_prec_fail1a.v:56: error: Invalid timeunit constant (number of zeros).
./ivltests/sv_timeunit_prec_fail1a.v:57: error: Invalid timeprecision constant (number of zeros).
./ivltests/sv_timeunit_prec_fail1a.v:59: error: Invalid timeunit scale '2s'.
./ivltests/sv_timeunit_prec_fail1a.v:60: error: Invalid timeprecision scale '2s'.
./ivltests/sv_timeunit_prec_fail1a.v:63: error: Invalid timeunit constant ('_' is not supported).
./ivltests/sv_timeunit_prec_fail1a.v:64: error: Invalid timeprecision constant ('_' is not supported).
./ivltests/sv_timeunit_prec_fail1b.v:4: error: A timeprecision is missing or is too large!
./ivltests/sv_timeunit_prec_fail1c.v:4: error: A timeprecision is missing or is too large!
./ivltests/sv_timeunit_prec_fail1d.v:5: error: A timeprecision is missing or is too large!
./ivltests/sv_timeunit_prec_fail1e.v:5: error: A timeprecision is missing or is too large!

View File

@ -1,20 +1,20 @@
./ivltests/sv_timeunit_prec_fail2a.v:8: error: repeat timeunit does not match the initial timeunit for this scope.
./ivltests/sv_timeunit_prec_fail2a.v:8: error: repeat timeprecision does not match the initial timeprecision for this scope.
./ivltests/sv_timeunit_prec_fail2a.v:13: error: repeat timeunit does not match the initial timeunit for this scope.
./ivltests/sv_timeunit_prec_fail2a.v:13: error: repeat timeprecision does not match the initial timeprecision for this scope.
./ivltests/sv_timeunit_prec_fail2a.v:14: error: repeat timeunit does not match the initial timeunit for this scope.
./ivltests/sv_timeunit_prec_fail2a.v:15: error: repeat timeprecision does not match the initial timeprecision for this scope.
./ivltests/sv_timeunit_prec_fail2a.v:21: error: repeat timeunit found and the initial timeunit for this scope is missing.
./ivltests/sv_timeunit_prec_fail2a.v:21: error: repeat timeprecision found and the initial timeprecision for this scope is missing.
./ivltests/sv_timeunit_prec_fail2a.v:27: error: repeat timeprecision found and the initial timeprecision for this scope is missing.
./ivltests/sv_timeunit_prec_fail2a.v:33: error: repeat timeunit found and the initial timeunit for this scope is missing.
./ivltests/sv_timeunit_prec_fail2a.v:39: Invalid timeunit constant (1st digit).
./ivltests/sv_timeunit_prec_fail2a.v:39: Invalid timeprecision constant (1st digit).
./ivltests/sv_timeunit_prec_fail2a.v:41: Invalid timeunit constant (number of zeros).
./ivltests/sv_timeunit_prec_fail2a.v:41: Invalid timeprecision constant (number of zeros).
./ivltests/sv_timeunit_prec_fail2a.v:43: Invalid timeunit scale '2s'.
./ivltests/sv_timeunit_prec_fail2a.v:43: Invalid timeprecision scale '2s'.
./ivltests/sv_timeunit_prec_fail2a.v:46: Invalid timeunit constant ('_' is not supported).
./ivltests/sv_timeunit_prec_fail2a.v:46: Invalid timeprecision constant ('_' is not supported).
./ivltests/sv_timeunit_prec_fail2b.v:4: error: a timeprecision is missing or is too large!
./ivltests/sv_timeunit_prec_fail2c.v:5: error: a timeprecision is missing or is too large!
./ivltests/sv_timeunit_prec_fail2a.v:8: error: Repeat timeunit does not match the initial timeunit for this scope.
./ivltests/sv_timeunit_prec_fail2a.v:8: error: Repeat timeprecision does not match the initial timeprecision for this scope.
./ivltests/sv_timeunit_prec_fail2a.v:13: error: Repeat timeunit does not match the initial timeunit for this scope.
./ivltests/sv_timeunit_prec_fail2a.v:13: error: Repeat timeprecision does not match the initial timeprecision for this scope.
./ivltests/sv_timeunit_prec_fail2a.v:14: error: Repeat timeunit does not match the initial timeunit for this scope.
./ivltests/sv_timeunit_prec_fail2a.v:15: error: Repeat timeprecision does not match the initial timeprecision for this scope.
./ivltests/sv_timeunit_prec_fail2a.v:21: error: Repeat timeunit found and the initial timeunit for this scope is missing.
./ivltests/sv_timeunit_prec_fail2a.v:21: error: Repeat timeprecision found and the initial timeprecision for this scope is missing.
./ivltests/sv_timeunit_prec_fail2a.v:27: error: Repeat timeprecision found and the initial timeprecision for this scope is missing.
./ivltests/sv_timeunit_prec_fail2a.v:33: error: Repeat timeunit found and the initial timeunit for this scope is missing.
./ivltests/sv_timeunit_prec_fail2a.v:39: error: Invalid timeunit constant (1st digit).
./ivltests/sv_timeunit_prec_fail2a.v:39: error: Invalid timeprecision constant (1st digit).
./ivltests/sv_timeunit_prec_fail2a.v:41: error: Invalid timeunit constant (number of zeros).
./ivltests/sv_timeunit_prec_fail2a.v:41: error: Invalid timeprecision constant (number of zeros).
./ivltests/sv_timeunit_prec_fail2a.v:43: error: Invalid timeunit scale '2s'.
./ivltests/sv_timeunit_prec_fail2a.v:43: error: Invalid timeprecision scale '2s'.
./ivltests/sv_timeunit_prec_fail2a.v:46: error: Invalid timeunit constant ('_' is not supported).
./ivltests/sv_timeunit_prec_fail2a.v:46: error: Invalid timeprecision constant ('_' is not supported).
./ivltests/sv_timeunit_prec_fail2b.v:4: error: A timeprecision is missing or is too large!
./ivltests/sv_timeunit_prec_fail2c.v:5: error: A timeprecision is missing or is too large!

128
lexor.lex
View File

@ -509,9 +509,8 @@ TU [munpf]
}
\'[01xzXZ] {
if (!gn_system_verilog()) {
cerr << yylloc.text << ":" << yylloc.first_line << ": warning: "
<< "Using SystemVerilog 'N bit vector. Use at least "
<< "-g2005-sv to remove this warning." << endl;
VLwarn(yylloc, "warning: Using SystemVerilog 'N bit vector. "
"Use at least -g2005-sv to remove this warning.");
}
generation_t generation_save = generation_flag;
generation_flag = GN_VER2005_SV;
@ -827,10 +826,8 @@ TU [munpf]
net_type = NetNet::NONE;
} else {
cerr << yylloc.text << ":" << yylloc.first_line
<< ": error: Net type " << yytext
<< " is not a valid (or supported)"
<< " default net type." << endl;
VLerror(yylloc, "error: Net type '%s' is not a valid (or supported) "
"default net type.", yytext);
net_type = NetNet::WIRE;
error_count += 1;
}
@ -853,80 +850,58 @@ TU [munpf]
been handled by an external preprocessor such as ivlpp. */
^{W}?`define{W}?.* {
cerr << yylloc.text << ":" << yylloc.first_line <<
": warning: `define not supported. Use an external preprocessor."
<< endl;
VLwarn(yylloc, "warning: `define not supported. Use an external preprocessor.");
}
^{W}?`else{W}?.* {
cerr << yylloc.text << ":" << yylloc.first_line <<
": warning: `else not supported. Use an external preprocessor."
<< endl;
VLwarn(yylloc, "warning: `else not supported. Use an external preprocessor.");
}
^{W}?`elsif{W}?.* {
cerr << yylloc.text << ":" << yylloc.first_line <<
": warning: `elsif not supported. Use an external preprocessor."
<< endl;
VLwarn(yylloc, "warning: `elsif not supported. Use an external preprocessor.");
}
^{W}?`endif{W}?.* {
cerr << yylloc.text << ":" << yylloc.first_line <<
": warning: `endif not supported. Use an external preprocessor."
<< endl;
VLwarn(yylloc, "warning: `endif not supported. Use an external preprocessor.");
}
^{W}?`ifdef{W}?.* {
cerr << yylloc.text << ":" << yylloc.first_line <<
": warning: `ifdef not supported. Use an external preprocessor."
<< endl;
VLwarn(yylloc, "warning: `ifdef not supported. Use an external preprocessor.");
}
^{W}?`ifndef{W}?.* {
cerr << yylloc.text << ":" << yylloc.first_line <<
": warning: `ifndef not supported. Use an external preprocessor."
<< endl;
VLwarn(yylloc, "warning: `ifndef not supported. Use an external preprocessor.");
}
^`include{W}?.* {
cerr << yylloc.text << ":" << yylloc.first_line <<
": warning: `include not supported. Use an external preprocessor."
<< endl;
VLwarn(yylloc, "warning: `include not supported. Use an external preprocessor.");
}
^`undef{W}?.* {
cerr << yylloc.text << ":" << yylloc.first_line <<
": warning: `undef not supported. Use an external preprocessor."
<< endl;
VLwarn(yylloc, "warning: `undef not supported. Use an external preprocessor.");
}
`[a-zA-Z_]+ {
yywarn(yylloc, "macro replacement not supported. "
VLwarn(yylloc, "warning: Macro replacement not supported. "
"Use an external preprocessor.");
}
`{W} { cerr << yylloc.text << ":" << yylloc.first_line << ": error: "
<< "Stray tic (`) here. Perhaps you put white space" << endl;
cerr << yylloc.text << ":" << yylloc.first_line << ": : "
<< "between the tic and preprocessor directive?"
<< endl;
error_count += 1; }
`{W} { VLerror(yylloc, "error: Stray tic (`) here. Perhaps you put white "
"space between the tic and preprocessor directive?"); }
. { return yytext[0]; }
/* Final catchall. something got lost or mishandled. */
/* XXX Should we tell the user something about the lexical state? */
<*>.|\n { cerr << yylloc.text << ":" << yylloc.first_line
<< ": error: unmatched character (";
<*>.|\n {
if (isprint(yytext[0]))
cerr << yytext[0];
VLerror(yylloc, "error: Unmatched character (%c).", yytext[0]);
else
cerr << "hex " << hex << ((unsigned char) yytext[0]);
cerr << ")" << endl;
error_count += 1; }
VLerror(yylloc, "error: Unmatched character (0x%x).",
(unsigned char) yytext[0]);
}
%%
@ -949,7 +924,8 @@ static unsigned truncate_to_integer_width(verinum::V*bits, unsigned size)
for (unsigned idx = integer_width; idx < size; idx += 1) {
if (bits[idx] != pad) {
yywarn(yylloc, "Unsized numeric constant truncated to integer width.");
VLwarn(yylloc, "warning: Unsized numeric constant truncated "
"to integer width.");
break;
}
}
@ -985,15 +961,15 @@ verinum*make_unsized_binary(const char*txt)
if (*idx != '_') size += 1;
if (size == 0) {
VLerror(yylloc, "Numeric literal has no digits in it.");
VLerror(yylloc, "error: Numeric literal has no digits in it.");
verinum*out = new verinum();
out->has_sign(sign_flag);
out->is_single(single_flag);
return out;
}
if ((based_size > 0) && (size > based_size)) yywarn(yylloc,
"extra digits given for sized binary constant.");
if ((based_size > 0) && (size > based_size)) VLwarn(yylloc,
"warning: Extra digits given for sized binary constant.");
verinum::V*bits = new verinum::V[size];
@ -1057,8 +1033,8 @@ verinum*make_unsized_octal(const char*txt)
if (based_size > 0) {
int rem = based_size % 3;
if (rem != 0) based_size += 3 - rem;
if (size > based_size) yywarn(yylloc,
"extra digits given for sized octal constant.");
if (size > based_size) VLwarn(yylloc,
"warning: Extra digits given for sized octal constant.");
}
verinum::V*bits = new verinum::V[size];
@ -1126,8 +1102,8 @@ verinum*make_unsized_hex(const char*txt)
if (based_size > 0) {
int rem = based_size % 4;
if (rem != 0) based_size += 4 - rem;
if (size > based_size) yywarn(yylloc,
"extra digits given for sized hex constant.");
if (size > based_size) VLwarn(yylloc,
"warning: Extra digits given for sized hex constant.");
}
verinum::V*bits = new verinum::V[size];
@ -1431,7 +1407,7 @@ static void process_ucdrive(const char*txt)
const char*cp = txt;
if (strncmp("pull", cp, 4) != 0) {
VLerror(yylloc, "pull required for `unconnected_drive "
VLerror(yylloc, "error: pull required for `unconnected_drive "
"directive.");
return;
}
@ -1439,16 +1415,14 @@ static void process_ucdrive(const char*txt)
if (*cp == '0') ucd = UCD_PULL0;
else if (*cp == '1') ucd = UCD_PULL1;
else {
cerr << yylloc.text << ":" << yylloc.first_line << ": error: "
"`unconnected_drive does not support 'pull" << *cp
<< "'." << endl;
error_count += 1;
VLerror(yylloc, "error: `unconnected_drive does not support "
"'pull%c'.", *cp);
return;
}
cp += 1;
if (*cp != '\0') {
VLerror(yylloc, "Invalid `unconnected_drive directive (extra "
"garbage after pull direction).");
VLerror(yylloc, "error: Invalid `unconnected_drive directive "
"(extra garbage after pull direction).");
return;
}
@ -1479,7 +1453,7 @@ static void line_directive()
/* Find the starting " and skip it. */
char*fn_start = strchr(cp, '"');
if (cp != fn_start) {
VLerror(yylloc, "Invalid #line directive (file name start).");
VLerror(yylloc, "error: Invalid #line directive (file name start).");
return;
}
fn_start += 1;
@ -1487,7 +1461,7 @@ static void line_directive()
/* Find the last ". */
char*fn_end = strrchr(fn_start, '"');
if (!fn_end) {
VLerror(yylloc, "Invalid #line directive (file name end).");
VLerror(yylloc, "error: Invalid #line directive (file name end).");
return;
}
@ -1502,8 +1476,8 @@ static void line_directive()
cpr = cp;
cpr += strspn(cp, " \t");
if (cp == cpr) {
VLerror(yylloc, "Invalid #line directive (missing space after "
"file name).");
VLerror(yylloc, "error: Invalid #line directive (missing space "
"after file name).");
delete[] buf;
return;
}
@ -1512,7 +1486,7 @@ static void line_directive()
/* Get the line number and verify that it is correct. */
unsigned long lineno = strtoul(cp, &cpr, 10);
if (cp == cpr) {
VLerror(yylloc, "Invalid line number for #line directive.");
VLerror(yylloc, "error: Invalid line number for #line directive.");
delete[] buf;
return;
}
@ -1521,8 +1495,8 @@ static void line_directive()
/* Verify that only space is left. */
cpr += strspn(cp, " \t");
if ((size_t)(cpr-yytext) != strlen(yytext)) {
VLerror(yylloc, "Invalid #line directive (extra garbage after "
"line number).");
VLerror(yylloc, "error: Invalid #line directive (extra garbage "
"after line number).");
delete[] buf;
return;
}
@ -1549,7 +1523,7 @@ static void line_directive2()
/* strtoul skips leading space. */
unsigned long lineno = strtoul(cp, &cpr, 10);
if (cp == cpr) {
VLerror(yylloc, "Invalid line number for `line directive.");
VLerror(yylloc, "error: Invalid line number for `line directive.");
return;
}
lineno -= 1;
@ -1558,8 +1532,8 @@ static void line_directive2()
/* Skip the space between the line number and the file name. */
cpr += strspn(cp, " \t");
if (cp == cpr) {
VLerror(yylloc, "Invalid `line directive (missing space after "
"line number).");
VLerror(yylloc, "error: Invalid `line directive (missing space "
"after line number).");
return;
}
cp = cpr;
@ -1567,7 +1541,7 @@ static void line_directive2()
/* Find the starting " and skip it. */
char*fn_start = strchr(cp, '"');
if (cp != fn_start) {
VLerror(yylloc, "Invalid `line directive (file name start).");
VLerror(yylloc, "error: Invalid `line directive (file name start).");
return;
}
fn_start += 1;
@ -1575,7 +1549,7 @@ static void line_directive2()
/* Find the last ". */
char*fn_end = strrchr(fn_start, '"');
if (!fn_end) {
VLerror(yylloc, "Invalid `line directive (file name end).");
VLerror(yylloc, "error: Invalid `line directive (file name end).");
return;
}
@ -1584,15 +1558,15 @@ static void line_directive2()
cpr = cp;
cpr += strspn(cp, " \t");
if (cp == cpr) {
VLerror(yylloc, "Invalid `line directive (missing space after "
"file name).");
VLerror(yylloc, "error: Invalid `line directive (missing space "
"after file name).");
return;
}
cp = cpr;
/* Check that the level is correct, we do not need the level. */
if (strspn(cp, "012") != 1) {
VLerror(yylloc, "Invalid level for `line directive.");
VLerror(yylloc, "error: Invalid level for `line directive.");
return;
}
cp += 1;
@ -1601,8 +1575,8 @@ static void line_directive2()
cp += strspn(cp, " \t");
if (strncmp(cp, "//", 2) != 0 &&
(size_t)(cp-yytext) != strlen(yytext)) {
VLerror(yylloc, "Invalid `line directive (extra garbage after "
"level).");
VLerror(yylloc, "error: Invalid `line directive (extra garbage "
"after level).");
return;
}

2731
parse.y

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998-2021 Stephen Williams (steve@icarus.com)
* Copyright (c) 1998-2022 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -67,10 +67,10 @@ void VLerror(const YYLTYPE&loc, const char*msg, ...)
based_size = 0; /* Clear the base information if we have an error. */
}
void yywarn(const YYLTYPE&loc, const char*msg)
void VLwarn(const YYLTYPE&loc, const char*msg)
{
warn_count += 1;
cerr << loc << ": warning: " << msg << endl;
cerr << loc << ": " << msg << endl;
}
int VLwrap()

View File

@ -1,7 +1,7 @@
#ifndef IVL_parse_misc_H
#define IVL_parse_misc_H
/*
* Copyright (c) 1998-2021 Stephen Williams (steve@icarus.com)
* Copyright (c) 1998-2022 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -57,7 +57,6 @@ extern YYLTYPE yylloc;
*/
extern int VLlex();
extern void VLerror(const char*msg);
extern void VLerror(const YYLTYPE&loc, va_list ap);
extern void VLerror(const YYLTYPE&loc, const char*msg, ...) __attribute__((format(printf,2,3)));
#define yywarn VLwarn
extern void VLwarn(const char*msg);

View File

@ -569,7 +569,7 @@ void pform_set_scope_timescale(const struct vlltype&loc)
if (gn_system_verilog() && (scope->time_unit < scope->time_precision)) {
if (scope->time_unit_is_local || scope->time_prec_is_local) {
VLerror("error: a timeprecision is missing or is too large!");
VLerror("error: A timeprecision is missing or is too large!");
}
} else {
assert(scope->time_unit >= scope->time_precision);
@ -1093,7 +1093,7 @@ bool get_time_unit(const char*cp, int &unit)
bool rc = true;
if (strchr(cp, '_')) {
VLerror(yylloc, "Invalid timeunit constant ('_' is not "
VLerror(yylloc, "error: Invalid timeunit constant ('_' is not "
"supported).");
return false;
}
@ -1118,7 +1118,7 @@ bool get_time_unit(const char*cp, int &unit)
rc = false;
ostringstream msg;
msg << "Invalid timeunit scale '" << cp << "'.";
msg << "error: Invalid timeunit scale '" << cp << "'.";
VLerror(msg.str().c_str());
}
@ -1134,11 +1134,11 @@ static bool get_time_unit_prec(const char*cp, int &res, bool is_unit)
/* We do not support a '_' in these time constants. */
if (strchr(cp, '_')) {
if (is_unit) {
VLerror(yylloc, "Invalid timeunit constant ('_' is not "
"supported).");
VLerror(yylloc, "error: Invalid timeunit constant ('_' "
"is not supported).");
} else {
VLerror(yylloc, "Invalid timeprecision constant ('_' is not "
"supported).");
VLerror(yylloc, "error: Invalid timeprecision constant ('_' "
"is not supported).");
}
return true;
}
@ -1146,9 +1146,11 @@ static bool get_time_unit_prec(const char*cp, int &res, bool is_unit)
/* Check for the 1 digit. */
if (*cp != '1') {
if (is_unit) {
VLerror(yylloc, "Invalid timeunit constant (1st digit).");
VLerror(yylloc, "error: Invalid timeunit constant "
"(1st digit).");
} else {
VLerror(yylloc, "Invalid timeprecision constant (1st digit).");
VLerror(yylloc, "error: Invalid timeprecision constant "
"(1st digit).");
}
return true;
}
@ -1158,11 +1160,11 @@ static bool get_time_unit_prec(const char*cp, int &res, bool is_unit)
res = strspn(cp, "0");
if (res > 2) {
if (is_unit) {
VLerror(yylloc, "Invalid timeunit constant (number of "
"zeros).");
VLerror(yylloc, "error: Invalid timeunit constant "
"(number of zeros).");
} else {
VLerror(yylloc, "Invalid timeprecision constant (number of "
"zeros).");
VLerror(yylloc, "error: Invalid timeprecision constant "
"(number of zeros).");
}
return true;
}
@ -1196,7 +1198,7 @@ static bool get_time_unit_prec(const char*cp, int &res, bool is_unit)
}
ostringstream msg;
msg << "Invalid ";
msg << "error: Invalid ";
if (is_unit) msg << "timeunit";
else msg << "timeprecision";
msg << " scale '" << cp << "'.";
@ -1220,10 +1222,10 @@ void pform_set_timeunit(const char*txt, bool initial_decl)
scope->time_unit_is_default = false;
allow_timeunit_decl = false;
} else if (!scope->time_unit_is_local) {
VLerror(yylloc, "error: repeat timeunit found and the initial "
VLerror(yylloc, "error: Repeat timeunit found and the initial "
"timeunit for this scope is missing.");
} else if (scope->time_unit != val) {
VLerror(yylloc, "error: repeat timeunit does not match the "
VLerror(yylloc, "error: Repeat timeunit does not match the "
"initial timeunit for this scope.");
}
}
@ -1258,10 +1260,10 @@ void pform_set_timeprec(const char*txt, bool initial_decl)
scope->time_prec_is_default = false;
allow_timeprec_decl = false;
} else if (!scope->time_prec_is_local) {
VLerror(yylloc, "error: repeat timeprecision found and the initial "
VLerror(yylloc, "error: Repeat timeprecision found and the initial "
"timeprecision for this scope is missing.");
} else if (scope->time_precision != val) {
VLerror(yylloc, "error: repeat timeprecision does not match the "
VLerror(yylloc, "error: Repeat timeprecision does not match the "
"initial timeprecision for this scope.");
}
}
@ -1458,7 +1460,7 @@ void pform_endmodule(const char*name, bool inside_celldefine,
perm_string tmp_name = tmp_module->mod_name();
pform_cur_module.pop_front();
ostringstream msg;
msg << "Module " << mod_name
msg << "error: Module " << mod_name
<< " was nested within " << tmp_name
<< " but broken.";
VLerror(msg.str().c_str());
@ -1492,7 +1494,7 @@ void pform_endmodule(const char*name, bool inside_celldefine,
if (test != use_module_map.end()) {
ostringstream msg;
msg << "Module " << name << " was already declared here: "
msg << "error: Module " << name << " was already declared here: "
<< test->second->get_fileline() << endl;
VLerror(msg.str().c_str());
} else {
@ -1792,7 +1794,7 @@ PExpr* pform_select_mtm_expr(PExpr*min, PExpr*typ, PExpr*max)
}
if (min_typ_max_warn > 0) {
cerr << res->get_fileline() << ": warning: choosing ";
cerr << res->get_fileline() << ": warning: Choosing ";
switch (min_typ_max_flag) {
case MIN:
cerr << "min";
@ -2046,7 +2048,7 @@ void pform_make_udp(const struct vlltype&loc, perm_string name,
// Put the primitive into the primitives table
if (pform_primitives[name]) {
VLwarn("UDP primitive already exists.");
VLwarn("warning: UDP primitive already exists.");
} else {
PUdp*udp = new PUdp(name, parms->size());
@ -2127,7 +2129,7 @@ void pform_make_udp(const struct vlltype&loc, perm_string name,
// Put the primitive into the primitives table
if (pform_primitives[name]) {
VLerror("UDP primitive already exists.");
VLerror("error: UDP primitive already exists.");
} else {
PUdp*udp = new PUdp(name, pins.size());
@ -2210,7 +2212,7 @@ static void pform_makegate(PGBuiltin::Type type,
list<named_pexpr_t>*attr)
{
if (info.parms_by_name) {
cerr << info.get_fileline() << ": Gates do not have port names."
cerr << info.get_fileline() << ": error: Gates do not have port names."
<< endl;
error_count += 1;
return;
@ -2515,7 +2517,7 @@ void pform_make_var_init(const struct vlltype&li,
perm_string name, PExpr*expr)
{
if (! pform_at_module_level() && !gn_system_verilog()) {
VLerror(li, "error: variable declaration assignments are only "
VLerror(li, "error: Variable declaration assignments are only "
"allowed at the module level.");
delete expr;
return;
@ -2678,7 +2680,7 @@ void pform_makewire(const struct vlltype&li,
list<named_pexpr_t>*attr)
{
if (is_compilation_unit(lexical_scope) && !gn_system_verilog()) {
VLerror(li, "error: variable declarations must be contained within a module.");
VLerror(li, "error: Variable declarations must be contained within a module.");
return;
}
@ -2876,7 +2878,7 @@ void pform_set_attrib(perm_string name, perm_string key, char*value)
} else {
delete[] value;
VLerror("Unable to match name for setting attribute.");
VLerror("error: Unable to match name for setting attribute.");
}
}
@ -2890,7 +2892,7 @@ void pform_set_type_attrib(perm_string name, const string&key,
{
map<perm_string,PUdp*>::const_iterator udp = pform_primitives.find(name);
if (udp == pform_primitives.end()) {
VLerror("type name is not (yet) defined.");
VLerror("error: Type name is not (yet) defined.");
delete[] value;
return;
}
@ -2923,7 +2925,7 @@ static void pform_set_type_parameter(const struct vlltype&loc, perm_string name,
pform_requires_sv(loc, "Type parameter");
if (value_range)
VLerror(loc, "error: type parameter must not have value range.");
VLerror(loc, "error: Type parameter must not have value range.");
type_parameter_t *type = new type_parameter_t(name);
pform_set_typedef(loc, name, type, 0);

View File

@ -60,9 +60,9 @@ void pform_end_package_declaration(const struct vlltype&loc)
map<perm_string,PPackage*>::const_iterator test = packages_by_name.find(use_name);
if (test != packages_by_name.end()) {
ostringstream msg;
msg << "Package " << use_name << " was already declared here: "
msg << "error: Package " << use_name << " was already declared here: "
<< test->second->get_fileline() << ends;
VLerror(msg.str().c_str());
VLerror(loc, msg.str().c_str());
}