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

Allow tuples with a single element #888

Merged
merged 2 commits into from Apr 2, 2021
Merged

Allow tuples with a single element #888

merged 2 commits into from Apr 2, 2021

Conversation

mihaibudiu
Copy link
Contributor

Copy link
Contributor

@jafingerhut jafingerhut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable to me.

@jafingerhut
Copy link
Contributor

jafingerhut commented Aug 25, 2020

The grammar shows that a keySetExpression is basically a comma-separated list of one or more simpleKeySetExpressions.

tupleKeySetExpression has parentheses around it.
simpleExpression list does not have parentheses around it.

It seems somewhat odd that parentheses are optional. Maybe p4c checks in certain contexts that they must be present, and must be absent in others? I haven't dug into that very far.

@mihaibudiu
Copy link
Contributor Author

I don't remember why we haven't merged this one.

@@ -178,14 +178,22 @@ keysetExpression
;

tupleKeysetExpression
: '(' simpleKeysetExpression ',' simpleExpressionList ')'
: "(" simpleKeysetExpression "," simpleExpressionList ")"
| "(" reducedSimpleKeysetExpression ")"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use simpleKeysetExpression here? What is the need for introducing reducedSimpleKeysetExpression?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reducedKeysetExpression is missing a case, expression

| DEFAULT
| "_"
;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is a reason to introduce reducedSimpleKeysetExpression, it seems reasonable for humans reviewing and understanding this to make its definition as similar to simpleKeysetExpression as possible, e.g. something like "DEFAULT | DONTCARE | expression MASK expression | expression RANGE expression"

@jnfoster
Copy link
Contributor

jnfoster commented Mar 1, 2021

We discussed at the March 1st, 2021 LDWG meeting.

@jafingerhut agreed to shepherd it and @mbudiu-vmw will check consistency with the p4c implementation.

@mihaibudiu
Copy link
Contributor Author

I can confirm that this grammar matches the compiler; there is some duplication for avoiding conflicts.

@jfingerh
Copy link
Contributor

@mbudiu-vmw I have carefully compared this modified grammar with the latest p4c, and agree that it matches in regards to the changes here. I will resolve all of my comments/questions on this PR, and approve it for merging.

@jfingerh
Copy link
Contributor

@mbudiu-vmw Rather, I thought I was going to resolve my comments, but I don't see the button for Github to allow me to do that. I have earlier approved this PR, so if there is anything else you would like me to do to approve this PR, let me know.

@mihaibudiu
Copy link
Contributor Author

Do you have 2 distinct github accounts?
I think we can just merge it.

@jfingerh
Copy link
Contributor

I do, @jfingerh and @jafingerhut, which I unfortunately confuse myself with, as well as others. Sorry about that.

@mihaibudiu mihaibudiu merged commit 6e5022d into master Apr 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants