Skip to content

Yul grammar changes. #5524

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

Merged
merged 1 commit into from
Dec 3, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions docs/yul.rst
Original file line number Diff line number Diff line change
Expand Up @@ -559,8 +559,7 @@ regular strings in native encoding. For code,

Grammar::

TopLevelObject = 'object' '{' Code? ( Object | Data )* '}'
Object = 'object' StringLiteral '{' Code? ( Object | Data )* '}'
Object = 'object' StringLiteral '{' Code ( Object | Data )* '}'
Copy link
Member

Choose a reason for hiding this comment

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

Why is code not optional?

Copy link
Member

@axic axic Nov 28, 2018

Choose a reason for hiding this comment

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

I think it should be 'object' StringLiteral '{' (Code | Object | Data )+ '}'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would not allow multiple code blocks - what happens to control flow at the end of the first code block? If you want to refer to code as data, you should wrap it inside a sub-object.

About objects without code: Do you see a use-case? We can allow it at some later point, if we want, but for now, I would require code - the code itself can be empty, though.

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Object = 'object' StringLiteral '{' Code ( Object | Data )* '}'
Object = 'object' StringLiteral '{' (Code | Object | Data )+ '}'

Copy link
Member

Choose a reason for hiding this comment

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

I think an object has exactly one Code.

Copy link
Member

@axic axic Nov 28, 2018

Choose a reason for hiding this comment

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

But I don't think code is mandatory, should make it optional then.

Copy link
Member

Choose a reason for hiding this comment

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

This PR is suggesting that it should be :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Having exactly one Code (which could be empty) would also be inline with what the CLI test expects with #5341.

Code = 'code' Block
Data = 'data' StringLiteral ( HexLiteral | StringLiteral )
HexLiteral = 'hex' ('"' ([0-9a-fA-F]{2})* '"' | '\'' ([0-9a-fA-F]{2})* '\'')
Expand Down