Commit graph

99 commits

Author SHA1 Message Date
Kyle Miller
02a4713875
feat: enable notationItem in "mixfix" notation commands (#10378)
This PR enables using `notation` items in
`infix`/`infixl`/`infixr`/`prefix`/`postfix`. The motivation for this is
to enable being able to use `pp.unicode`-aware parsers. A followup PR
can combine core parsers as such:
```lean
infixr:30 unicode(" ∨ ", " \\/ ") => Or
```

Continuation of #10373.
2025-09-14 18:54:36 +00:00
Kyle Miller
3e4fa12c72
feat: add unicode(...) parser syntax and pp.unicode option (#10373)
This PR adds a `pp.unicode` option and a `unicode("→", "->")` syntax
description alias for the lower-level `unicodeSymbol "→" "->"` parser.
The syntax is added to the `notation` command as well. When `pp.unicode`
is true (the default) then the first form is used when pretty printing,
and otherwise the second ASCII form is used. A variant, `unicode("→",
"->", preserveForPP)` causes the `->` form to be preferred; delaborators
can insert `→` directly into the syntax, which will be pretty printed
as-is; this allows notations like `fun` to use custom options such as
`pp.unicode.fun` to opt into the unicode form when pretty printing.

Additionally:
- Adds more documentation for the `symbol` and `nonReservedSymbol`
parser descriptions.
- Adds documentation for the
`infix`/`infixr`/`infixl`/`prefix`/`postfix` commands.
- The parenthesizers for symbols are improved to backtrack if the atom
doesn't match.
- Fixes a bug where `&"..."` symbols aren't validated.

This is partial progress for issue #1056. What remains is enabling
`unicode(...)` for mixfix commands and then making use of it for core
notation.
2025-09-14 04:40:03 +00:00
Sebastian Ullrich
2efbe4ac36
feat: support visibility modifiers on syntax abbrevs (#10228)
Closes #10068
2025-09-03 07:53:29 +00:00
Sebastian Ullrich
ff1d3138bf
refactor: module-ize Lean (#9330) 2025-07-25 12:02:51 +00:00
Henrik Böving
23e49eb519 perf: add prelude to all Lean modules 2024-02-18 14:55:17 -08:00
Scott Morrison
329e00661a
chore: upstream Std.Util.ExtendedBinders (#3320)
This is not a complete upstreaming of that file (it also supports `∀ᵉ (x
< 2) (y < 3), p x y` as shorthand for `∀ x < 2, ∀ y < 3, p x y`, but I
don't think we need this; it is used in Mathlib).

Syntaxes still need to be made built-in.

---------

Co-authored-by: Leonardo de Moura <leomoura@amazon.com>
2024-02-14 11:36:00 +00:00
Mario Carneiro
5661b15e35 fix: spacing and indentation fixes 2023-05-28 18:48:36 -07:00
Mario Carneiro
765ebcdbf0 feat: use withoutPosition consistently 2022-10-24 12:51:32 -07:00
Mario Carneiro
e7c7678ab0 refactor: line wrapping in parser code 2022-10-24 08:37:29 -07:00
Mario Carneiro
583e023314 chore: snake-case attributes (part 2) 2022-10-19 09:28:08 -07:00
Mario Carneiro
dd5948d641 chore: snake-case attributes (part 1) 2022-10-19 09:28:08 -07:00
Gabriel Ebner
fb4d90a58b feat: dynamic quotations for categories 2022-10-18 14:59:14 -07:00
Mario Carneiro
6392c5b456 chore: import reductions 2022-09-15 14:02:38 -07:00
Mario Carneiro
a4f1db7aca feat: attributes on {macro,elab}(_rules) 2022-08-15 08:40:40 -07:00
Mario Carneiro
3b793b949b feat: attributes on notation 2022-08-14 11:18:20 -07:00
Mario Carneiro
c961cd1310 feat: doc comments on notation 2022-08-13 17:18:14 -07:00
Mario Carneiro
e816424466
chore: use Category declarations for builtin cats too (#1400) 2022-08-03 18:10:54 -07:00
Leonardo de Moura
1c770ac8d7 feat: doc strings for declare_syntax_cat
see #1374
2022-07-27 13:40:08 -07:00
Leonardo de Moura
e1fc904786 feat: attributes on syntax
closes #1321
2022-07-18 23:37:11 -04:00
Leonardo de Moura
e336ff5f93 feat: indentation sensitiviy for macro and elab commands
This commit fixes issue reported at
https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/Command.20terminator/near/257674790
2021-10-18 17:16:09 -07:00
Leonardo de Moura
f43ab76641 feat: doc string for syntax abbreviations 2021-09-12 18:26:36 -07:00
Leonardo de Moura
d67c633ca1 feat: allow user to set "behavior" at declare_syntax_cat 2021-09-01 13:28:12 -07:00
Sebastian Ullrich
e632c14f3f chore: align stx precedence in syntax to the new one in macro 2021-08-24 10:11:12 -07:00
Sebastian Ullrich
20accf5105 feat: revise macro parameter syntax 2021-08-12 07:48:42 -07:00
Sebastian Ullrich
8637220927 fix: make precedence mandatory for mixfix commands
Resolves #577
2021-07-19 13:18:58 -07:00
Sebastian Ullrich
3f4ab0a2af feat: implement elab_rules
TODO: infer category from quotation type
2021-06-21 10:17:26 -07:00
Sebastian Ullrich
9101c9d5da feat: support docstrings on syntax/macro/... 2021-06-21 10:17:26 -07:00
tydeu
44f45f426c
feat: add scoped macro_rules (#432) 2021-04-30 09:05:09 +02:00
Sebastian Ullrich
73cf3533a1 fix: count quotation depth in parser correctly 2021-04-29 13:33:48 +02:00
Leonardo de Moura
09d438ca1d chore: enforce notation parameter naming convention 2021-04-19 18:54:09 -07:00
Leonardo de Moura
164577d94e chore: remove parser! and tparser!
The new macros are called "leading_parser` and `trailing_parser`.

cc @Kha
2021-03-11 09:36:58 -08:00
Sebastian Ullrich
1c31240ebb feat: token antiquotations in macro 2020-12-22 13:11:04 +01:00
Leonardo de Moura
0642a62848 chore: prepare to add scoped macro and elab commands 2020-12-21 16:50:29 -08:00
Leonardo de Moura
4fc06bfcca feat: add optional (priority := <prio>) to instance command 2020-12-21 10:02:12 -08:00
Leonardo de Moura
43284cc5fa feat: improve notation for setting parser names and priorities 2020-12-21 09:11:12 -08:00
Leonardo de Moura
97642bd000 fix: prio issue 2020-12-16 07:44:48 -08:00
Leonardo de Moura
6100ed9283 feat: add LeadingIdentBehavior type
Different strategies for handling the leading identifier in the
`Pratt` parser loop.
2020-12-15 16:45:14 -08:00
Leonardo de Moura
69e8385f8d refactor: move prioParser to Term.lean 2020-12-14 17:33:38 -08:00
Leonardo de Moura
0004196977 feat: add attrParam builtin parsers 2020-12-14 17:27:28 -08:00
Leonardo de Moura
abe7481453 feat: elaborate prio DSL 2020-12-14 16:25:10 -08:00
Leonardo de Moura
acba8d4a4a chore: cleanup 2020-12-14 16:01:52 -08:00
Leonardo de Moura
a46505cb8b feat: use new precedence syntax 2020-12-14 15:14:03 -08:00
Leonardo de Moura
f95a450894 feat: add builtin prec/prio parsers 2020-12-14 15:05:39 -08:00
Leonardo de Moura
216d34e178 feat: add prio parser category 2020-12-14 13:24:56 -08:00
Leonardo de Moura
c5e201bce6 feat: add prec syntax category 2020-12-14 13:09:27 -08:00
Leonardo de Moura
ffefd8db36 chore: remove weird syntax sugar from macro command
Before this commit,
```
macro term x:term : term => `($x)
```
would generate the notation
```
syntax "term" term : term
```
2020-12-10 08:09:47 -08:00
Sebastian Ullrich
fd1f74c421 feat: extend sepBy syntax syntax 2020-12-09 17:36:29 +01:00
Leonardo de Moura
bcf4ffdd1a feat: local modifier at @[...] 2020-12-05 07:24:55 -08:00
Leonardo de Moura
c6ab0b4d2c feat: allow local modifier at infix, notation, and syntax commands 2020-12-05 07:00:06 -08:00
Leonardo de Moura
5a772c6cae feat: expand scoped notation into scoped attribute modifier 2020-12-04 11:39:00 -08:00