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

fix: thread the mode into the parser #3599

Merged
merged 4 commits into from
Nov 22, 2022
Merged

fix: thread the mode into the parser #3599

merged 4 commits into from
Nov 22, 2022

Conversation

ggreif
Copy link
Contributor

@ggreif ggreif commented Nov 21, 2022

Turns out I was doing a bunch of things wrong. Now we make the relevant Lexer_lib.mode accessible from the parser productions (previously it just accessed a constant thing).

This makes --viper to select the verification mode in the parser too (lexer was already fine).

@ggreif ggreif added the viper Verification related label Nov 21, 2022
@ggreif ggreif requested a review from crusso November 21, 2022 21:28
@github-actions
Copy link

github-actions bot commented Nov 22, 2022

Comparing from 98c563f to 3654a35:
The produced WebAssembly code seems to be completely unchanged.

src/mo_frontend/parser.mly Outdated Show resolved Hide resolved
@@ -1,4 +1,26 @@
(* Viper only tokens and productions *)
%{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved here from parser.mly

@aterga
Copy link
Contributor

aterga commented Nov 22, 2022

I've tested that this PR enables the --viper flag, but without the flag I get, e.g.

moc test/viper/invariant.mo
test/viper/invariant.mo:9.10-9.19: syntax error [M0001], unexpected token 'invariant', expected one of token or <phrase> sequence:
  system <exp_nest>
  return <exp_nest>
  invariant <exp_nest>
  func <exp_nest>
  <nat> : async <exp_nest>

whereas beforehand we had

[nix-shell:~/workdir/motoko]$ moc test/viper/invariant.mo
test/viper/invariant.mo:9.3-9.71: syntax error [M0181], verification assertions not permitted in normal mode
test/viper/invariant.mo:10.3-10.29: syntax error [M0181], verification assertions not permitted in normal mode
test/viper/invariant.mo:11.3-11.50: syntax error [M0181], verification assertions not permitted in normal mode
test/viper/invariant.mo:14.7-14.29: syntax error [M0181], verification assertions not permitted in normal mode
test/viper/invariant.mo:16.7-16.31: syntax error [M0181], verification assertions not permitted in normal mode

which was more verbose. This is just FYI; I don't consider the new behavior problematic.

@@ -9,7 +9,10 @@ type import = string * string

let parse_with mode lexbuf parser =
let tokenizer, _ = Lexer.tokenizer mode lexbuf in
Ok (Parsing.parse 0 (parser lexbuf.Lexing.lex_curr_p) tokenizer lexbuf)
Ok
(Parsing.parse Lexer_lib.mode 0
Copy link
Contributor Author

Choose a reason for hiding this comment

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

passing an additional argument

Copy link
Contributor

@crusso crusso left a comment

Choose a reason for hiding this comment

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

LGTM

@ggreif ggreif added the automerge-squash When ready, merge (using squash) label Nov 22, 2022
@ggreif ggreif merged commit 4f15125 into viper Nov 22, 2022
@ggreif ggreif removed the automerge-squash When ready, merge (using squash) label Nov 22, 2022
@ggreif ggreif deleted the gabor/viper-parser-mode branch November 26, 2022 00:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
viper Verification related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants