Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue when using \ followed by " #1831

Open
LapinFou opened this issue Jun 21, 2023 · 3 comments
Open

Issue when using \ followed by " #1831

LapinFou opened this issue Jun 21, 2023 · 3 comments

Comments

@LapinFou
Copy link

LapinFou commented Jun 21, 2023

Hi folks,

I encountered an issue when using AUTO features with the following Verilog code.

Updating AUTOs...
verilog-modi-current: Search failed: "\\<\\(end\\(?:c\\(?:lass\\|on\\(?:fig\\|nectmodule\\)\\)\\|interface\\|module\\|p\\(?:ackage\\|r\\(?:imitive\\|ogram\\)\\)\\)\\)\\>"

After some investigation, I found the problematic line (see below).

   task tbPassed;
      begin
           begin
              $display("\n                  xx");
              $display("                xxx    _____         _____ _____");
              $display("              xxxx    |  __ \\ /\\    / ____/ ____|");
              $display("            xxxxx     | |__) /  \\  | (___| (___");
              $display("  xxx     xxxxxx      |  ___/ /\\ \\  \\___ \\\\___ \\"); // Generate error -> "verilog-modi-current: Search failed [...]"
              $display("  xxxx  xxxxxx        | |  / ____ \\ ____) |___) |");
              $display("    xxxxxxxx          |_| /_/    \\_\\_____/_____/");
              $display("      xxxx");
          end
      end
   endtask

If I add a space before the final " (\\ ") instead of \\")), then it does work.
Please see the corrected code below:

   task tbPassed;
      begin
           begin
              $display("\n                  xx");
              $display("                xxx    _____         _____ _____");
              $display("              xxxx    |  __ \\ /\\    / ____/ ____|");
              $display("            xxxxx     | |__) /  \\  | (___| (___");
              $display("  xxx     xxxxxx      |  ___/ /\\ \\  \\___ \\\\___ \\ "); // This i OK
              $display("  xxxx  xxxxxx        | |  / ____ \\ ____) |___) |");
              $display("    xxxxxxxx          |_| /_/    \\_\\_____/_____/");
              $display("      xxxx");
          end
      end
   endtask

I'm using the Verilog mode version 2023.06.06.141322628 with GNU Emacs 28.2 on Linux (RHEL7).

@LapinFou LapinFou changed the title Issue when using \ before " Issue when using \ followed by " Jun 21, 2023
@wsnyder
Copy link
Member

wsnyder commented Jul 25, 2023

Thanks for the report. I looked at this and the possible fix would be very slow, so I think until a better fix gets more thought it will need to be worked around as you did.

acr4 added a commit to acr4/verilog-mode that referenced this issue Sep 9, 2023
…gs (veripool#1831)

  "...\\..." is a string containing a backslash: \
  "...\"..." is a string containing a double-quote: "

When parsing double-quoted strings, we must detect embedded escaped backslashes
and double-quotes. Detecting when a string terminates with one or more of these
characters is tricky. Strings terminating in "...\"" are not uncommon, and have
reasonably robust support, but strings terminating in "...\\" are quite rare,
and were quite broken.

This patch aims to improve the detection of "...\\" (or "...\\\\", or any even
number of backslashes in a row immediately preceding a double-quote string
terminator.
@acr4
Copy link
Contributor

acr4 commented Sep 9, 2023

PR #1840 begins to think about how to solve this. Like @wsnyder said, it's more complex than it looks on the surface. Here's a quick test-case, but by no means an exhaustive one. It just builds on @LapinFou's original text block.

module m;

   always @(/*AS*/) begin
      if(x)
        y = z;
   end

   task tbPassed;
      begin
         begin
            $display("\n                  xx");
            $display("                xxx    _____         _____ _____");
            $display("              xxxx    |  __ \\ /\\    / ____/ ____|");
            $display("            xxxxx     | |__) /  \\  | (___| (___");
            $display("  xxx     xxxxxx      |  ___/ /\\ \\  \\___ \\\\___ \\");
            $display("  xxxx  xxxxxx        | |  / ____ \\ ____) |___) |");
            $display("    xxxxxxxx          |_| /_/    \\_\\_____/_____/");
            $display("      xxxx");
         end
      end
   endtask

endmodule // m

@LapinFou
Copy link
Author

LapinFou commented Sep 9, 2023

Thanks a lot for looking to fix this issue. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants