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

Syntax errors due to streaming with operator #693

Open
udinator opened this issue Mar 3, 2021 · 4 comments
Open

Syntax errors due to streaming with operator #693

udinator opened this issue Mar 3, 2021 · 4 comments
Assignees
Labels
style-linter Verilog style-linter issues

Comments

@udinator
Copy link

udinator commented Mar 3, 2021

The SV linter is throwing unexpected errors on the with construct used in streaming operations, even though this construct is part of the LRM.
Example error message:
../src/lowrisc_dv_mem_bkdr_if_0/sram_scrambler_pkg.sv:58:28: syntax error, rejected "with" (https://github.com/google/verible).

Example test case:

module test;
  initial begin
    logic unpacked_arr [16] = '{0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1};
    logic [3:0] nibble_arr[4];
    for (int i = 0; i < 4; i++) begin
      nibble_arr[i] = {<< {unpacked_arr with [i*4 +: 4]}};
    end
  end
endmodule
@udinator udinator added the style-linter Verilog style-linter issues label Mar 3, 2021
@udinator
Copy link
Author

udinator commented Mar 3, 2021

b/181792412

@hzeller
Copy link
Collaborator

hzeller commented Mar 3, 2021

Context: this is LRM 11.4.14
And yes, confirmed, it is indeed missing.

@hzeller
Copy link
Collaborator

hzeller commented Mar 3, 2021

Also caught by sv-tests

@hzeller
Copy link
Collaborator

hzeller commented Mar 4, 2021

More context: this was indeed thought of but not added initially due to parser generation conflicts.
(just collecting this here as context for whoever will be working on this)

@hzeller hzeller linked a pull request Mar 15, 2021 that will close this issue
@hzeller hzeller self-assigned this Mar 16, 2021
nikhiljha pushed a commit to nikhiljha/verible that referenced this issue Sep 27, 2022
switches to fortls from fortran-language-server
jbylicki pushed a commit to antmicro/verible that referenced this issue Jun 28, 2023
The stream expression has an expression followed by
an optional 'with' '[' array_range_expression ']'
(LRM 11.4.14)

There are a few other cases where an expression can
be trailed with 'with',

with_constraint_block: there we expect an
identifier list in parenthesis after 'with'
similar with array methods with predicate
with '(' ...)
Since the parser with one look-ahead can't see beyond
the 'with', it runs into a shift/reduce conflict
as it does not know if '(' or '[' is to follow.

Disambiguate that in the lexer by creating a
separate token TK_with__followed_by_bracket which is
a TK_with, where the lexer already looked ahead and
knows that it will be followed by '['.

After seeing the '[', everything but the "with" is put
back into the stream to be processed separately.

Changed lexer and parser as well as associated unit tests including formatter.

Fixing chipsalliance#693

Signed-off-by: Henner Zeller <hzeller@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
style-linter Verilog style-linter issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants