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
Leonardo de Moura
d5fe509c36
chore(*): remove end after each match-expression
...
`end` is not optional anymore
2018-05-04 11:30:06 -07:00
Leonardo de Moura
0d49ae3f69
feat(library/init/lean/parser): add not_followed_by and not_followed_by_sat
...
The new parsers are useful to implement the longest match rule.
2018-05-02 15:55:57 -07:00
Leonardo de Moura
f44bfb3e59
feat(library/init/lean/parser/parser): use dlist to implement expected messages
...
The idiom `p1 <|> p2 <|> ... <|> pn` generates many append operations.
`dlist` provides an O(1) append.
2018-05-02 12:43:21 -07:00
Leonardo de Moura
4d6cbf62a2
refactor(library/init/lean/parser/parser): we don't need to store the whole message in ok_eps
...
In the original parsec paper, they store messages in OK silent/epsilon
results too. This is not necessary, we only need the "expected" field
for the `ok_eps` constructor.
2018-05-02 11:37:57 -07:00
Leonardo de Moura
6672cc2a34
fix(library/init/lean/parser/parser): bug
2018-05-01 17:15:12 -07:00
Leonardo de Moura
ffdc6cca8a
refactor(library/init/lean/ir): move reserved set to different file
2018-05-01 15:27:25 -07:00
Leonardo de Moura
263391bdbb
refactor(library/init/lean): add init/lean/parser/identifier
2018-05-01 11:53:55 -07:00
Leonardo de Moura
7305a7a65e
feat(library/init/lean): identifier parser
2018-05-01 10:29:34 -07:00
Leonardo de Moura
ba8b85f4c0
chore(library/init/lean/parser/parser): adjust variable names
2018-04-30 16:36:09 -07:00
Leonardo de Moura
485b16a413
feat(library/init/lean/parser/syntax): use position
2018-04-30 16:13:01 -07:00
Leonardo de Moura
9879cb46be
feat(library/init/lean/parser/parser): store offset in error messages
2018-04-30 16:08:52 -07:00
Leonardo de Moura
12f2831f9f
test(tests/lean/parser1): add parser tests
2018-04-28 15:58:50 -07:00
Leonardo de Moura
65c7426174
chore(library/init/lean/parser/parser): parser_m ==> parser
...
Use the same name convention used at `init/control`
2018-04-27 13:44:37 -07:00
Leonardo de Moura
6f0296c757
feat(library/init/lean/parser/parser): add faster take* combinators
...
They are much faster than the more general `many*` combinators.
2018-04-27 13:39:19 -07:00
Leonardo de Moura
3f812698a9
feat(library/init/lean/parser/parser): fast str combinator
2018-04-27 13:39:19 -07:00
Leonardo de Moura
f950965614
fix(library/init/lean/parser/parser): bug
2018-04-27 13:39:19 -07:00
Leonardo de Moura
77d3a788e8
refactor(init): init/category ==> init.control
2018-04-27 08:33:08 -07:00
Leonardo de Moura
8b442101af
chore(library/init/lean/parser/parser): add prelude
2018-04-27 08:16:20 -07:00
Leonardo de Moura
c427fb4086
refactor(*): create library/init/lean folder
...
The new folder will contain the new parser, macro expander and compiler.
This commit also renames the namespace for the old parser `lean3.parser`
2018-04-27 08:02:40 -07:00