Commit graph

67 commits

Author SHA1 Message Date
Leonardo de Moura
32d5ef8b78 feat: scoped and local unification hints 2020-12-05 13:49:36 -08:00
Leonardo de Moura
4d428c8660 feat: add ScopedEnvExtension.addLocalEntry 2020-12-05 06:54:03 -08:00
Leonardo de Moura
0ab368581a refactor: ScopedEnvExtension
1) `ScopedEnvExtension` module now mananges the push/pop/activate
methods. Motivations:
  - Easier to add attributes
  - One `ScopedEnvExtension` may be shared between multiple
  attributes (e.g., parsers)

2) Add `AttributeKind`
2020-12-04 16:22:43 -08:00
Leonardo de Moura
02e13081a9 feat: implement AttributeImpl scoping methods for parsers 2020-12-04 16:22:43 -08:00
Sebastian Ullrich
92cbe27810 refactor: clean up & delay registering parser aliases 2020-12-04 19:24:32 +01:00
Leonardo de Moura
6f1facd07c feat: implement ParserExtension using ScopedEnvExtension 2020-12-04 09:57:35 -08:00
Leonardo de Moura
2408b5c6b5 feat: basic support for scoped attributes 2020-12-03 10:39:59 -08:00
Sebastian Ullrich
21f4257da5 feat: name resolution during parsing 2020-12-03 17:46:13 +01:00
Leonardo de Moura
b95c4788c1 refactor: OfDecimal ==> OfScientific
`decimalLit` ==> `scientificLit`
2020-12-03 08:08:19 -08:00
Leonardo de Moura
d1f4d4f57e feat: scientific notation 2020-12-03 07:49:20 -08:00
Leonardo de Moura
facb28d080 feat: basic support for decimal numbers 2020-12-02 14:54:59 -08:00
Leonardo de Moura
0869f38de4 chore: update structure, class, inductive 2020-11-27 15:09:30 -08:00
Leonardo de Moura
c305c2691f chore: use := 2020-11-19 07:22:31 -08:00
Leonardo de Moura
91dca53274 refactor: remove MonadIO
There is no reason for having `MonadIO` anymore. The `MonadLift` type
class is well behaved in the new frontend, the `MonadFinally` solves
the problem at monad stacks such as `ExcepT e IO`.

This commit also changes the type of the IO printing functions.
For example, the type of `IO.println` was
```
def IO.println {m} [MonadIO m] {α} [ToString α] (s : α) : m Unit
```
and now it is just
```
def IO.println {α} [ToString α] (s : α) : IO Unit
```
We rely on the new frontend auto-lifting feature.
That is, if there is an instance `[MonadLiftT IO m]`, then
a term of type `IO a` is automatically coerced to `m a`

We also want a simpler `IO.println` for writing tests.
For example,
```
```
doesn't work because there isn't sufficient information for inferring
the parameter `m` in the previous `IO.println`.
The shortest workaround looked very weird
```
```

I considered adding `IO` as a default value for `m` when we have
`MonadIO m`, as we use `Nat` as the default for `ofNat a`, but it felt
like uncessary complexity.

@Kha The commit seems to work well. The auto-lifting featuring has
been working great for me. There is still room for improvement.
For example, given `MonadLiftT m n`, it doesn't automatically lift
`a -> m b` into `a -> n b`. So, code such as
`foo >>= IO.println`
had to be rewritten as
`foo >>= fun x => IO.println x`
I will add this feature later.
If you have time, please try to play with this feature and figure out
if it is stable enough for making it the default.
That is, if it roboust enough, we can stop using the following idiom
for writing functions that can be lifted automatically.
```
def instantiateLevelMVarsImp (u : Level) : MetaM Level :=
  ...

def instantiateLevelMVars {m} [MonadLiftT MetaM m] (u : Level) : m Level :=
  liftMetaM $ instantiateLevelMVarsImp u
```
I think we only need this idiom when using `MonadControlT` which is
not as common as `MonadLiftT`.
2020-11-18 18:47:22 -08:00
Leonardo de Moura
96db4985eb feat: allow anonymous antiquotations at ParserDescr.nodeWithAntiquot 2020-11-17 10:48:22 -08:00
Leonardo de Moura
da23b96b43 feat: improve error messages for syntax command 2020-11-17 10:33:53 -08:00
Leonardo de Moura
360fa1638f chore: rename Parser.try to Parser.atomic
Reason: `try` is a keyword.

cc @Kha
2020-11-17 08:25:01 -08:00
Leonardo de Moura
bed1582844 chore: remove workaround of the workaround 2020-11-14 07:04:17 -08:00
Leonardo de Moura
35f1844d16 feat: add ParserDescr.checkPrec 2020-11-13 16:00:31 -08:00
Leonardo de Moura
f64d6c4514 feat: add ParserDescr.nodeWithAntiquot 2020-11-13 16:00:31 -08:00
Leonardo de Moura
6fbaea6563 feat: simplify syntax command syntax 2020-11-12 07:01:20 -08:00
Leonardo de Moura
0510f746fc feat: add macro registerParserAlias!
It register the parser, parenthesizer, and formatter.
2020-11-11 19:34:14 -08:00
Leonardo de Moura
3bfc5248ca chore: ParserDescrNew => ParserDescr 2020-11-11 18:57:49 -08:00
Leonardo de Moura
ba9a06dfc9 feat: compact ParserDescr 2020-11-11 18:52:26 -08:00
Leonardo de Moura
bd8bb163e2 feat: add parser aliases tables 2020-11-11 17:41:20 -08:00
Leonardo de Moura
f17e226638 chore: naming convention
Example: `mkNameStr` => `Name.mkStr`

cc @Kha
2020-11-11 10:08:55 -08:00
Leonardo de Moura
fc4d991707 feat: add allowTrailingSep parameter to ParserDescr.sepBy and ParserDescr.sepBy1 2020-11-08 07:51:10 -08:00
Leonardo de Moura
34cba1ec2e feat: add withPosition and checkCol constructors 2020-11-08 06:42:25 -08:00
Leonardo de Moura
81d6e065e7 chore: adjust files and tests 2020-11-07 17:32:12 -08:00
Sebastian Ullrich
c1d75e21ea fix: fix pretty printers for imported ParserDescrs
... by interpreting them (imported or not) on the fly instead of storing them in the environment

/cc @leodemoura
2020-11-07 17:05:07 +01:00
Leonardo de Moura
6858cb5fb6 chore: cleanup 2020-10-29 10:24:16 -07:00
Sebastian Ullrich
8f01619c3d perf: work around parser performance issue I forgot about and the speedcenter had to remind me of 2020-10-28 10:11:45 +01:00
Leonardo de Moura
13c2a8ff51 chore: remove #lang lean4 header 2020-10-25 09:54:07 -07:00
Leonardo de Moura
af968c60e6 chore: cleanup 2020-10-22 07:32:23 -07:00
Leonardo de Moura
f8971200af chore: move to new frontend 2020-10-20 17:01:29 -07:00
Sebastian Ullrich
490c482af2 fix: allow [runParserAttributeHooks] on imported declarations, add non-builtin variant 2020-10-20 09:39:50 +02:00
Leonardo de Moura
ef18b0ab49 chore: use [builtinInit] 2020-10-19 14:58:38 -07:00
Leonardo de Moura
84a0cd1f59 feat: add [builtinInit] attribute 2020-10-19 14:51:23 -07:00
Leonardo de Moura
e54a207986 refactor: provide Options to lean_eval_const
add `ImportM` monad for `addImportedFn`

cc @Kha
2020-10-19 10:21:38 -07:00
Leonardo de Moura
60e4f4fee1 feat: improve notFollowedBy error messages 2020-10-15 17:01:10 -07:00
Leonardo de Moura
3bd75d51d5 feat: add ParserDescr.noWs 2020-10-09 16:26:49 -07:00
Leonardo de Moura
7013ea4098 feat: add interpolatedStr to ParserDescr and Syntax 2020-10-09 14:04:53 -07:00
Leonardo de Moura
0275d23ad7 fix: ignore $ at notFollowedByCategoryToken when inside quotations 2020-09-26 17:57:26 -07:00
Leonardo de Moura
6892a957d6 feat: trailing ; in indented "do" sequences
cc @Kha
2020-09-26 16:08:30 -07:00
Leonardo de Moura
3d6cc2de08 feat: add notFollowedByCategoryToken parser 2020-09-26 15:53:23 -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
f0ab743ad0 chore: remove temporary workaround 2020-09-19 18:00:45 -07:00
Leonardo de Moura
fe2d3be821 feat: parser priorities 2020-09-19 17:55:17 -07:00
Leonardo de Moura
f679b7d803 feat: add notFollowedBy to syntax 2020-09-19 15:43:44 -07:00