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

[CN] Add parsing of a->b expressions in CN assertions #396

Merged
merged 5 commits into from
Jul 22, 2024

Conversation

septract
Copy link
Contributor

@septract septract commented Jul 17, 2024

Work on addressing #328

This works by modifying parsers/c/c_parser.mly to desugar a->b expressions to (*a).b

I also added a testcase demonstrating the new syntax.

@septract septract changed the title Add arrow access syntax (2nd attempt) [CN] Add parsing of a->b expressions in CN assertions (2nd attempt) Jul 18, 2024
@septract septract changed the title [CN] Add parsing of a->b expressions in CN assertions (2nd attempt) [CN] Add parsing of a->b expressions in CN assertions Jul 18, 2024
@septract septract marked this pull request as ready for review July 18, 2024 00:20
@septract
Copy link
Contributor Author

cc @dc-mak

@cp526
Copy link
Collaborator

cp526 commented Jul 18, 2024

That looks good. Though ideally we'd delay the desugaring until after parsing, so we have the parse AST record exactly what the user wrote (and be able to give better error messages).

That would involve a bit more work:

  • adding an AST node for the arrow notation to frontend/model/cn.lem
  • changing c_parser.mly to output that AST node instead of immediately desugaring
  • extending cabs_to_ail.lem (which does symbol resolution) for the new AST node, just following the way that code works for other similar constructs
  • making compile.ml (which translates parse AST to internal ast) do the desugaring

Which sounds like a lot but, I suspect, is on the order of 30 lines of code.

@septract
Copy link
Contributor Author

@cp526 I pushed desugaring later down the pipeline. Does this look good?

I accidentally merged main to my branch so you should squash before merging.

@cp526
Copy link
Collaborator

cp526 commented Jul 22, 2024

Looks good!

@cp526 cp526 merged commit 7bdc9b1 into rems-project:master Jul 22, 2024
1 check passed
@septract septract deleted the mdd/member-syntax-2 branch July 22, 2024 21:12
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.

2 participants