From fdd10e5c9758a8fac922fb2a40388b94db83923c Mon Sep 17 00:00:00 2001 From: Hiroo HAYASHI <24754036+hirooih@users.noreply.github.com> Date: Sat, 5 Dec 2020 11:51:47 +0900 Subject: [PATCH] SystemVerilog: improve the handling of case labels --- parsers/verilog.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/parsers/verilog.c b/parsers/verilog.c index 5e99cd7eb4..c508817d85 100644 --- a/parsers/verilog.c +++ b/parsers/verilog.c @@ -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 ':'; } @@ -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 ':'; } @@ -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 @@ -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 */