Skip to content

Commit

Permalink
Add support for && dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross35 committed Jan 4, 2024
1 parent ecd1704 commit a31b2f7
Show file tree
Hide file tree
Showing 7 changed files with 3,706 additions and 3,438 deletions.
10 changes: 8 additions & 2 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ module.exports = grammar({
field("recipe_name", $.identifier),
optional($.parameters),
":",
repeat($.dependency),
optional($.dependencies),
),

parameters: ($) =>
Expand All @@ -242,7 +242,13 @@ module.exports = grammar({
variadic_parameter: ($) =>
seq(field("kleene", choice("*", "+")), $.parameter),

dependencies: ($) => repeat1($.dependency),
dependencies: ($) =>
// return seq(item, repeat(seq(",", item)));
prec.left(seq($.dependency, repeat(seq(optional("&&"), $.dependencies)))),
// choice(
// $.dependency,
// seq($.dependency, "&&", $.dependencies),
// ),

// dependency : NAME
// | '(' NAME expression* ')'
Expand Down
3 changes: 2 additions & 1 deletion queries/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@
"set"
] @keyword

; exclude `=` since it is only an operator in parameters (matching covered there)
; exclude `=` and `&&` since they are valid in more normal scopes
; (matching is covered in their parent nodes)
["@" "==" "!=" "+" ":=" "*" ":" "/" "?"] @operator

["(" ")" "[" "]" "{{" "}}" "{" "}"] @punctuation.bracket
Expand Down
51 changes: 43 additions & 8 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -958,11 +958,16 @@
"value": ":"
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "dependency"
}
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "dependencies"
},
{
"type": "BLANK"
}
]
}
]
},
Expand Down Expand Up @@ -1068,10 +1073,40 @@
]
},
"dependencies": {
"type": "REPEAT1",
"type": "PREC_LEFT",
"value": 0,
"content": {
"type": "SYMBOL",
"name": "dependency"
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "dependency"
},
{
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "&&"
},
{
"type": "BLANK"
}
]
},
{
"type": "SYMBOL",
"name": "dependencies"
}
]
}
}
]
}
},
"dependency": {
Expand Down
25 changes: 24 additions & 1 deletion src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,25 @@
]
}
},
{
"type": "dependencies",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "dependencies",
"named": true
},
{
"type": "dependency",
"named": true
}
]
}
},
{
"type": "dependency",
"named": true,
Expand Down Expand Up @@ -550,7 +569,7 @@
"required": false,
"types": [
{
"type": "dependency",
"type": "dependencies",
"named": true
},
{
Expand Down Expand Up @@ -821,6 +840,10 @@
"type": "$",
"named": false
},
{
"type": "&&",
"named": false
},
{
"type": "'''",
"named": false
Expand Down
Loading

0 comments on commit a31b2f7

Please sign in to comment.