-
Notifications
You must be signed in to change notification settings - Fork 28
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] Feature: add logical implication to the spec language #329
Comments
Where is the code that supports the ternary conditional? |
@elaustell it starts here cerberus/parsers/c/c_parser.mly Line 2071 in 4b3b206
And ends up hitting this Line 78 in 4b3b206
Though for the sake of location info fidelity it's probably worth just adding it as new construct. |
I notice that there is already some support for Lines 192 to 193 in c6524d2
which appears to have -> as the impl syntax. However I know @bcpierce00 mentioned using -> to talk about the fields of structs in ghost code. Should we change the existing support for impl to something like ==> , or leave what exists unchanged and add something else entirely?
|
Changing it to And regarding adding implication: I had forgotten we internally have a term for implication already; this means this change just needs additions to the frontend. |
@elaustell it sounds like you are going to implement this (thank you!). Once you are done, it would be great to also add some examples of the new syntax to the example archive and/or tutorial example set. |
Something else I notice (and maybe the reason it hasn't been implemented yet) is that there are currently two different uses of cerberus/backend/absint/src/cfg.ml Lines 274 to 276 in ec8db7e
Here, Impl seems to refer to some sort of implementation. This use of Impl is referenced in many other parts of the code base. However, Impl is also used inLine 794 in ec8db7e
Here, it refers to implication. There are also many cases of this use of Impl . Now that I am adding the implication Impl in more places, I am running into errors. Should I change the existing usage of Impl as an implication? Or what is the best course of action?
|
@cp526 @dc-mak We need to move CN to using it's own lexer before changing to Because this will require adding a new punctuator to the lexer which in the current setup will affect base Cerberus because of CN's reuse of the C lexer. It was fine to add CN keywords because they are in a separated lexicon which we use at runtime just for CN, but we can't do that for punctuators. |
@bcpierce00 "implies" would indeed work. I started the splitting of C/CN lexers and parsers so we should be able to move to |
@elaustell I had a look at your austell_addImpl branch, unless I'm misunderstanding the feature request you shouldn't be changing anything to Cabs, Ail or the rest of the pipeline in base Cerberus. You just need the new And don't do merge commits of |
Just popping in to say thanks to Kayvan, and also confirm that Kayvan is correct. cerberus/backend/cn/ONBOARDING.md Line 34 in ec8db7e
Thanks for the feature! @elaustell do feel free open draft PRs and request reviews frequently so we can can discuss questions about the code (and I can get notified as a reviewer!) |
CN parsing of C-types should be the same as in Cerberus base; i expect if we make it less general we’ll sooner or later run into code that needs it. Can we not make CN’s parser “import” the whole standard C parser and then build on top (even if that means including expression parsing)? |
@cp526 that makes sense. Menhir has a grammar concatenation feature that would allow us to "import" the C grammar when building CN's, but that requires using the same I have a first attempt that involves calling the C parser on C type-names from the CN lexer and producing I've created a draft PR #342 so we can move the discussion there. |
Currently I am unable to rebase on master, I think because I don't have write access to Cerberus? I get the following error:
|
Sorry, that's my bad. I'll send an email now about repository access. |
@elaustell it's probably an issue of remote configuration. What does |
|
does the following command work?
(@dc-mak we probably need to clarify the instructions in ONBOARDING.md) |
Yes, that does work, thanks so much! Sorry, I'm not fluent in GitHub quite yet. |
@kmemarian I would really like to get |
@elaustell Please feel free to direct any question directly to me via email or Mattermost as a first port of call and we can discuss there :-) |
This commit adds `implies` as a new, infix logical binary operator for the spec language. It does not implement it for the runtime testing. The reason we use a new keyword "implies" instead of a more natural `==>` is that currently the lexer is shared between C and CN, and and so we cannot add `==>` to CN without adding it to C, which is incorrect because C does not support that token. Fixes rems-project#329
This commit adds `implies` as a new, infix logical binary operator for the spec language. It does not implement it for the runtime testing. The reason we use a new keyword "implies" instead of a more natural `==>` is that currently the lexer is shared between C and CN, and and so we cannot add `==>` to CN without adding it to C, which is incorrect because C does not support that token. Fixes rems-project#329
Currently: CN's spec language only supports C's ternary conditional operator
B ? P : Q
Ideally: CN should support logical implication
A ==> B
(or whatever symbol we prefer for implication - but I suggest we use==>
which is the ACSL / FramaC's syntax).How: Desugar to a ternary conditional, or duplicate and modify the code which supports the ternary conditional.
This might be an easy first change for someone diving into the CN codebase.
The text was updated successfully, but these errors were encountered: