Commit Graph

12 Commits

Author SHA1 Message Date
Michael Davis 108cdd550f
allow only one stab clause without a right-hand-side
Only one stab clause in a multi-stab-clause expression may be empty.
Multiple is a syntax error.

Co-authored-by: Jonatan Kłosko <jonatanklosko@gmail.com>
2022-04-12 09:16:45 -05:00
Michael Davis 662426cd85
handle stab clauses without right-hand-sides
Currently a stab clause without a right-hand-side is parsed as an error:

```elixir
Enum.map(xs, fn x ->
end)
```

And the `end` token ends up not being highlighted as a keyword. The
compiler gives a warning about this syntax but it comes up pretty
often when editing (writing a `case` block for example).

Implementation-wise, this might be a bug in tree-sitter? `prec.right`
seems to fight with error recovery when the rightmost token(s) are
`optional`.

```elixir
fn ->
end
```

gets parsed as

```scm
(anonymous_function
  (stab_clause
    right: (body (identifier)))
  (MISSING "end"))
```

although the `optional` should allow this case. I've seen this in
other grammars and it seems like the way around it is to replace
the `prec.right` with a conflict.
2022-04-11 19:23:22 -05:00
Jonatan Kłosko 8c8c14af1a
Ignore heredoc end delimiter unless in a new line (#28) 2022-03-04 16:33:24 +01:00
Michael Davis 08dbe8978c
parse nullary range operator (#25)
Co-authored-by: Jonatan Kłosko <jonatanklosko@gmail.com>
2022-02-13 13:19:53 -06:00
Jonatan Kłosko 94d6471cc8
Fix multiline stab clause with trailing identifier (#20) 2021-12-27 22:56:00 +01:00
Jonatan Kłosko ab50f8bbda
Parse digits in sigil modifiers (#3) 2021-10-04 10:26:04 +02:00
Jonatan Kłosko 18f6c6cc5d Use the same AST node for all identifiers 2021-09-29 12:44:04 +02:00
Jonatan Kłosko e35f31122f Fix stab clause ambiguities 2021-09-28 20:40:20 +02:00
Jonatan Kłosko bb5f90516e Add field names 2021-09-28 17:26:43 +02:00
Jonatan Kłosko d229dddf66 Cleanup and documentation 2021-09-28 16:03:43 +02:00
Jonatan Kłosko dad92d2b87 Initial parser implementation 2021-09-25 02:34:29 +02:00
Jonatan Kłosko 3f19b87c70 Add parser tests 2021-09-01 16:59:04 +02:00