-
Notifications
You must be signed in to change notification settings - Fork 36
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
parse error simple valid verilog syntax #54
Comments
PR is welcome! |
I also hit this. Reducing the testcase further: module test(input [1:0] b, output [1:0] a);
assign a = { b[1:0] };
endmodule This is the relevant part of the parse tree:
I think the correct parse would be: Instead it has gone down the garden path with |
Here's an actual testcase: diff --git a/corpus/assign.txt b/corpus/assign.txt
index 81e897a..cc3a9ab 100644
--- a/corpus/assign.txt
+++ b/corpus/assign.txt
@@ -222,6 +222,34 @@ endmodule
))
))
+
+============================================
+assign - concatenation RHS with bit_select
+============================================
+
+module mod ();
+ assign a = {b[0]};
+endmodule
+
+----
+
+
+(source_file (module_declaration
+ (module_header (module_keyword) (simple_identifier))
+ (module_nonansi_header (list_of_ports))
+ (module_or_generate_item (continuous_assign
+ (list_of_net_assignments (net_assignment
+ (net_lvalue (simple_identifier))
+ (expression (primary (concatenation
+ (expression (primary
+ (simple_identifier)
+ (select1 (bit_select1 (expression (primary (primary_literal (integral_number (decimal_number (unsigned_number))))))))
+ ))
+ )))
+ ))
+ ))
+))
+
============================================
assign - bit_select
============================================ The failing RHS expression output from
So the ambiguity is that simple concatenation lists match both I only need Verilog parsing, not SystemVerilog, so this patch works for me (and all the tests in diff --git a/grammar.js b/grammar.js
index d1980f9..3d7d67b 100644
--- a/grammar.js
+++ b/grammar.js
@@ -4123,7 +4123,6 @@ const rules = {
prec.left(PREC.UNARY, seq(
$.unary_operator, repeat($.attribute_instance), $.primary
)),
- prec.left(PREC.UNARY, $.inc_or_dec_expression),
prec.left(PREC.PARENT, seq('(', $.operator_assignment, ')')),
exprOp($, PREC.ADD, choice('+', '-')), Not suitable for a PR, but maybe useful to someone else who stumbles across this issue. |
There seems to be a problem in the concat grammar. Given this simple verilog tests:
WHen I run:
I get this error at the end:
but the verilog is fine.
If I change to this, it parses:
The text was updated successfully, but these errors were encountered: