Commit graph

69 commits

Author SHA1 Message Date
Leonardo de Moura
5cfa13d08b fix(library/init/lean/parser/parser): consume whitespace in the beginning of the input 2019-07-08 14:13:50 -07:00
Leonardo de Moura
f66f6fd455 fix(library/init/lean/parser/parser): The first tokens of try p are the first tokens of p 2019-07-08 13:46:19 -07:00
Leonardo de Moura
d3ca360e7f feat(library/init/lean/parser): depArrow proof of concept 2019-07-08 10:49:54 -07:00
Leonardo de Moura
e2bcf179ac fix(library/init/lean/parser/parser): missing trim 2019-07-08 10:33:51 -07:00
Leonardo de Moura
8b3d932212 chore(library/init/lean/parser): maxPrec ==> appPrec 2019-07-08 09:17:32 -07:00
Leonardo de Moura
9334f54b87 feat(library/init/lean/parser/parser): support for whitespace sensitive left binding power
We use this new feature to implement array access notation `a[i]`.
2019-07-07 07:21:10 -07:00
Leonardo de Moura
794edcb18c chore(library/init/lean/parser): minor modifications 2019-07-05 18:31:03 -07:00
Leonardo de Moura
ee5ec98fa9 feat(library/init/lean/parser/parser): add symbolNoWs trailing parser 2019-07-05 16:22:36 -07:00
Leonardo de Moura
dca0ba60fa feat(library/init/lean/parser/parser): add fieldIdx parser
We should not use `numLit` for projections since it will parse
`p.1.2` as
```
Term.proj `p (numLit "1.2")
```
2019-07-05 15:07:51 -07:00
Leonardo de Moura
e3c75d2af6 fix(library/init/lean/parser/parser): position information for strLit, numLit, ident 2019-07-05 12:07:37 -07:00
Leonardo de Moura
24f9cd9564 chore(library/init/lean/parser/parser): minor 2019-07-05 11:23:45 -07:00
Leonardo de Moura
70fbf58c50 fix(library/init/lean/parser/parser): bug at identFnAux 2019-07-05 10:46:20 -07:00
Leonardo de Moura
ea6eee516b chore(frontends/lean): use => instead of := in match-expressions
Motivation: use same separator used in lambda expressions as in
other programming languages.
2019-07-04 11:38:38 -07:00
Leonardo de Moura
56007d7c97 feat(library/init/lean/parser/parser): display builtinParser name when updateTokens fails 2019-07-02 16:06:39 -07:00
Leonardo de Moura
a02443d23d chore(frontends/lean): fun x, e ==> fun x => e 2019-07-02 13:22:11 -07:00
Leonardo de Moura
6841e47aa4 chore(frontends/lean/builtin_exprs): remove support for (<infix>) and (<infix> <expr>) notations
In Lean 4, we will support the more general

`a + ·` ==> `fun x, a + x`
`· + b` ==> `fun x, x + b`
`· + ·` ==> `fun x y, x + y`
`f · y` ==> `fun x, f a y`
`g · · b` ==> `fun x y, g x y b`
2019-07-02 08:06:06 -07:00
Leonardo de Moura
ee2d3faa63 feat(library/init/lean/parser/parser): change optional p behavior
It ignores error only if `p` does not consume any input. This change
improves the quality of the error messages. The previous behavior can be
obtained by using `optional (try p)`.
2019-07-02 07:52:22 -07:00
Leonardo de Moura
9d50b3ca47 feat(library/init/lean/parser/term): paren parser 2019-07-01 19:44:13 -07:00
Leonardo de Moura
13b5747713 fix(library/init/lean/parser/parser): prattParser 2019-07-01 16:00:58 -07:00
Leonardo de Moura
5691450b5b feat(library/init/lean/parser): term parser skeleton 2019-07-01 15:04:13 -07:00
Leonardo de Moura
24647cb7cb fix(library/init/lean/parser/parser): better representation for many1 Syntax node 2019-06-30 09:02:06 -07:00
Leonardo de Moura
531ef5d700 feat(library/init/lean/parser): universe level parser and bug fixes 2019-06-30 09:02:06 -07:00
Leonardo de Moura
91e1d30cf8 feat(frontends/lean/builtin_exprs): use ; in do-notation 2019-06-27 18:00:43 -07:00
Leonardo de Moura
ab487ea4ac feat(frontends/lean): allow ; instead of in in let-decls 2019-06-27 17:12:03 -07:00
Leonardo de Moura
2e01ac508a feat(library/init/lean/syntax): primitives for creating and testing string and nat literals 2019-06-25 10:39:23 -07:00
Leonardo de Moura
da09ef4f66 feat(frontends/lean/builtin_exprs): minor improvement 2019-06-24 15:48:11 -07:00
Leonardo de Moura
8f1345dc53 chore(library/init/lean/syntax): simplify SyntaxNodeKind 2019-06-21 14:24:44 -07:00
Leonardo de Moura
0fe8fd1307 feat(library/init/lean/parser/parser): notation 2019-06-21 14:20:22 -07:00
Leonardo de Moura
bc9e460f62 fix(library/init/lean/compiler/ir): collectUsedDecls must take initialization functions into account
Move builtin parser level to its own directory
2019-06-21 13:34:42 -07:00
Leonardo de Moura
93e5746739 chore(library/init/lean/parser/parser): naming consistency 2019-06-20 16:47:55 -07:00
Leonardo de Moura
98879f1580 refactor(library/init/lean/parser/parser): simplify SyntaxNodeKind
The numeric `id` generation is works well for builtin parsers, but it
creates problems when defining dynamic ones.
2019-06-20 14:51:59 -07:00
Leonardo de Moura
8724a8cfd5 feat(library/init/lean/parser/parser): builtin parser attributes must be applied after compilation 2019-06-20 09:22:03 -07:00
Leonardo de Moura
d7fb0aa908 feat(library/init/lean/parser/parser): simpler cache
cc @kha
2019-06-19 16:48:18 -07:00
Leonardo de Moura
f180b3f32e feat(library/init/lean/parser/parser): improve error messages on prattParser 2019-06-19 16:36:18 -07:00
Leonardo de Moura
4db487fb42 fix(library/init/lean/parser/parser): sepBy1 2019-06-19 16:34:49 -07:00
Leonardo de Moura
cf9a29152d fix(library/init/lean/parser/parser): ParserInfo for ident, strLit, and numLit 2019-06-19 16:19:00 -07:00
Leonardo de Moura
401de35b6c chore(library/init/lean/parser/parser): remove unnecessary import
It turns out we don't need evalConst for implementing `builtinParsers`.
2019-06-19 10:53:51 -07:00
Leonardo de Moura
5f014415a9 feat(library/init/lean/parser/parser): add helper functions for invoking builting parsers
TODO: add scoped attributes for dynamically extending parsers.
2019-06-19 10:48:19 -07:00
Leonardo de Moura
89dae7f877 fix(library/init/lean/parser/parser): missing result 2019-06-19 10:33:53 -07:00
Leonardo de Moura
697f69020f fix(library/init/lean/parser/parser): new registerBuiltinParserAttribute
It is still broken since we apply attributes before we compile code.

Recall that attributes such as `@[export]` and `@[extern]` must be applied before we
compile code.

On the other hand, any attribute `attrName`
```
@[attrName] def foo := ...
```
which creates auxiliary definitions that depend on `foo` must be applied
AFTER we generate code for `foo`. Otherwise, we will fail to compile the
auxiliary definition since we don't have code for `foo` yet.

I will fix the issue above by allowing attributes to specify when they
should be applied. I will start with only two options: before and after
code compilation. In the future, we may need more options (e.g., before
elaboration), but I don't see the need yet.

cc @kha
2019-06-19 09:52:56 -07:00
Leonardo de Moura
444d942b1c fix(library/init/lean/parser/parser): bootstrapping/initialization issue
`evalConst` was being invoked "too early".
2019-06-18 11:27:37 -07:00
Leonardo de Moura
14e902cf8e feat(library/init/lean/parser): register builtin parsing tables 2019-06-18 09:25:10 -07:00
Leonardo de Moura
03ca8734f3 feat(library/init/lean/parser/parser): add runParser for testing 2019-06-18 09:01:58 -07:00
Leonardo de Moura
b558ac424f feat(library/init/lean/parser/parser): add prattParser 2019-06-18 08:37:15 -07:00
Leonardo de Moura
e9535e5792 feat(library/init/lean/parser/parser): add longestMatch combinator 2019-06-18 08:07:46 -07:00
Leonardo de Moura
e9b877c334 feat(library/init/lean/parser/parser): add registerBuiltinParserAttribute 2019-06-17 16:49:44 -07:00
Leonardo de Moura
a495a4ce86 feat(library/init/lean/parser/parser): new parser combinators based on tests/playground/parser
Main differences with respect to `tests/playground/parser`

1- There is a single (parametric) parser type: `Parser k`, where `k` is
   used to identify whether it is a `nud` or `led` parser.
2- It assumes parsing tables are stored in the `Environment`.
3- We check precedence mismatch, and use the value `none` to represent
   "use existing precedence".
4- We have support for silent (aka epsilon) parsing actions.

Remark: the experiments at `tests/playground/parser` demonstrated that the new
parsing infrastructure is at least 10x faster than the one based on the
`Parsec` monad.
2019-06-17 13:29:01 -07:00
Leonardo de Moura
1bae8f8eab refactor(library/init/lean/ir/parser): parser.lean => parser_t.lean 2018-06-05 08:00:13 -07:00
Sebastian Ullrich
0f7c0ac8bf feat(init/lean/parser/parser): make a monad transformer
Also move parser combinators into the more specific namespace `init.lean.parser.parser_t`.
2018-06-04 12:57:23 +02:00
Leonardo de Moura
3f883bd949 chore(library/init/lean/parser/parser): add monad_fail instance 2018-05-09 09:19:14 -07:00