Commit graph

60 commits

Author SHA1 Message Date
Kyle Miller
a1c3a36433
feat: parity between structure instance notation and where notation (#6165)
This PR modifies structure instance notation and `where` notation to use
the same notation for fields. Structure instance notation now admits
binders, type ascriptions, and equations, and `where` notation admits
full structure lvals. Examples of these for structure instance notation:
```lean
structure PosFun where
  f : Nat → Nat
  pos : ∀ n, 0 < f n

def p : PosFun :=
  { f n := n + 1
    pos := by simp }

def p' : PosFun :=
  { f | 0 => 1
      | n + 1 => n + 1
    pos := by rintro (_|_) <;> simp }
```
Just like for the structure `where` notation, a field `f x y z : ty :=
val` expands to `f := fun x y z => (val : ty)`. The type ascription is
optional.

The PR also is setting things up for future expansion. Pending some
discussion, in the future structure/`where` notation could have have
embedded `where` clauses; rather than `{ a := { x := 1, y := z } }` one
could write `{ a where x := 1; y := z }`.
2024-11-30 20:27:25 +00:00
Sebastian Ullrich
6c63c9c716
feat: quotations for parser aliases (#4307)
Another papercut towards incremental `have`
2024-05-30 09:22:22 +00:00
Leni Aniva
ab36ed477e
feat: allow trailing comma in tuples, lists, and tactics (#2643) 2023-11-17 13:31:41 +01:00
Sebastian Ullrich
8fc1af650a fix: symmetry in orelse antiquotation parsing 2023-07-28 08:36:33 -07:00
Sebastian Ullrich
d4caf1f922 fix: $_* anonymous suffix splice syntax pattern 2023-03-06 16:30:18 +01:00
Gabriel Ebner
fb4d90a58b feat: dynamic quotations for categories 2022-10-18 14:59:14 -07:00
Leonardo de Moura
37af11ae20 fix: unused match-syntax alternatives are silently ignored
closes #1371
2022-07-31 06:00:08 -07:00
Sebastian Ullrich
3a56db2812 chore: fix tests 2022-06-27 22:37:02 +02:00
Sebastian Ullrich
ec045bfbb8 feat: $_ antiquotation pattern 2022-06-04 13:57:04 +02:00
Leonardo de Moura
3862e7867b refactor: make String.Pos opaque
TODO: this refactoring exposed bugs in `FuzzyMatching` and `Lake`

closes #410
2022-03-20 10:47:13 -07:00
Leonardo de Moura
e9d85f49e6 chore: remove tryPureCoe?
Based on the discussion at
https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/for.2C.20unexpected.20need.20for.20type.20ascription/near/269083574
The consensus seemed to be that "auto pure" is more confusing than its worth.
2022-02-03 16:25:24 -08:00
Sebastian Ullrich
e4bf5977d9 fix: syntax pattern match against multiple identifiers 2021-06-10 18:15:40 +02:00
Sebastian Ullrich
a02c6fd3eb chore: adapt stdlib & tests 2021-05-20 15:17:36 -07:00
Sebastian Ullrich
088774536e fix: syntax match: do not discard other patterns after splices 2021-05-07 16:08:10 +02:00
Sebastian Ullrich
683ecb2d65 feat: ignore unquoted identifiers in prechecked quotations 2021-04-29 13:30:09 +02:00
Sebastian Ullrich
9301e05a7e feat: double-quoted quotation semantics and basic precheck hooks 2021-04-27 16:38:37 -07:00
Leonardo de Moura
1c23d68c6a feat: add (generalizing := true/false) optional attribute to match 2021-04-15 17:04:25 -07:00
Sebastian Ullrich
1e61b7db89 fix: partial syntax tree panic
Fixes #391
2021-04-12 18:33:39 +02:00
Sebastian Ullrich
18aaef4d93 chore: fix test 2021-02-11 18:45:06 +01:00
Sebastian Ullrich
8320ab6177 fix: syntax match: check identifiers (using strict equality) 2021-02-11 17:50:05 +01:00
Sebastian Ullrich
a9f96ace3e chore: naming 2021-01-20 16:48:50 +01:00
Sebastian Ullrich
79107a2316 feat: copy & store whole ref range in SourceInfo 2021-01-20 16:48:50 +01:00
Sebastian Ullrich
bbafd80322 chore: token antiquotations: return/take full Syntax (but only use head info of it)
/cc @leodemoura
2020-12-26 23:54:46 +01:00
Sebastian Ullrich
c3c27f8dd3 feat: lift restriction on number of antiquotations in splice
/cc @leodemoura
2020-12-25 18:41:03 +01:00
Sebastian Ullrich
07c7638fd7 feat: token source info antiquotations tk%$id
/cc @leodemoura
2020-12-22 13:11:04 +01:00
Sebastian Ullrich
c54f9dd8c8 feat: "slice" patterns [$x, $y, $zs,*, $w] in syntax match
/cc @leodemoura
2020-12-21 15:29:46 +01:00
Sebastian Ullrich
fdbec9101f fix: pattern reordering in syntax match 2020-12-20 13:52:25 +01:00
Sebastian Ullrich
efc2b79aba feat: as patterns in syntax match
@leodemoura no problem using the new architecture :)
2020-12-19 22:03:37 +01:00
Sebastian Ullrich
29c2023410 fix: adapt to new matchAlt syntax 2020-12-16 18:52:56 +01:00
Sebastian Ullrich
8dfa588983 feat: introduce SepArray and use it for sepBy antiquotation splices 2020-12-12 16:02:15 +01:00
Sebastian Ullrich
9e06680541 chore: remove old antiquotations splice syntax 2020-12-12 14:57:14 +01:00
Sebastian Ullrich
a13f129312 feat: antiquotation suffix splices such as $x:k,*
/cc @leodemoura
2020-12-12 14:57:14 +01:00
Sebastian Ullrich
686a28fcc9 feat: allow do lifts inside unescaped antiquotations
/cc @leodemoura
2020-12-12 13:01:05 +01:00
Sebastian Ullrich
bf63c4c0d0 feat: make sure dynamic quotations can only be used for parsers of arity 1 2020-12-11 21:34:30 +01:00
Sebastian Ullrich
591392840c fix: accept dynamic quotations in match 2020-12-11 21:34:30 +01:00
Sebastian Ullrich
00e167b2f0 feat: match_syntax ~> match 2020-12-08 17:20:36 +01:00
Sebastian Ullrich
6fc03d0f29 feat: quotation scopes in match_syntax 2020-12-08 17:13:32 +01:00
Sebastian Ullrich
b12be950bf feat: support complex antiquotations in antiquotation scopes 2020-12-08 17:13:32 +01:00
Sebastian Ullrich
d7f27a140e feat: antiquotation scopes 2020-12-04 19:24:32 +01:00
Leonardo de Moura
10c32fcf94 chore: HasToString => ToString 2020-10-27 16:11:48 -07:00
Leonardo de Moura
db9e390b4d chore: remove new_frontend from tests 2020-10-25 09:16:38 -07:00
Leonardo de Moura
a0a724ddbd fix: tests and elabDo 2020-09-26 19:12:01 -07:00
Sebastian Ullrich
986bb17e34 test: remove broken test case 2020-09-17 08:12:28 -07:00
Leonardo de Moura
32e26799ed chore: move more tests to new frontend 2020-09-13 13:28:12 -07:00
Sebastian Ullrich
eb5a171764 feat: adjust semantics to new syntax 2020-08-19 09:56:23 -07:00
Leonardo de Moura
17b6957f6c chore: fix tests 2020-05-26 15:05:01 -07:00
Sebastian Ullrich
bece6f7a32 feat: command quotations 2020-01-06 10:09:26 -08:00
Sebastian Ullrich
6fc47e4baf fix: match_syntax should not check kind of anonymous antiquotations 2019-12-30 08:24:29 -08:00
Sebastian Ullrich
881e3bf490 fix: raise precedence inside antiquotation parser 2019-12-30 08:24:29 -08:00
Sebastian Ullrich
81381d5c77 feat: make all antiquotation kinds optional 2019-12-30 08:24:29 -08:00