It seems chaining 2 method calls makes the parser throw an error.
I found two examples (see below) where calling parse_sv would fail while simply removing .method2() would fix the issue.
The examples are very similar, but the place at which the error is indicated is different so I thought it might help.
I also took a look at the BNF definition of Systemverilog, and I believe all those examples should be valid since a method_call_root can itself be a method_call. (Note that I only kept what was required to see the recursion in the BNF bellow)
- subroutine_call ::= method_call
- method_call ::= method_call_root . method_call_body
- method_call_body ::= method_identifier { attribute_instance } [ ( list_of_arguments ) ]
- method_call_root ::= primary
- primary ::= function_subroutine_call
- function_subroutine_call ::= subroutine_call
Example 1
Content of test_file_1.sv:
package A;
class B;
function bar foo();
bit test = variable.method1().method2();
endfunction : foo
endclass : B
endpackage : A
Return value of the parser (indicates the last letter of bit):
Err(Parse(Some(("path/to/test_file_1.sv", 62))))
Example 2
Content of test_file_2.sv:
package A;
class B;
function bar foo();
bit test;
test = variable.method1().method2();
endfunction : foo
endclass : B
endpackage : A
Return value of the parser (indicates the closing parenthesis of method1):
Err(Parse(Some(("path/to/test_file_2.sv", 102))))
It seems chaining 2 method calls makes the parser throw an error.
I found two examples (see below) where calling
parse_svwould fail while simply removing.method2()would fix the issue.The examples are very similar, but the place at which the error is indicated is different so I thought it might help.
I also took a look at the BNF definition of Systemverilog, and I believe all those examples should be valid since a
method_call_rootcan itself be amethod_call. (Note that I only kept what was required to see the recursion in the BNF bellow)Example 1
Content of
test_file_1.sv:Return value of the parser (indicates the last letter of
bit):Example 2
Content of
test_file_2.sv:Return value of the parser (indicates the closing parenthesis of
method1):