Commit graph

31 commits

Author SHA1 Message Date
Sebastian Ullrich
1840b4b1ff fix: pretty printer with new syntax 2020-08-19 09:56:23 -07:00
Sebastian Ullrich
6cbfe2359b chore: remove old syntax 2020-08-19 09:56:23 -07:00
Sebastian Ullrich
3091bd71e7 feat: unwrap basic token parsers 2020-08-19 09:56:23 -07:00
Sebastian Ullrich
d4952dc40b feat: use insideQuot parsers 2020-08-19 09:56:23 -07:00
Leonardo de Moura
1ba3925740 feat: new let-expression syntax
see 0064f7d2b9
2020-08-17 07:51:08 -07:00
Sebastian Ullrich
129b60022d refactor: use distinct syntax kinds for quotations 2020-08-14 17:18:09 +02:00
Sebastian Ullrich
46f5670ba3 chore: Lean.Parser.Parser ~> Lean.Parser.Basic 2020-08-13 18:44:13 +02:00
Leonardo de Moura
25fd5d0a9a fix: ambiguity at match
```lean
match x : t with
| ...
```

Two possible intepretations for `x : t`:

1- The discriminant `t` where `x` is the name for the equality proofs `t = ...` in each alternative.

2- The discriminant `x` with a expected type `t` (aka motive) for the match.

This commit resolves the ambiguity by forcing no space before `:` in
the first interpretation.

cc @Kha
2020-08-10 13:47:09 -07:00
Leonardo de Moura
f974521783 fix: missing node 2020-08-10 11:15:44 -07:00
Leonardo de Moura
3ce794c58a feat: allow h : annotation on match discriminants 2020-08-10 10:12:24 -07:00
Sebastian Ullrich
19563961e2 feat: more whitespace in term parsers 2020-08-06 09:27:12 -07:00
Sebastian Ullrich
e6442d3177 feat: force whitespace in sort applications 2020-08-06 09:27:12 -07:00
Sebastian Ullrich
01456b1b00 fix: Term.app: force whitespace in front of each argument 2020-08-06 09:27:12 -07:00
Leonardo de Moura
447000a797 fix: >>= associativity 2020-08-03 14:00:19 -07:00
Leonardo de Moura
249bda16c0 chore: remove prelude commands from Lean package 2020-06-25 11:21:17 -07:00
Leonardo de Moura
09eb27404f chore: remove <$ and $> notation
cc @Kha
2020-06-15 14:52:31 -07: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
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
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
610ced2de5 chore: appPrec => maxPrec 2020-06-10 16:50:09 -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
2125687d9c chore: remove unnecessary [appPrec] annotations 2020-06-10 14:44:54 -07:00
Leonardo de Moura
77e1260ed2 chore: simplify checkPrec 2020-06-10 14:34:58 -07:00
Leonardo de Moura
6d3aff97d5 chore: lbp and rbp ==> prec 2020-06-10 13:41:10 -07:00
Leonardo de Moura
f0a9e54a69 chore: make sure leading and trailing parsers use the same kind of check 2020-06-10 13:41:10 -07:00
Leonardo de Moura
400aa435f3 fix: add missing precedence to liftMethod and remove unnecessary precedence from doLet 2020-06-08 16:12:05 -07:00
Leonardo de Moura
8dde9715a9 refactor: associate precedences to parsers instead of tokens
@Kha This is working in progress.
I am convinced we should associated the precedence to parsers. A lot
of weird stuff is gone :)
2020-06-08 16:12:05 -07:00
Leonardo de Moura
9a349a913a chore: remove sortApp
@Kha Note that `checkRBPGreater` comment and name were incorrect. It
was actually checking whether the RBP <= lower
2020-06-03 15:18:16 -07:00
Leonardo de Moura
6e5cd5fcc0 chore: change coercion from String to Parser
@Kha
I kept `TokenInfo` as is. That is, the `lbp` field is still `Option Nat`.
I changed my mind because we have the combinator `NonReservedSymbol`.
It feels weird to have a combinator that does not create a keyword,
but sets the `lbp`. Recall that it is used at `Lean/Parser/Tactic.lean`.

Other observations:

- We use symbols in auxiliary constructions (e.g., `mkAntiquot`). It
feels weird to set their `lbp` there.

- It felt weird to specify the `lbp` in places such as
```
def structCtor := parser! ident >> optional inferMod >> symbol " :: " 67
```

- We have a few parsing rules where the same symbol appears twice.
It is funny to set the `lbp` twice. Note that the approach we
discussed yesterday (retrieving the `lbp` from the `Environment`)
would not work here.
2020-05-27 15:59:12 -07:00
Leonardo de Moura
4ccc3fef52 chore: move Init.Lean files to Lean package 2020-05-26 15:04:35 -07:00
Renamed from src/Init/Lean/Parser/Term.lean (Browse further)