Commit graph

229 commits

Author SHA1 Message Date
Sebastian Ullrich
7fdfdb1784 chore(library/init/lean/parser): remove unnecessary class constraints 2018-11-06 21:45:08 +01:00
Sebastian Ullrich
090c4c0ce7 feat(library/init/lean/syntax): add lazily propagated macro scopes to syntax_node 2018-11-06 16:46:50 +01:00
Sebastian Ullrich
fc4dcd19cf refactor(library/init/lean/parser): use ident.view in syntax.to_format 2018-11-05 17:57:00 +01:00
Sebastian Ullrich
8c27f0aac6 refactor(frontends/lean/elaborator,library/init/lean): finish no_kind refactoring 2018-11-04 20:24:40 +01:00
Sebastian Ullrich
93fc1fd1de fix(library/init/lean/parser/combinators): node: do not wrap error in first argument 2018-10-30 17:43:05 +01:00
Sebastian Ullrich
74bd182bc8 perf(library/init/lean/parser/combinators): make node semireducible 2018-10-30 17:43:05 +01:00
Sebastian Ullrich
0d7ea62f9a perf(frontends/lean/elaborator,library/init/lean): put out_params first to benefit from instance pre-filtering 2018-10-30 17:43:05 +01:00
Sebastian Ullrich
2e0d6649be perf(library/init/lean/parser/basic): make basic_parser_m semireducible 2018-10-30 17:43:05 +01:00
Sebastian Ullrich
188ab30a9c fix(library/init/lean/parser/declaration): precedence for attribute arguments 2018-10-30 17:43:05 +01:00
Leonardo de Moura
cc3767e6a5 refactor(library/init/data): avoid indirection at rbmap
Now, the nodes in a `rbmap` contain the key and value, and we avoid
one level of indirection. `rbmap`s are more common than `rbtree`.
We implement `rbtree A` as `rbmap A unit`.
2018-10-26 17:14:09 -07:00
Leonardo de Moura
96ef30e827 chore(library/init/lean/parser/parsec): remove private
Motivation: allow us to change the attribute in other files
2018-10-25 10:55:32 -07:00
Leonardo de Moura
370f67b27b feat(library/init/lean/parser/parsec): mark *_mk_res functions as [inline_if_reduce] 2018-10-25 10:10:54 -07:00
Sebastian Ullrich
08d8856112 perf(library/init/lean/parser/token): replace longest_match in token with custom implementation 2018-10-22 22:33:58 +02:00
Sebastian Ullrich
163f996d00 perf(library/init/lean/parser): inline some trivial functions 2018-10-22 22:23:54 +02:00
Leonardo de Moura
19be59065a perf(library/init/lean/parser/parsec): mark bind_mk_res and orelse_mk_res with @[inline]
A few weeks ago, it was not feasible to inline `bind_mk_res` and
`orelse_mk_res` because the compilation time would increase a lot.
Since then I have improved the heuristics for deciding whether to float
`cases_on` or not.
So, I tried today to mark them with `@[inline]` again.
The corelib build time increased only 1.2 secs, but the `parser1.lean` runtime improved:
Before:
```
num. allocated objects:  18025367
num. allocated closures: 2988476
```
After:
```
num. allocated objects:  15774515
num. allocated closures: 2488695
```
I used my desktop to collect the numbers above.
2018-10-22 11:11:21 -07:00
Leonardo de Moura
89afabae29 refactor(library/init/lean/parser/parsec): make sure custom error message doesn't need to be inhabited 2018-10-21 10:57:23 -07:00
Leonardo de Moura
0f7745a3e0 feat(library/init/lean/parser/parsec): mark whitespace and num with [noinline]
We want them to be specialized for a given monad stack, but not
inlined. If we inline them, then every occurrence of `whitespace` and
`num` will specialize the nested `take_while?` application.
This is bad since we don't cache them.
2018-10-18 16:33:10 -07:00
Leonardo de Moura
677864dee5 feat(library/init/lean/parser/parsec): mark some of the parsec functions with @[specialize] 2018-10-18 16:23:47 -07:00
Leonardo de Moura
880137f0ed feat(library/init/lean/parser/basic): mark tokens with @[nospecialize] 2018-10-18 15:20:54 -07:00
Leonardo de Moura
38bc3beffb fix(library/init): alternative instances
Both `alternative` and `monad` implement `applicative`. However,
their default implementations for `seq_right` and `seq_left` are
different. The `alternative` implementation uses the inefficient default
version for `seq_right` available at `applicative`:
```
(seq_right := λ α β a b, const α id <$> a <*> b)
```
instead of the more efficient
```
(seq_right := λ α β x y, x >>= λ _, y)
```
defined at `monad` using the `bind` operator.

This commit makes sure the `applicative` instances for `reader_t`,
`state_t`, `option` and `parsec_t` use the efficient version.
I found the problem when inspecting the generated code for:
```
def symbol (s : string) : parsec' unit :=
(str s *> whitespace) <?> ("'" ++ s ++ "'")
```
2018-10-17 14:25:50 -07:00
Sebastian Ullrich
1d0456adf5 fix(library/init/lean/parser/term): revert refactoring that broke sort_apps of Type 2018-10-17 09:13:52 +02:00
Sebastian Ullrich
f29d886c29 fix(library/init/lean/parser/string_literal): letter escapes 2018-10-16 22:43:30 +02:00
Leonardo de Moura
88de81077c feat(library/compiler/specialize): do not specialize instances unless they are marked with [specialize]
@kha: I changed the specialization candidate selection procedure.
Now, instances are not considered for specializations unless we mark
them with `[specialize]`. The idea is that an instance application is
morally just creating the "dictionary" for invoking a polymorphic
function.
2018-10-15 18:29:29 -07:00
Leonardo de Moura
4cfe44bed0 feat(library/compiler/specialize): add nospecialize attribute
@kha I had to add this attribute because the specializer was generated
many specialization candidates for functions that take `[has_tokens ...]`
as an argument. Moreover, these candidates had a lot of
dependencies. I am trying to workaround this issue by marking the
instances with the new attribute `[nospecialize]`.
I did not mark instances created by `[derive]`. It is quite tedious to
do it.

BTW, when I was investigating the problem I stumbled at `node.view`.
Its type is:
```
node.view :
  Π {α : Type} {m : Type → Type} [_inst_1 : monad m] [_inst_2 : monad_except (parsec.message syntax) m]
  [_inst_3 : monad_parsec syntax m] [_inst_4 : alternative m] (k : syntax_node_kind) (rs : list (m syntax))
  [i : @has_view syntax_node_kind k α], @has_view (m syntax) (@node m _inst_1 _inst_2 _inst_3 _inst_4 k rs) α
```
This looks wrong: the view depends on `[monad_parsec syntax m]`

We should also make sure definitions do not have unnecessary type
class instances. Otherwise, we will put additional stress on the code
specializer. One option is to change the frontend and filter unused
instances.
2018-10-15 17:44:26 -07:00
Sebastian Ullrich
a820b9955f perf(library/init/lean/parser/term): index term parsers by leading token
66% speedup on core.lean
2018-10-15 10:21:08 +02:00
Sebastian Ullrich
2df885d9a3 fix(library/init/lean/parser/token): broken end of comment 2018-10-13 12:01:48 -07:00
Sebastian Ullrich
8a88d4d5e2 feat(library/init/lean/parser/token): string literals
hard-coded for now because we do not have general support for variable-length
tokens yet
2018-10-13 08:11:36 -07:00
Sebastian Ullrich
758d258210 fix(library/init/lean/parser/term): rename term.ident to ident_univs to remove confusion with ident
`protected` didn't do anything here
2018-10-13 08:11:36 -07:00
Leonardo de Moura
c0b76704a0 chore(library/init/lean/parser/level): typo 2018-10-12 11:56:34 -07:00
Leonardo de Moura
15a25d5aa9 chore(library/init/lean/parser): add a few comments 2018-10-11 15:54:57 -07:00
Sebastian Ullrich
8e0778e54a fix(library/init/lean/parser/token): parse whitespace after raw_ident 2018-10-08 09:30:48 -07:00
Sebastian Ullrich
4e3f9b46c2 refactor(library/init/lean/parser/token): remove weird with_source higher-order function 2018-10-05 08:52:04 -07:00
Sebastian Ullrich
ebeec844af perf(library/init/lean/parser): minor performance tweaks 2018-10-05 08:52:04 -07:00
Sebastian Ullrich
22714b9b10 perf(library/init/lean/parser/combinators): node: no need to fill up with syntax.missing anymore
Views now do iterated pattern matches instead of a single one
2018-10-04 14:27:24 -07:00
Sebastian Ullrich
959948b901 feat(library/init/lean): even more core.lean progress 2018-10-03 16:00:08 -07:00
Sebastian Ullrich
ca8e75be9e fix(library/init/lean/elaborator): check for and consume end of input 2018-10-03 16:00:08 -07:00
Sebastian Ullrich
5274be8c3e feat(library/init/lean/elaborator): local notation
Implemented by treating the parser cfg as a cache that can be recreated from the
elaborator state after e.g. a scope has ended
2018-10-03 16:00:08 -07:00
Sebastian Ullrich
0563c60b1a feat(library/init/lean/elaborator): add coroutine, use it to implement section/namespace elaborators (they don't do anything yet except for checking the end name) 2018-10-02 14:55:28 -07:00
Sebastian Ullrich
097b7be14f refactor(library/init/lean/parser/token): change raw view type to option syntax_atom and create raw_str to give some raw parsers view defaults 2018-10-02 14:55:28 -07:00
Sebastian Ullrich
533ac2d5b2 fix(library/init/lean/parser/declaration): attributes before visibility modifiers 2018-10-02 14:55:28 -07:00
Sebastian Ullrich
71fd8a59b4 feat(library/init/lean/parser/notation): simple term language for precedences 2018-10-02 14:55:28 -07:00
Sebastian Ullrich
b8b39585ec fix(library/init/lean/parser/command): variable may take unbracketed binder 2018-10-02 14:55:28 -07:00
Sebastian Ullrich
fc5120290f feat(library/init/lean/parser/term): inductive levels, let, structure instances 2018-10-02 14:55:28 -07:00
Leonardo de Moura
429f844fbe @chore(library/init/lean/parser/parsec): remove @[inline] annotations to reduce compilation time
We will mark them as `@[specialize]` as soon as we implement code specialization
2018-10-01 17:30:13 -07:00
Sebastian Ullrich
ab5460d010 perf(library/init/lean/parser/parsec): more [inline] attributes 2018-10-01 16:32:11 -07:00
Sebastian Ullrich
7d8c3c5db8 feat(library/init/lean/parser/term): use longest_match for Pratt parsing 2018-10-01 09:02:39 -07:00
Sebastian Ullrich
6a23ecfe9c fix(library/init/lean/parser/parsec): fix lookahead, longest_match 2018-10-01 09:02:39 -07:00
Sebastian Ullrich
b443006e8f fix(library/init/lean/parser/syntax): reprint: do not concatenate choice contents 2018-10-01 09:02:39 -07:00
Sebastian Ullrich
945bf39e05 feat(library/init/lean): progress 2018-09-28 20:50:18 -07:00
Sebastian Ullrich
df278096c4 fix(library/init/lean): fixes fixes fixes 2018-09-28 13:08:25 -07:00