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

Syntax for parsing Rust #1

Merged
merged 4 commits into from
Aug 9, 2024
Merged

Syntax for parsing Rust #1

merged 4 commits into from
Aug 9, 2024

Conversation

virgil-serbanuta
Copy link
Member

No description provided.

Copy link
Member

@yanliu18 yanliu18 left a comment

Choose a reason for hiding this comment

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

Looks good to me.
Sorry that I didn't review all the rust syntax definition.
Since the tests are parsing, I am assuming, the defnition is working well.
Good to merge.

clean:
rm -r .build

build: $(RUST_TIMESTAMP)
Copy link
Member

Choose a reason for hiding this comment

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

Not sure what is missing on my local machine, but make build and make test produces msg: "make: Nothing to be done for `build'.".

But running $(which kompile) rust-semantics/rust.md -o .build/rust-kompiled builds the semantics.

Copy link
Member Author

Choose a reason for hiding this comment

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

That should only happen if you already built the semantics and successfully run the tests... Could you make clean or rm -r .build and try again?

syntax InnerAttribute ::= "#![" Attr "]" [symbol(innerAttribute)]
syntax OuterAttribute ::= "#[" Attr "]" [symbol(outerAttribute)]

syntax Attr ::= Identifier
Copy link
Member

Choose a reason for hiding this comment

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

It seems, Attr syntax is defined with SimplePath (line 92), would you share the reason of not using SimplePath in the sort definition?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure, I fixed it.

```k

syntax Module ::= MaybeUnsafe "mod" Identifier ";"
| MaybeUnsafe "mod" Identifier "{" InnerAttributes Items "}"
Copy link
Member

Choose a reason for hiding this comment

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

A comment rather than a review.
InnerAttributes Items is crate, not sure why the definition in rust reference book is not using crate here.

Copy link
Member Author

Choose a reason for hiding this comment

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

My guess is that they wanted the "crate" non-terminal to match the meaning of the word "crate" as used in the Rust documentation, which, IIRC, is either "source code file" or something close to that.

syntax MaybeSimplePathWithColon ::= "::" | SimplePath "::"
syntax MaybeUseTreesMaybeComma ::= "" | UseTrees | UseTrees ","
syntax UseTrees ::= UseTree
syntax UseTrees ::= UseTree "," UseTrees
Copy link
Member

Choose a reason for hiding this comment

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

Would non-empty syntactic list useful here, for line 123 and 124.

syntax UseTrees ::= NeList{UseTree, ","}

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed here and in many other places.

@virgil-serbanuta virgil-serbanuta merged commit 0fa3ae5 into main Aug 9, 2024
1 check passed
@virgil-serbanuta virgil-serbanuta deleted the syntax branch August 9, 2024 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants