Commit graph

17020 commits

Author SHA1 Message Date
Leonardo de Moura
1636083cae fix(library/init/lean/parser/parser): typo 2019-07-15 14:07:27 -07:00
Leonardo de Moura
12346d344a feat(shell/lean): invoke new parser when --new-frontend is used 2019-07-15 13:57:05 -07:00
Leonardo de Moura
367f28e90b chore(library/init/lean/parser/module): export test function 2019-07-15 13:39:56 -07:00
Leonardo de Moura
a8c36d4c29 feat(library/init/lean/syntax): remove MacroScopes
We are going to use a simpler approach to help users writing hygienic
macros. Suppose we have a syntax quotation such as
```
`(let x := %%a;
  ite x x %%b)
```
We will parse this quotation, and during elaboration, we must create
code (i.e., an `Expr`) such that given `a` and `b`, it constructs
a (new) syntax object, and we want to guarantee that there is no accidental name capture.
So, given the syntax object `S` representing the quotation above, we
first pre-resolve the identifiers in `S`. In this step, we annotate the
identifier `ite` with the global declaration `_root_.ite`.
Then, we create a fresh identifier for each identifier, but we would
preserve the pre-resolved information.
Assume the monadic action `mkFresh <id>` creates a fresh identifier with
prefix `<id>`, and `mkFreshWithPreresolved <id> <pre-list>` creates a
fresh identifier with prefix <id> and pre-resolved list `<pre-list>`.
Then, the quotation above would be transformed into:
```
let x := mkFresh `x;
let ite := mkFreshWith `ite [`_root_.ite];
`(let %%x := %%a;
 %%ite %%x %%x %%b)
```
Here, the new quotation is just syntax sugar for a sequence of `Syntax`
constructor applications. Now, whenever we want to create a syntax
object using the quotation above, we guarantee there is no accidental
name capture because we are creating a fresh identifier for all
identifiers in the quotation. Global references are preserved using the
field preresolved that we already have.
It is straightforward to implement the transformation above using a
mapping. Note that if we use the same mapping to elaborate two different
quotations, we are essentially saying they share the same scope.
For example, suppose we have
```
let c := `(ite x x %%b);
`(let x := %%a; %%c)
```
If we use the same mapping, we produce
```
let x := mkFresh `x;
let ite := mkFreshWith `ite [`_root_.ite];
let c := `(%%ite %%x %%x %%b);
`(let %%x := %%a; %%c)
```
If we create a new mapping when compiling each quotation, we get
```
let x := mkFresh `x;
let ite := mkFreshWith `ite [`_root_.ite];
let c := `(%%ite %%x %%x %%b);
let x1 := mkFresh `x;
`(let %%x1 := %%a; %%c)
```
which is probably not what the user wants.
We can provide a simple notation for users specifying which behavior
they want. The default may be super simple. Example: we have a new mapping (aka scope) per declaration.
The approach above is simple and efficient. It is also great for
users that want to create syntax objects during the elaboration phase
and want to avoid name capture.
2019-07-15 10:00:27 -07:00
Leonardo de Moura
4c3ea024bc chore(stage0): update 2019-07-15 09:46:39 -07:00
Leonardo de Moura
146a796c5c feat(library/init/lean/module): add ModuleParser with error recovery 2019-07-15 09:32:13 -07:00
Leonardo de Moura
6a47055850 feat(library/init/lean/parser/parser): improve orelse error message 2019-07-15 09:31:37 -07:00
Leonardo de Moura
0b590dbd4d chore(library/init/lean/environment): add note stating that addImportedFn must have support for failure
We need this feature when importing "conflicting" parser extensions.
Example: parsers in different modules that assign different binding
powers to different tokens.
2019-07-14 08:50:47 -07:00
Leonardo de Moura
b9149dd428 fix(library/init/lean/parser/module): token table initialization 2019-07-14 08:31:12 -07:00
Leonardo de Moura
d588d39786 fix(library/init/lean/parser): use symbolOrIdent when parsing max and imax 2019-07-14 08:22:07 -07:00
Leonardo de Moura
f8fba6877b fix(library/init/lean/parser/parser): add ident as possible first token for symbolOrIdent 2019-07-14 08:19:42 -07:00
Leonardo de Moura
1dce4a8f70 feat(library/init/lean/parser/parser): add symbolOrIdent 2019-07-14 08:09:04 -07:00
Leonardo de Moura
a843c0be55 feat(library/init/lean/parser/parser): shared TokenTable 2019-07-14 07:53:24 -07:00
Leonardo de Moura
52157cebf7 feat(library/init/lean/parser): add ParserAttribute skeleton 2019-07-14 07:16:14 -07:00
Leonardo de Moura
18ab2be51c feat(library/init/lean/environment): use Thunk to store environment extension initial state 2019-07-13 13:58:20 -07:00
Leonardo de Moura
e3351f0524 test(tests/playground/modtest1): new test 2019-07-12 17:03:22 -07:00
Leonardo de Moura
e4c9326c00 feat(library/init/lean/parser): add module.lean 2019-07-12 16:42:25 -07:00
Leonardo de Moura
728598520b chore(library/init/lean/parser/term): add new parser! and tparser! notations 2019-07-12 15:51:10 -07:00
Leonardo de Moura
070fe8c00a chore(library/init/core): avoid unnecessary notation
Motivation: simplify transition to new parser.
2019-07-12 14:24:46 -07:00
Leonardo de Moura
d59d8e0d56 feat(library/init/lean/parser/command): add notation command 2019-07-12 14:18:08 -07:00
Leonardo de Moura
d7a60c0b7f chore(library/init): temporarily disable unquoted symbols 2019-07-12 14:07:33 -07:00
Leonardo de Moura
36da73b6cb feat(library/init/lean/parser/command): add (some) notation commands 2019-07-12 14:01:23 -07:00
Leonardo de Moura
151735d356 chore(library/init/lean/parser/parser): remove testParser 2019-07-12 13:57:56 -07:00
Leonardo de Moura
166a6fa75a feat(library/init/lean/parser/command): missing commands 2019-07-12 11:00:14 -07:00
Leonardo de Moura
7046a38e93 feat(library/init/lean/parser/command): add inductive, structure and class parsers 2019-07-12 10:21:59 -07:00
Rob Dockins
a9ebf23fab fix(libraray/init/data): generalize universe variables in array and persistent array operations
This change allows the monadic traversal operations on arrays to use monads that
are defined to raise universe levels.  This happens, for example, when defining
monads using certain continuation-passing idioms.
2019-07-11 17:52:04 -07:00
Leonardo de Moura
8751f68041 feat(library/init/lean/parser/command): more decl commands 2019-07-11 17:42:11 -07:00
Leonardo de Moura
49d5c83a18 feat(library/init/lean/parser/command): add abbrev 2019-07-11 17:30:29 -07:00
Leonardo de Moura
eed4c72fc5 fix(library/init/lean/parser/command): docComment 2019-07-11 17:28:51 -07:00
Leonardo de Moura
72477f3cc6 feat(library/init/lean/parser/command): improve how optional affects firstTokens field 2019-07-11 17:22:26 -07:00
Leonardo de Moura
d354dc437c feat(library/init/lean/parser/command): add declaration draft 2019-07-11 17:13:22 -07:00
Leonardo de Moura
1b8c2200d5 chore(stage0): update 2019-07-11 16:45:09 -07:00
Leonardo de Moura
05a3bab321 feat(library/init/lean/parser): add command.lean 2019-07-11 16:43:44 -07:00
Leonardo de Moura
2f60132610 test(tests/compiler/termparsertest1): new test 2019-07-11 13:16:25 -07:00
Leonardo de Moura
3370ab7398 feat(library/init/lean/parser/term): allow equations to be used in let-decls 2019-07-11 13:13:08 -07:00
Leonardo de Moura
99393433a4 feat(library/init/lean/parser/term): do notation 2019-07-11 12:38:55 -07:00
Leonardo de Moura
711ab9f222 feat(library/init/lean/parser/term): missing notation 2019-07-11 10:34:49 -07:00
Leonardo de Moura
7c53be5df7 chore(library/init): remove remaining set notation 2019-07-11 10:31:25 -07:00
Leonardo de Moura
295cabed2e chore(library/init): remove unnecessary notations 2019-07-11 10:27:16 -07:00
Leonardo de Moura
57e2f1be2a feat(library/init/lean/parser/term): builtin operators 2019-07-11 10:13:00 -07:00
Leonardo de Moura
195fb27ce5 feat(library/init/lean/parser/term): add let 2019-07-11 09:51:34 -07:00
Leonardo de Moura
7b91d880d7 feat(library/init/lean/parser/term): add sortApp, inaccessible and explicit 2019-07-11 09:05:21 -07:00
Leonardo de Moura
2c979459a9 feat(library/init/lean/parser/parser): add many1Indent1 combinator
It is useful for create whitespace sensitive notation such as `match` expressions.
2019-07-10 16:10:41 -07:00
Leonardo de Moura
140cc45491 feat(library/init/lean/parser/term): whitespace sensitive match expression 2019-07-10 15:13:28 -07:00
Leonardo de Moura
f95ed02999 feat(library/init/lean/parser/parser): add withPosition and checkColGe parsers 2019-07-10 15:11:54 -07:00
Leonardo de Moura
3ef8845163 chore(tests/playground): fix tests 2019-07-10 11:36:39 -07:00
Leonardo de Moura
c9cd693b8e feat(runtime/object): avoid recursion at mark_mt and mark_persistent
Reason: potential stack overflows
2019-07-10 11:27:49 -07:00
Leonardo de Moura
a85a98f1ec chore(stage0): update 2019-07-10 11:19:40 -07:00
Leonardo de Moura
022d22cac4 feat(library/compiler/extract_closed): fine grain extraction
Motivation: increase reuse
2019-07-10 11:14:20 -07:00
Leonardo de Moura
efa48d6762 chore(stage0): update 2019-07-10 11:11:53 -07:00