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 4c561df
Show file tree
Hide file tree
Showing 7 changed files with 3,704 additions and 3,438 deletions.
5 changes: 3 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,8 @@ module.exports = grammar({
variadic_parameter: ($) =>
seq(field("kleene", choice("*", "+")), $.parameter),

dependencies: ($) => repeat1($.dependency),
dependencies: ($) =>
prec.left(seq($.dependency, repeat(seq(optional("&&"), $.dependencies)))),

// dependency : NAME
// | '(' NAME expression* ')'
Expand Down
4 changes: 3 additions & 1 deletion queries/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
param: (identifier) @variable.parameter
"="? @operator)

(dependencies "&&" @operator)
(dependency
recipe: (identifier) @function)
(dependency_expression
Expand All @@ -92,7 +93,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 4c561df

Please sign in to comment.