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

Fix parsing of 'with' inside streaming operator. #1504

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hzeller
Copy link
Collaborator

@hzeller hzeller commented Oct 12, 2022

This is picking up where we left off in #697. Mostly the strong suggestion there was to use lexer states which has to be explored here

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 #693

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>
@hzeller hzeller force-pushed the 20221012-fix-parsing-of-with-streaming-693 branch from c6a9304 to 4cb5360 Compare October 12, 2022 14:22
@hzeller
Copy link
Collaborator Author

hzeller commented Feb 10, 2023

Hey @msierszulski maybe this would be something interesting for you to pick up ?

I started it a long time ago in #697 but then became busy with other things so I didn't have the time to implement the reviewer-suggested changes.

Since you're currently actively looking at the yacc file in other contexts, maybe this would be something interesting for you to make a fresh pull request out of that implements the reviewer suggestions from back then ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Priority, but unplanned
Development

Successfully merging this pull request may close these issues.

None yet

1 participant