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 87f48b8 commit 8259343
Show file tree
Hide file tree
Showing 7 changed files with 3,705 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 @@ -218,7 +218,7 @@ module.exports = grammar({
field("recipe_name", $.identifier),
optional($.parameters),
":",
repeat($.dependency),
optional($.dependencies),
),

parameters: ($) =>
Expand All @@ -239,7 +239,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
2 changes: 1 addition & 1 deletion queries/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"set"
] @keyword

["@" "==" "!=" "+" ":=" "*" ":" "/" "?"] @operator
["@" "==" "!=" "+" ":=" "*" ":" "/" "?" "&&"] @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 @@ -954,11 +954,16 @@
"value": ":"
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "dependency"
}
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "dependencies"
},
{
"type": "BLANK"
}
]
}
]
},
Expand Down Expand Up @@ -1064,10 +1069,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 @@ -813,6 +832,10 @@
"type": "$",
"named": false
},
{
"type": "&&",
"named": false
},
{
"type": "'''",
"named": false
Expand Down
Loading

0 comments on commit 8259343

Please sign in to comment.