Skip to content

Commit

Permalink
SystemVerilog: improve the handling of case labels
Browse files Browse the repository at this point in the history
  • Loading branch information
hirooih committed Dec 5, 2020
1 parent 35d31ab commit fdd10e5
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions parsers/verilog.c
Original file line number Diff line number Diff line change
Expand Up @@ -1621,8 +1621,9 @@ static int processType (tokenInfo* token, int c, verilogKind* kind, bool* with)
if (c == ':')
{
c = skipWhite (vGetc ());
if (c != ':') // case label
if (c != ':')
{
verbose ("Unexpected input.\n");
vUngetc (c);
return ':';
}
Expand Down Expand Up @@ -1709,8 +1710,9 @@ static int skipClassType (tokenInfo* token, int c)
else // c == ':'
{
c = skipWhite (vGetc ());
if (c != ':') // case label
if (c != ':')
{
verbose ("Unexpected input.\n");
vUngetc (c);
return ':';
}
Expand All @@ -1727,7 +1729,7 @@ static int tagNameList (tokenInfo* token, int c)
verilogKind kind = token->kind;

c = skipClassType (token, c);
if (c == ':' || c == ';') // case label or ## (cycle delay)
if (c == ':' || c == ';') // ## (cycle delay) or unexpected input
return c;

// skip drive|charge strength or type_reference, dimensions, and delay for net
Expand Down Expand Up @@ -1796,13 +1798,16 @@ static int findTag (tokenInfo *const token, int c)
break;
case K_IDENTIFIER:
{
if (c == '[') // for a case label foo[x]:
c = skipPastMatch ("[]");

if (c == ':')
; /* label */
else if (c == '{')
else if (c == ',' || c == '{') // "foo, ..." or "coverpoint foo { ... }"
c = skipWhite(vGetc());
else if (c == '(') // task, function, or method call
c = skipPastMatch ("()");
else if (c == '=')
else if (c == '=') // assignment
c = skipExpression (skipWhite(vGetc()));
else
c = tagNameList (token, c); /* user defined type */
Expand Down

0 comments on commit fdd10e5

Please sign in to comment.