-
Notifications
You must be signed in to change notification settings - Fork 641
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
Properly pass the Ltac2 notation level to the gramlib API. #14094
Conversation
2b85bdc
to
3eaf02b
Compare
I changed my mind since we can alway introduce a backwards-compatible syntax using numbers for the built-in levels and combinators for user-defined levels. The camlp5 API actually provides something similar with the AFTER / BEFORE / FIRST / LAST / LIKE combinators so it's only a matter of exposing those constructs. |
3eaf02b
to
7cb6f7f
Compare
@JasonGross would you assign? |
| Some n -> | ||
let () = | ||
if n < 0 || n > 6 then | ||
user_err (str "Notation levels must range between 0 and 6") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this error message be documented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added an entry in the refman.
I can assign if you'd like me to, but I don't feel competent to review the code changes and the current test in the test-suite is not adequate to convince me that the levels are working as intended. If you can design some test that will fail if the levels are not correctly associated, such that I no longer need to care what the code is doing, I'd be happy to take this. Alternatively, if you want to merge it under the premise that what's going on is not worse than what was happening before, I can merge it from that perspective too. |
7cb6f7f
to
fb32fce
Compare
Not sure how to do that. Now that we can print the Ltac2 grammar we might try to rely on an output test but it'd be very fragile. |
Add some Ltac2 notations that parse into an embedded AST and check for equality. e.g., Ltac2 Type tree := [ Leaf | Node (tree * tree) ]
Ltac2 Notation tactic4(a) "node456" tactic6(b) : 5 := node (a, b). or something like that, and then do stuff like |
You can do something with types. eg in ocaml let f (+) x y z = (x + y) + z
(* f : ('a -> 'b -> 'a) -> 'a -> 'b -> 'b -> 'a *)
let f (+) x y z = x + (y + z)
(* f : ('a -> 'b -> 'b) -> 'a -> 'a -> 'b -> 'b *) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wording suggestions
doc/changelog/05-tactic-language/14094-ltac2-notation-level-fix.rst
Outdated
Show resolved
Hide resolved
@JasonGross I am too lazy to write this kind of test when 1. it's unlikely to break again because of this API and 2. there are other Ltac2 parsing issues lurking around that were not yet observed because parsing has an explosive combinatoric flavour to it. I have added the test you suggested in the bug report, that was failing before and is now properly working. If by a very unfortunate mistake we use the wrong API again it will be caught anyways, the rest seems like we would need a complete parsing test suite for the language which is kind of unrelated to the PR. |
For some reason I was confusing the position and the level in the previous version of the code. Fixes coq#11866: Ltac2 Notations do not respect precedence.
fb32fce
to
f6e393d
Compare
@coqbot merge now |
@JasonGross: You can't merge the PR because you're not among the assignees. |
@coqbot merge now |
For some reason I was confusing the position and the level in the previous version of the code.
I am leaving this as a draft for now since we may seize the opportunity to have a richer level language for Ltac2 notations.
Fixes #11866: Ltac2 Notations do not respect precedence.