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

Antiquotation types silently ignore tokens #1275

Closed
gebner opened this issue Jul 2, 2022 · 4 comments · Fixed by #1744
Closed

Antiquotation types silently ignore tokens #1275

gebner opened this issue Jul 2, 2022 · 4 comments · Fixed by #1744
Assignees
Labels
bug Something isn't working

Comments

@gebner
Copy link
Member

gebner commented Jul 2, 2022

import Lean open Lean
@[defaultInstance] instance : MonadQuotation Elab.TermElabM := inferInstance

syntax "👉" (ident <|> "_") : term
#eval `(👉 $_)

The last underscore has type TSyntax `ident, which suggests that only identifiers are valid to insert here.

This just majorly confused me in leanprover-community/mathport#152.

To clarify: I would expect a type like TSyntax [`ident, `token.«_»].

Versions

Nightly from July 2, as well as the relaxed antiquotations branch.

@gebner
Copy link
Member Author

gebner commented Jul 2, 2022

I'm not sure what the takeaway here is:

  1. Never use nested <|>.
  2. Add antiquotations for <|>.
  3. Add antiquotations for symbols.
  4. Add a leading_parser to def binderIdent.

@Kha
Copy link
Member

Kha commented Jul 2, 2022

This comes back to the old issue of tokens being ignored in syntax patterns. How about something like the following:

  • We introduce a new parser alias tokenWithAntiquot(str) that introduces both an antiquotation as well as a surrounding syntax node so that it is not ignored in syntax patterns anymore
  • We come up with sensible heuristics for when to default to tokenWithAntiquot in syntax, say whenever str is not used in a sequence. Thus "simp" ("!" <|> "?") ... would make only the latter two tokens pattern-relevant.

@gebner
Copy link
Member Author

gebner commented Jul 2, 2022

say whenever str is not used in a sequence

More conservatively, we could also say whenever str is used directly in a <|>. The difference between the heuristics would be with "+"+ or "?"?, where we don't really need nodes or antiquotations.

The same should presumably also apply to unicode symbols.

@Kha
Copy link
Member

Kha commented Jul 2, 2022

Yes, that would probably be a better heuristic!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants