Commit graph

104 commits

Author SHA1 Message Date
Sebastian Ullrich
b69060f350 fix: category quotations in term position 2020-12-29 11:16:34 +01:00
Sebastian Ullrich
ca3dd82ed4 doc: notations & precedence 2020-12-28 00:44:16 +01:00
Leonardo de Moura
f638269a71 fix: name resolution at syntax command
This commit also cleans up `toParserDescr`+`toParserDescrAux`.
2020-12-22 08:40:00 -08:00
Sebastian Ullrich
1c31240ebb feat: token antiquotations in macro 2020-12-22 13:11:04 +01:00
Leonardo de Moura
43255a4af3 feat: local and scoped macros 2020-12-21 17:08:25 -08: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
Sebastian Ullrich
f9dcbbddc4 refactor: remove optional leading pipe from match, use many1Indent instead of sepBy1 2020-12-16 18:27:05 +01:00
Leonardo de Moura
31e1851b21 fix: priority 2020-12-15 21:10:02 -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
abe7481453 feat: elaborate prio DSL 2020-12-14 16:25:10 -08:00
Leonardo de Moura
fcaf38d566 fix: handle prec DSL at infixl macro 2020-12-14 15:35:37 -08:00
Leonardo de Moura
a46505cb8b feat: use new precedence syntax 2020-12-14 15:14:03 -08:00
Sebastian Ullrich
0316c872b9 feat: macro: use appropriate antiquotation kind dependent on bound syntax
/cc @leodemoura
2020-12-14 13:54:34 +01:00
Sebastian Ullrich
554d0b4d4c chore: adapt stdlib to new antiquotation splices 2020-12-12 17:20:03 +01: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
Leonardo de Moura
a10328e745 chore: simplify syntax patterns using $[...]? 2020-12-09 17:06:19 -08:00
Sebastian Ullrich
4dfa7e1187 feat: use actual separator in sepBy antiquotation scope 2020-12-09 17:48:05 +01:00
Sebastian Ullrich
fd1f74c421 feat: extend sepBy syntax syntax 2020-12-09 17:36:29 +01:00
Sebastian Ullrich
e6493755e9 chore: stdlib: match_syntax ~> match 2020-12-08 17:32:02 +01:00
Sebastian Ullrich
00e167b2f0 feat: match_syntax ~> match 2020-12-08 17:20:36 +01:00
Sebastian Ullrich
93a9d79088 refactor: move around quotation helpers once more 2020-12-08 17:20:36 +01:00
Leonardo de Moura
44d0fe993a feat: ensure scoped instances cannot be used outside namespaces 2020-12-05 16:26:31 -08:00
Leonardo de Moura
1faed06dc1 feat: new attrKind syntax 2020-12-05 13:59:08 -08:00
Leonardo de Moura
d43a65aed0 feat: elaboarate local syntax, infix and notation commands 2020-12-05 08:05:40 -08:00
Leonardo de Moura
aad8ea9c76 feat: stable parser names
```
syntax term "+" term : term              -- generates `term_+_`
syntax "[" sepBy(term, ", ") "]"  : term -- generates `term[_,]`
syntax "done" : tactic                   -- generates `tacticDone`
```

cc @Kha
2020-12-04 18:00:51 -08:00
Leonardo de Moura
0749cb9fa9 fix: avoid artificial hierarchical name at parser declarations 2020-12-04 16:22:43 -08:00
Leonardo de Moura
5a772c6cae feat: expand scoped notation into scoped attribute modifier 2020-12-04 11:39:00 -08:00
Leonardo de Moura
9d304df757 feat: heterogeneous Append experiment
@Kha This one required a bunch of manual fixes. The main issue is that
before we added the string interpolation feature, we created
`MessageData`s using `++` and coercions. For example, given
`(e : Expr)`, we would write
```
let msg : MessageData := "type: " ++ e
```
and rely on the coercions `String -> MessageData` and
`Expr -> MessageData`, and the instance `Append MessageData`.
However, heterogeneous operators "block" the expected type propagation downwards.
This kind of code is obsolete now since we can write a more compact
version using string interpolation
```
let msg := m!"type: {e}"
```
2020-12-01 16:32:41 -08:00
Sebastian Ullrich
d18596d4ca feat: add Unexpander for delaborating without importing Lean, use for simple notations
/cc @leodemoura
2020-12-01 11:57:20 -08:00
Sebastian Ullrich
4843f933fa feat: mkAntiquotNode 2020-12-01 11:57:20 -08:00
Leonardo de Moura
e9069b6965 feat: expand optional priority at notation and mixfix commands 2020-11-29 08:22:47 -08:00
Leonardo de Moura
0869f38de4 chore: update structure, class, inductive 2020-11-27 15:09:30 -08:00
Leonardo de Moura
91dca53274 refactor: remove MonadIO
There is no reason for having `MonadIO` anymore. The `MonadLift` type
class is well behaved in the new frontend, the `MonadFinally` solves
the problem at monad stacks such as `ExcepT e IO`.

This commit also changes the type of the IO printing functions.
For example, the type of `IO.println` was
```
def IO.println {m} [MonadIO m] {α} [ToString α] (s : α) : m Unit
```
and now it is just
```
def IO.println {α} [ToString α] (s : α) : IO Unit
```
We rely on the new frontend auto-lifting feature.
That is, if there is an instance `[MonadLiftT IO m]`, then
a term of type `IO a` is automatically coerced to `m a`

We also want a simpler `IO.println` for writing tests.
For example,
```
```
doesn't work because there isn't sufficient information for inferring
the parameter `m` in the previous `IO.println`.
The shortest workaround looked very weird
```
```

I considered adding `IO` as a default value for `m` when we have
`MonadIO m`, as we use `Nat` as the default for `ofNat a`, but it felt
like uncessary complexity.

@Kha The commit seems to work well. The auto-lifting featuring has
been working great for me. There is still room for improvement.
For example, given `MonadLiftT m n`, it doesn't automatically lift
`a -> m b` into `a -> n b`. So, code such as
`foo >>= IO.println`
had to be rewritten as
`foo >>= fun x => IO.println x`
I will add this feature later.
If you have time, please try to play with this feature and figure out
if it is stable enough for making it the default.
That is, if it roboust enough, we can stop using the following idiom
for writing functions that can be lifted automatically.
```
def instantiateLevelMVarsImp (u : Level) : MetaM Level :=
  ...

def instantiateLevelMVars {m} [MonadLiftT MetaM m] (u : Level) : m Level :=
  liftMetaM $ instantiateLevelMVarsImp u
```
I think we only need this idiom when using `MonadControlT` which is
not as common as `MonadLiftT`.
2020-11-18 18:47:22 -08:00
Leonardo de Moura
64669f4562 chore: refine heuristic for automatically marking the first symbol in tactic notation as non-reserved 2020-11-17 13:32:00 -08:00
Leonardo de Moura
da23b96b43 feat: improve error messages for syntax command 2020-11-17 10:33:53 -08:00
Leonardo de Moura
70385b87fa feat: add instance MonadRef MacroM 2020-11-13 16:00:31 -08:00
Leonardo de Moura
71f62fe5cb feat: use ParserDescr.nodeWithAntiquot at syntaxAbbrev 2020-11-13 16:00:31 -08:00
Leonardo de Moura
98ca335a85 chore: fix comment 2020-11-13 16:00:31 -08:00
Leonardo de Moura
51d0579e20 fix: bug at toParserDescr 2020-11-13 16:00:31 -08:00
Leonardo de Moura
bd76458210 feat: add support for nonReservedSymbol at syntax command 2020-11-12 07:32:18 -08:00
Leonardo de Moura
6fbaea6563 feat: simplify syntax command syntax 2020-11-12 07:01:20 -08:00
Leonardo de Moura
3bfc5248ca chore: ParserDescrNew => ParserDescr 2020-11-11 18:57:49 -08:00
Leonardo de Moura
ba9a06dfc9 feat: compact ParserDescr 2020-11-11 18:52:26 -08:00
Leonardo de Moura
df5b7fdc24 chore: naming convention
Use namespaces (e.g., `mkStxLit` ==> `Syntax.mkLit`)

cc @Kha
2020-11-11 09:55:23 -08:00
Leonardo de Moura
029510d4f5 feat: syntax for setting allowTrailingSep
@Kha This commit allows us to set `allowTrailingSep` for `sepBy` and
`sepBy1` from the `syntax` command.
```lean
syntax "[" (sepBy (allowTrailingSep := true) term ",") "]" : term
```
The new syntax is a bit verbose :)
What do you think? Any suggestions?
2020-11-08 08:12:54 -08:00
Leonardo de Moura
d618bf5b16 feat: expand new syntax Syntax 2020-11-08 07:22:38 -08:00
Leonardo de Moura
2d2d39c78e chore: use mut 2020-11-07 17:32:13 -08:00
Leonardo de Moura
81d6e065e7 chore: adjust files and tests 2020-11-07 17:32:12 -08:00