Commit graph

21204 commits

Author SHA1 Message Date
Leonardo de Moura
41e6447837 refactor: use MetaM and exceptions 2020-09-22 16:05:28 -07:00
Leonardo de Moura
25bcc95b13 feat: construct brecOn application
TODO: replace recursive application with `below` argument
2020-09-22 14:39:22 -07:00
Leonardo de Moura
0511b73d80 feat: add replaceFVars 2020-09-22 14:24:03 -07:00
Leonardo de Moura
bbc1f4d461 fix: throwAppTypeMismatch should be polymorphic
We use it from `TermElabM` and `MetaM`, and they have different
`TermElabM` implementations.
2020-09-22 09:35:59 -07:00
Leonardo de Moura
05e5d934d3 feat: change default precedence for new syntax
Now, the following example produces a syntax error.
```lean
macro "foo!" x:term : term => `($x + 1)

check id foo! 10
```

@Kha, I think the heuristic is simple and defensible.
If the new syntax starts and ends with token, than the precedence is
`maxPrec`. Otherwise, it is `leadPrec`.

see #180
2020-09-21 19:04:03 -07:00
Leonardo de Moura
dc9626ceab feat: try to improve weird error message
@Kha Before this commit, we were producing the error "expected command" at the `let` token
```lean
check id let x := 1; x
```
The new error is "expected command, but found term; this error may be
due to parsing precedence levels, consider parenthesizing the term".

The example above looks artificial, but it will happen all the time as
users start to define their own notation.
2020-09-21 18:29:01 -07:00
Leonardo de Moura
1b358967ba chore: update stage0 2020-09-21 17:13:42 -07:00
Leonardo de Moura
f4b5ec710f fix: fixes #175 2020-09-21 17:12:07 -07:00
Leonardo de Moura
b0564a32b9 feat: add AttrM
We are going to use `AttrM` to implement solution 2 described at https://github.com/leanprover/lean4/issues/175
2020-09-21 16:44:20 -07:00
Leonardo de Moura
cab56d1e1b chore: do not invoke the hooks from addImported
@Kha I am working on issue
https://github.com/leanprover/lean4/issues/175

I am using solution 2 described there. The hooks will be at `AttrM`
instead of `CoreM`.

AFAICT code deleted by this commit is not necessary.
2020-09-21 16:28:07 -07:00
Leonardo de Moura
c19814a624 chore: avoid memory leak
@Kha I suspect the memory leaks reported at the CI are due to
an exception produced by the compiler.
The compiler is currently a mix of Lean and C++ code.
I think the exception was thrown from C++ code, crossed Lean code (producing
memory leaks), and was caught by the old frontend written in C++.

We will eventually replace the compiler C++ code with Lean code.
So, I think this is a low priority issue.
2020-09-21 13:30:58 -07:00
Leonardo de Moura
38df6de545 chore: update stage0 2020-09-21 12:28:20 -07:00
Leonardo de Moura
151e877513 refactor: seal EnvExtension type
The motivation is to prevent users from tinkering with its internal
implementation details that rely on unsafe features.
The new test crashed before this commit.
2020-09-21 12:24:44 -07:00
Leonardo de Moura
1f9f12975c chore: seal EnvExtensionState and EnvExtensionEntry 2020-09-21 11:48:57 -07:00
Leonardo de Moura
c9e902034d fix: typo 2020-09-21 11:44:26 -07:00
Leonardo de Moura
0de92b069f chore: move function 2020-09-21 08:58:41 -07:00
Leonardo de Moura
aa6d6c4dda feat: expose mkModuleInitializationFunctionName
cc @Kha

for https://github.com/leanprover/lean4/issues/185
2020-09-21 08:53:29 -07:00
Leonardo de Moura
30a1e0228b chore: add where to list of keywords 2020-09-21 08:27:29 -07:00
Sebastian Ullrich
f693e910b1 fix: skip minimum amount of tokens during parser recovery
Fixes #186
2020-09-21 11:37:50 +02:00
Leonardo de Moura
6a90fbf855 test: String interpolation
@Kha I wrote this extended test using the new frontend. The new
frontend worked great. I only had a minor issue with `#exit`.
The example uses `let rec`, parsers, macros, lift-method notation, etc.
It implements the new parser `strInterpolant p` for string
interpolation. The parser `p` is used to process the elements inside
`{...}`. Then, I use this parser to implement the macro `toString!`.
Example: `toString! "1+2 = {1+2}"` produces `"1+2 = 3"`.
Even the new "lift-method" notation works inside the string interpolant.
```lean
def g (x : Nat) : StateRefT Nat IO Nat := do
modify (· + x);
get

def ex : StateRefT Nat IO Unit := do
IO.println $ toString! ">> hello {(<- g 1)}";
IO.println $ toString! ">> world {(<- g 1)}";
pure ()
```
2020-09-20 18:11:19 -07:00
Leonardo de Moura
9eb978946c chore: add quotedCharCoreFn 2020-09-20 17:05:47 -07:00
Leonardo de Moura
241eabfc41 fix: non termination on ill-formed string literals 2020-09-20 17:05:18 -07:00
Leonardo de Moura
03a361edf4 feat: add initialize command parser 2020-09-20 13:42:50 -07:00
Leonardo de Moura
13abf0bd45 chore: update stage0 2020-09-20 09:17:12 -07:00
Leonardo de Moura
d33f7c7885 feat: attribute command 2020-09-20 09:11:36 -07:00
Leonardo de Moura
7d9118d2e2 feat: add resolveGlobalConst and resolveGlobalConstNoOverload 2020-09-20 08:54:24 -07:00
Leonardo de Moura
6ed69525ad chore: move functions to Environment namespace 2020-09-20 08:28:43 -07:00
Leonardo de Moura
ac2a9539f9 fix: old&new frontend interference
The new test was not working because new frontend was using old
frontend function.
2020-09-20 08:25:45 -07:00
Leonardo de Moura
d5cb3aa85a chore: add elabAttr
WIP
2020-09-20 07:51:11 -07:00
Leonardo de Moura
12acbaf392 doc: resolveGlobalName 2020-09-20 07:50:29 -07:00
Leonardo de Moura
6ac227a63c chore: elabAttrs, elabDeclAttrs 2020-09-20 07:39:14 -07:00
Leonardo de Moura
4786cb12b5 fix: unknown namespace error message 2020-09-20 07:10:23 -07:00
Leonardo de Moura
6aea344b32 chore: update stage0 2020-09-19 19:09:02 -07:00
Leonardo de Moura
d2ee641e7f chore: restore macro 2020-09-19 19:08:35 -07:00
Leonardo de Moura
3348e3c3a1 chore: update stage0 2020-09-19 19:05:14 -07:00
Leonardo de Moura
9fdef2e4eb fix: commands that expand into syntax 2020-09-19 19:04:21 -07:00
Leonardo de Moura
3a386a27a9 chore: update stage0 2020-09-19 19:00:46 -07:00
Leonardo de Moura
87381e3329 feat: add support for parser priorities in the syntax command
@Kha Parser priorities are working :)
2020-09-19 18:47:08 -07:00
Leonardo de Moura
f0ab743ad0 chore: remove temporary workaround 2020-09-19 18:00:45 -07:00
Leonardo de Moura
e52f50b2fb chore: update stage0 2020-09-19 17:55:57 -07:00
Leonardo de Moura
fe2d3be821 feat: parser priorities 2020-09-19 17:55:17 -07:00
Leonardo de Moura
3ee9cdd2dc doc: document issue
@Kha One possible fix: we store `currNamespace` and `openDecls` at `CoreM`.
The issue is similar to the one we had with the pretty printer.
2020-09-19 16:55:50 -07:00
Leonardo de Moura
3e42dac1ee chore: update stage0 2020-09-19 15:44:24 -07:00
Leonardo de Moura
f679b7d803 feat: add notFollowedBy to syntax 2020-09-19 15:43:44 -07:00
Leonardo de Moura
c43450f027 feat: macros for the syntax category
This is the last of a series of commits for adding this feature.
2020-09-19 15:00:41 -07:00
Leonardo de Moura
c2c57b4a5e chore: update stage0 2020-09-19 14:44:48 -07:00
Leonardo de Moura
ee6d723554 feat: add stx.quot 2020-09-19 14:40:17 -07:00
Leonardo de Moura
f876177f26 feat: expand macros in syntax declaration 2020-09-19 14:39:49 -07:00
Leonardo de Moura
17d4117637 chore: remove temporary hacks 2020-09-19 14:21:38 -07:00
Leonardo de Moura
a96e5d4bcd chore: update stage0 2020-09-19 14:17:10 -07:00