Certain consumers of tree-sitter do not wish to take a dependency on the
CLI in order to generate their grammars. Long-term, those consumers will
be able to use packaging systems like tspm or obtain grammars from
github actions. In the short term, though, not packaging the grammar
means that there is no way for them to consume it.
This creates a GitHub action that will push the static grammar to an
isolated branch of this repository, allowing those systems to use GitHub
as a kind of hosting system for grammar artifacts. We push the grammar
on creation of a new ref to keep the number of deltas relatively low.
* Create a separate rule for literals and move tests
- Create a rule for literals: numbers, characters, strings and commands
- Place tests for literals in separate file
- Create a `test/` directory and move `corpus/`
NOTE: All literals are indexable
* Update numeric literals
- Add binary and octal integer literals
- Add hexadecimal float literals
- Fix numbers allowing trailing underscores
- Fix hexadecimal prefix allowing uppercase `X`
- Fix coefficients allowing non-decimal bases
- Fix primitive types not allowing leading zeros
- Update tests
* Add escape sequences and unicode codepoints
* Refactor comments
- Rename `comment` to `line_comment`
- Split block comment scanner into a separate function
* Refactor string and command literals
- Add string interpolations
- Add prefixed command literals
- Add triple backquote command literals
- Remove backticks from valid string identifiers
- Distinguish between standard and non-standard string literals.
non-standard strings cannot have interpolations.
- Update escape sequences
- Update tests
NOTE: The scanner uses a stack to keep track of string delimiters.
* generate and update scripts
- Do a shallow clone of examples (instead of cloning the whole repo).
- 6 files now parse correctly
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>
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.