Commit graph

20082 commits

Author SHA1 Message Date
Sebastian Ullrich
fff0cdc0ec test: Webserver: maybe-final version 2020-06-17 17:37:08 +02:00
Sebastian Ullrich
3c547db67c test: Webserver: introduce antiquotations for custom parsers, remove Prelim namespace
/cc @leodemoura
2020-06-17 11:54:41 +02:00
Sebastian Ullrich
5a10ac8f80 chore: delete platform-specific test 2020-06-17 10:53:10 +02:00
Leonardo de Moura
0c089b8cbd feat: elaborate syntaxAbbrev as a definition
@Kha I elaborated it as a definition. It works because we can now
reference Parser declarations in `syntax` command.
This change allowed us to replace `p.getArg 0` with `p` in the
`Websever` demo.
2020-06-16 15:43:17 -07:00
Leonardo de Moura
b01a923281 chore: throw error if a precedence is used with a parser declaration 2020-06-16 15:26:38 -07:00
Leonardo de Moura
8ba3a35712 chore: update stage0 2020-06-16 15:18:39 -07:00
Leonardo de Moura
18cd41f902 feat: add syntaxAbbrev 2020-06-16 15:18:10 -07:00
Leonardo de Moura
3e028e3812 feat: allow syntax command to use existing parser declarations
@Kha Note that I had to change the pattern. After I replaced,
```
syntax text : child
```
with
```
syntax Prelim.text  : child
```
Thus, I wrote
```
`(child|$t:text)
```
as
```
`(child|$t)
```
It works for this example, but it may be a problem in general.
2020-06-16 15:08:23 -07:00
Leonardo de Moura
c6e7ea8fd5 feat: add ParserDescr.parser constructor for embedding parser definitions into parser descriptions 2020-06-16 14:06:46 -07:00
Leonardo de Moura
580c0aaf94 chore: update stage0 2020-06-16 13:41:58 -07:00
Leonardo de Moura
f61e4ffbbd chore: ParserDescr.parser ==> ParserDescr.cat 2020-06-16 13:40:16 -07:00
Sebastian Ullrich
ade961bcf3 test: webserver demo 2020-06-16 22:10:43 +02:00
Sebastian Ullrich
4b84f8fa88 fix: nullary attributes in new frontend 2020-06-16 21:59:40 +02:00
Sebastian Ullrich
52d966f70b feat: #eval 2020-06-16 10:41:42 -07:00
Sebastian Ullrich
6404af6983 feat: IO.Prim.withIsolatedStreams 2020-06-16 10:41:42 -07:00
Sebastian Ullrich
f5015c9bc1 feat: adjust fun/do precedence in old frontend 2020-06-16 10:41:42 -07:00
Sebastian Ullrich
fe20860c3d chore: delete unused file 2020-06-16 10:41:42 -07:00
Leonardo de Moura
392d078011 feat: declare quotation parser for new parsing category
@Kha We can now delete the command
```
@[termParser] def childStxQuot : Parser :=
checkPrec maxPrec >> (node `Lean.Parser.Term.stxQuot $ symbol "`(child|" >> categoryParser `child 0 >> symbol ")")
```
from the web demo.
2020-06-16 10:38:37 -07:00
Sebastian Ullrich
b3d2e51aff feat: generalize tactic/command macro syntax 2020-06-16 19:21:48 +02:00
Sebastian Ullrich
cfd1900625 fix: #eval: redirect stdout/stderr 2020-06-16 12:06:53 +02:00
Sebastian Ullrich
f4c28fbe5f chore: remove unnecessary getByte/putByte IO primitives 2020-06-16 12:06:53 +02:00
Simon Hudon
a64e78b90b feat: add std streams
Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2020-06-16 12:06:53 +02:00
Sebastian Ullrich
58a7230dd9 chore: update stage0 2020-06-16 10:57:57 +02:00
Sebastian Ullrich
1ccaadfcf0 feat: add #eval syntax 2020-06-16 10:56:47 +02:00
Leonardo de Moura
09eb27404f chore: remove <$ and $> notation
cc @Kha
2020-06-15 14:52:31 -07:00
Leonardo de Moura
53dfd0d581 fix: expandMacroFns
We only keep trying other macros if the macro `m` produced
`unsupportedSyntax`. If the macro produced an error, we keep the
error.

@Kha This should fix the web demo.
2020-06-15 14:39:36 -07:00
Leonardo de Moura
bc6dba89f3 chore: fix tests 2020-06-15 14:39:30 -07:00
Sebastian Ullrich
f5a575b847 feat: getAtomVal! 2020-06-15 19:35:47 +02:00
Sebastian Ullrich
e6b988a10a feat: add natural language demo 2020-06-13 16:20:23 +02:00
Sebastian Ullrich
46065a9b3b feat: leanmake: auto-detect PKG 2020-06-13 15:22:01 +02:00
Sebastian Ullrich
43caef0130 fix: parenthesizer 2020-06-13 11:13:37 +02:00
Leonardo de Moura
6f0192581a feat: change precedence for fun and do parsing rules to maxPrec
Motivation: avoid `$`. See new test.

cc @Kha
2020-06-11 16:24:04 -07:00
Leonardo de Moura
7860f3645e doc: update comments to match new algorithm 2020-06-11 16:18:26 -07:00
Sebastian Ullrich
0afae3acc5 doc: adjust citation in Parser.lean 2020-06-11 15:55:53 -07:00
Leonardo de Moura
36bddc91cb chore: remove checkWsBeforeIfSymbol hack
Now the `app` parsing rule always require some whitespace before the
first argument.

cc @Kha
2020-06-11 14:58:29 -07:00
Leonardo de Moura
f0ebf426b7 chore: longestMatchFn parsers must produce exactly one Syntax node
Before this commit, we were handling the following two abnormal cases:

1- `p` did not produce any `Syntax` node. `runLongestMatchParser`
would insert a `Syntax.missing`.

2- `p` produced more than one `Syntax` node on the
stack. `runLongestMatchParser` would combine all of them using a
`nullKind` node.

This feature was never used since we only use `longestMatchFn` to
process leading and trailing parsers. In both case, we create a node.
Moreover, if a bad parser is manually created, I think it is better to
fail than accept using `Syntax.missing` or a `nullKind` node. We would
only be postponing the problem since we don't have elaboration
functions for them.

cc @Kha
2020-06-11 12:38:55 -07:00
Leonardo de Moura
8e4dc5bcf6 fix: longestMatchFn
Several combinators (e.g., `checkNoWsBefore`) access the "leading
term" by retrieving the element on the top of the syntax stack.
However, the `longestMatchFn` was accumulating successful matches on
the syntax stack too. This commit makes sure the `longestMatchFn`
always push the "leading term" before trying a parser.

This commit also eliminates the `orelseFn` hack at `trailingLoopStep`.
Now, we use `longestMatchFn` for all parsers. Note that we have to add
a new combinator (`checkWsBeforeIfSymbol`) to make sure that `a[i]`
cannot be parsed by the `app` parsing rule.
Before removing the hack from `trailingLoopStep`,
`a[i]` was correctly parsed as an `arrayRef`. After the change,
the `app` parser is tried and it succeeds (IF we don't use
`checkWsBeforeIfSymbol`). It is an application using the list literal
`[i]`.
The `checkWsBeforeIfSymbol` ensures that `a[i]` is not a valid `app`.

cc @Kha
2020-06-11 12:21:16 -07:00
Leonardo de Moura
77ce102baf chore: use notationItem to remove $noprec* hack 2020-06-10 16:59:44 -07:00
Leonardo de Moura
d9f71c6921 chore: update stage0 2020-06-10 16:55:40 -07:00
Leonardo de Moura
de0a2fefa0 feat: add notationItem 2020-06-10 16:54:46 -07:00
Leonardo de Moura
610ced2de5 chore: appPrec => maxPrec 2020-06-10 16:50:09 -07:00
Leonardo de Moura
f92166e913 chore: fix test 2020-06-10 16:43:44 -07:00
Leonardo de Moura
f838b80e03 fix: elaboration functions for parser! and tparser! 2020-06-10 16:42:42 -07:00
Leonardo de Moura
b5dff38ecf chore: update stage0 2020-06-10 16:22:32 -07:00
Leonardo de Moura
7269a721ff fix: parser! and tparser! syntax in the new frontend 2020-06-10 16:20:48 -07:00
Leonardo de Moura
1307405300 chore: make sure parser! and tparser! use a syntax similar to the one used at syntax for setting precedences
cc @Kha
2020-06-10 16:09:13 -07:00
Leonardo de Moura
243cda497e chore: remove leadingNodePrec and trailingNodePrec 2020-06-10 15:07:41 -07:00
Leonardo de Moura
cdc2dbe28d chore: use leadingNode and trailingNode in the old frontend 2020-06-10 15:05:22 -07:00
Leonardo de Moura
1c09e63a29 chore: update trailingNode and leadingNode API 2020-06-10 15:02:12 -07:00
Leonardo de Moura
6e848c484e chore: update stage0 2020-06-10 14:58:52 -07:00