Zulip Chat Archive
Stream: lean4
Topic: Syntax declaration causes parsing error
Yicheng Qian (Sep 01 2023 at 20:51):
How can we define a custom syntax containing an identifier prefix while not causing parsing problems? For example, if I define
syntax foo := "foo"
syntax (name := bar) "bar" foo : tactic
then
#check (fun (foo : Nat) => foo)
produces error "expected ')' or term". Is there any way to fix this?
Mario Carneiro (Sep 01 2023 at 20:53):
does using &"foo"
work?
Yicheng Qian (Sep 01 2023 at 20:53):
Oh it works!
Mario Carneiro (Sep 01 2023 at 20:53):
it should work in this case, but I don't know whether the real example is more complex
Yicheng Qian (Sep 01 2023 at 20:54):
What does &
stand for?
Mario Carneiro (Sep 01 2023 at 20:54):
nonReservedToken
instead of token
Yicheng Qian (Sep 01 2023 at 20:54):
Ok, it also works in the real example.
Mario Carneiro (Sep 01 2023 at 20:55):
the limitation of nonReservedToken
is that it will not be differentiated from an ident
in the same position
Yicheng Qian (Sep 01 2023 at 21:00):
Ok, I see. If a token is reserved then it cannot be ident
, but if it's not reserved, then the corresponding string can represent either the token or an ident.
Last updated: Dec 20 2023 at 11:08 UTC