From cf1c9d9a0a9dd69ecc08304f7ce96ede0c026a01 Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Sat, 18 Jan 2025 20:05:39 +0000 Subject: [PATCH] Fix error parsing PSL statement split over multiple lines. Fixes xxx --- NEWS.md | 2 ++ src/lexer.l | 11 ++++------- src/scan.h | 2 -- test/psl/parse1.vhd | 4 ++++ test/psl/parse3.vhd | 8 ++++++++ test/test_psl.c | 3 ++- 6 files changed, 20 insertions(+), 10 deletions(-) diff --git a/NEWS.md b/NEWS.md index fd6641ef6..acf53b01f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -6,6 +6,8 @@ - Fixed a regression that caused some array aggregates to be incorrectly reported as ambiguous (#1138). - The Windows installer now bundles the Tcllib library (#1136). +- Fixed a bug where PSL directives in comments were parsed incorrectly + when split over multiple lines (#1135). ## Version 1.15.0 - 2025-01-11 - `--load` is now a global option and should be placed before the `-r` diff --git a/src/lexer.l b/src/lexer.l index 3fd2e005f..d5a69d268 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -127,7 +127,7 @@ COVERAGE_OFF {PRAGMA}(?i:coverage)[ \t]+(?i:off).* COVERAGE_ON {PRAGMA}(?i:coverage)[ \t]+(?i:on).* TRANSLATE_OFF {PRAGMA}(?i:pragma)[ \t]+(?i:translate_off).* TRANSLATE_ON {PRAGMA}(?i:pragma)[ \t]+(?i:translate_on).* -PSL_COMMENT {PRAGMA}(?i:psl)[ \t]+ +PSL_COMMENT {PRAGMA}(?i:psl) PSL_CONT ^{SPACE}*({PSL_COMMENT}|"--") UTF8_MB [\x80-\xff][\x80-\xbf]{1,3} VLOG_NUMBER {INTEGER}?\'[bhd]{HEX} @@ -352,6 +352,7 @@ BEFORE ?i:before "--" { comment_caller = YY_START; BEGIN(COMMENT); } "//" { comment_caller = YY_START; BEGIN(COMMENT); } +{PSL_COMMENT}[^ \t\r\n] { comment_caller = YY_START; BEGIN(COMMENT); } {PSL_COMMENT} { if (begin_psl_comment()) { in_psl_comment = true; BEGIN(PSL); @@ -375,7 +376,7 @@ BEFORE ?i:before \n { /* Must match a single character */ } . { } -; { in_psl_comment = false; TOKEN(tSEMI); } +; { TOKEN(tSEMI); } {PSL_CONT} { /* Multi-line PSL comment */ if (!in_psl_comment) { comment_caller = YY_START; @@ -1183,6 +1184,7 @@ void scan_as_psl(void) void scan_as_vhdl(void) { BEGIN(INITIAL); + in_psl_comment = false; } void scan_as_verilog(void) @@ -1204,8 +1206,3 @@ void scan_as_sdf_expr(void) { BEGIN(SDF_EXPR); } - -bool is_scanned_as_psl(void) -{ - return (YY_START == PSL); -} diff --git a/src/scan.h b/src/scan.h index 4bd27c071..26f8ded6b 100644 --- a/src/scan.h +++ b/src/scan.h @@ -68,8 +68,6 @@ void reset_vhdl_parser(void); void reset_verilog_parser(void); void reset_sdf_parser(void); -bool is_scanned_as_psl(void); - #define tEOF 0 #define tLPAREN '(' diff --git a/test/psl/parse1.vhd b/test/psl/parse1.vhd index 76a83865b..243384266 100644 --- a/test/psl/parse1.vhd +++ b/test/psl/parse1.vhd @@ -36,4 +36,8 @@ begin -- psl assert always (x -> next x) abort y; -- OK -- psl assert always (x -> (y or next x)); -- OK -- psl assert (x or y) or (next x); -- OK + + -- psl + -- assert always xxx; -- Error (issue #1135) + -- psl1111 assert assert assert; -- Not PSL end architecture; diff --git a/test/psl/parse3.vhd b/test/psl/parse3.vhd index 7c796c725..c51013502 100644 --- a/test/psl/parse3.vhd +++ b/test/psl/parse3.vhd @@ -67,4 +67,12 @@ begin -- psl assert {a} |=> {{b[->3]} && {(a and not c)[+]}; not c and b}; -- psl assert {global_vect(1)}; -- OK (issue #1115) + + -- psl -- OK (issue #1135) + -- assert always ( + -- { + -- a = '1'; + -- true + -- } |-> c = '0' + -- ) abort c = '1'; end architecture; diff --git a/test/test_psl.c b/test/test_psl.c index 9b0620683..322994efb 100644 --- a/test/test_psl.c +++ b/test/test_psl.c @@ -1,5 +1,5 @@ // -// Copyright (C) 2022-2024 Nick Gasson +// Copyright (C) 2022-2025 Nick Gasson // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -35,6 +35,7 @@ START_TEST(test_parse1) { 19, "no visible declaration for FFF" }, { 28, "FOO already declared in this region" }, { 34, "no visible declaration for XXXX" }, + { 41, "no visible declaration for XXX" }, { -1, NULL } }; expect_errors(expect);