Compare commits

...

5 Commits

Author SHA1 Message Date
Shadowfacts 9bc2dfc6f4 Update to --abi=14 2022-05-28 10:37:56 -04:00
Patrick Thomson 5d0c1bfcdf
Loosen tree-sitter library bounds. (#36) 2022-04-28 11:17:48 -05:00
Clay ec1c4cac1b
Add HEEx language injection for `~H` sigils (#34)
* Add HEEx language injection for `~H` sigils

* Update queries/injections.scm

Co-authored-by: Jonatan Kłosko <jonatanklosko@gmail.com>
2022-04-18 23:16:26 +02:00
the-mikedavis 1dabc1c790 Generate parser 2022-04-12 14:20:51 +00:00
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
7 changed files with 328670 additions and 321677 deletions

View File

@ -20,7 +20,7 @@ include = [
path = "bindings/rust/lib.rs"
[dependencies]
tree-sitter = "0.20"
tree-sitter = ">= 0.19, < 0.21"
[build-dependencies]
cc = "1.0"

View File

@ -159,16 +159,6 @@ module.exports = grammar({
// * stab arguments item in `arg1, left when right ->`
[$.binary_operator, $._stab_clause_arguments_without_parentheses],
// Given `( -> • \n`, the newline could be either:
// * stab clause without a body
// * stab clause with a body
[$._stab_clause_without_body, $._stab_clause_with_body],
// Given `( -> • /`, `/` token could be either:
// * stab clause with a body
// * -> as an operator followed by `/`
[$._stab_clause_with_body, $.operator_identifier],
// Given `((arg1, arg2 • ,`, `arg3` expression can be either:
// * stab parenthesised arguments item in `((arg1, arg2, arg3) ->)`
// * stab non-parenthesised arguments item in `((arg1, arg2, arg3 ->))`
@ -739,20 +729,13 @@ module.exports = grammar({
),
stab_clause: ($) =>
choice($._stab_clause_with_body, $._stab_clause_without_body),
_stab_clause_with_body: ($) =>
seq(
optional(field("left", $._stab_clause_left)),
field("operator", "->"),
field("right", $.body)
),
_stab_clause_without_body: ($) =>
seq(
optional(field("left", $._stab_clause_left)),
field("operator", "->"),
optional($._terminator)
// Right precedence, because we want to consume body if any
prec.right(
seq(
optional(field("left", $._stab_clause_left)),
field("operator", "->"),
optional(field("right", $.body))
)
),
_stab_clause_left: ($) =>
@ -834,10 +817,13 @@ module.exports = grammar({
),
body: ($) =>
seq(
optional($._terminator),
sep1($._expression, $._terminator),
optional($._terminator)
choice(
$._terminator,
seq(
optional($._terminator),
sep1($._expression, $._terminator),
optional($._terminator)
)
),
anonymous_function: ($) =>

7
queries/injections.scm Normal file
View File

@ -0,0 +1,7 @@
; Phoenix HTML template
((sigil
(sigil_name) @_sigil_name
(quoted_content) @injection.content)
(#eq @_sigil_name "H")
(#set! injection.language "heex")
(#set! injection.combined))

81
src/grammar.json generated
View File

@ -6452,54 +6452,63 @@
}
},
"body": {
"type": "SEQ",
"type": "CHOICE",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_terminator"
},
{
"type": "BLANK"
}
]
"type": "SYMBOL",
"name": "_terminator"
},
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_expression"
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_terminator"
},
{
"type": "BLANK"
}
]
},
{
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_terminator"
},
{
"type": "SYMBOL",
"name": "_expression"
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_expression"
},
{
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_terminator"
},
{
"type": "SYMBOL",
"name": "_expression"
}
]
}
]
}
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_terminator"
}
]
},
{
"type": "BLANK"
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_terminator"
},
{
"type": "BLANK"
}
]
}
]
}

2
src/node-types.json generated
View File

@ -1082,7 +1082,7 @@
"fields": {},
"children": {
"multiple": true,
"required": true,
"required": false,
"types": [
{
"type": "access_call",

650204
src/parser.c generated

File diff suppressed because it is too large Load Diff

View File

@ -684,12 +684,11 @@ end
(integer))))))
=====================================
stab clause / edge cases / empty right-hand-sides
stab clause / edge cases / empty right-hand-side
=====================================
fun do
x ->
y ->
end
---
@ -700,10 +699,8 @@ end
(do_block
(stab_clause
(arguments
(identifier)))
(stab_clause
(arguments
(identifier))))))
(identifier))
(body)))))
=====================================
pattern matching