Skip to content

Commit

Permalink
Add attribute support
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross35 committed Jan 3, 2024
1 parent 0f49fe4 commit 3e4df75
Show file tree
Hide file tree
Showing 7 changed files with 2,905 additions and 2,475 deletions.
4 changes: 3 additions & 1 deletion GRAMMAR.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ string : STRING
sequence : expression ',' sequence
| expression ','?

recipe : '@'? NAME parameter* variadic? ':' dependency* body?
recipe : attribute? '@'? NAME parameter* variadic? ':' dependency* body?

attribute : '[' NAME ']' eol

parameter : '$'? NAME
| '$'? NAME '=' value
Expand Down
8 changes: 6 additions & 2 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,11 @@ module.exports = grammar({
seq($.expression, optional(",")),
),

// recipe : '@'? NAME parameter* variadic_parameters? ':' dependency* body?
recipe: ($) => seq($.recipeheader, $.NEWLINE, optional($.body)),
attribute: ($) => seq("[", $.NAME, "]", $.eol),

// recipe : attribute? '@'? NAME parameter* variadic_parameters? ':' dependency* body?
recipe: ($) =>
seq(optional($.attribute), $.recipeheader, $.NEWLINE, optional($.body)),

recipeheader: ($) =>
seq(
Expand All @@ -173,6 +176,7 @@ module.exports = grammar({
choice(
seq(optional("$"), $.NAME),
seq(optional("$"), $.NAME, "=", $.value),
$.eol,
),

// variadic_parameters : '*' parameter
Expand Down
37 changes: 37 additions & 0 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -655,9 +655,42 @@
}
]
},
"attribute": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "["
},
{
"type": "SYMBOL",
"name": "NAME"
},
{
"type": "STRING",
"value": "]"
},
{
"type": "SYMBOL",
"name": "eol"
}
]
},
"recipe": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "attribute"
},
{
"type": "BLANK"
}
]
},
{
"type": "SYMBOL",
"name": "recipeheader"
Expand Down Expand Up @@ -817,6 +850,10 @@
"name": "value"
}
]
},
{
"type": "SYMBOL",
"name": "eol"
}
]
},
Expand Down
27 changes: 27 additions & 0 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,25 @@
]
}
},
{
"type": "attribute",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "NAME",
"named": true
},
{
"type": "eol",
"named": true
}
]
}
},
{
"type": "body",
"named": true,
Expand Down Expand Up @@ -402,6 +421,10 @@
"type": "NAME",
"named": true
},
{
"type": "eol",
"named": true
},
{
"type": "value",
"named": true
Expand Down Expand Up @@ -440,6 +463,10 @@
"type": "NEWLINE",
"named": true
},
{
"type": "attribute",
"named": true
},
{
"type": "body",
"named": true
Expand Down
Loading

0 comments on commit 3e4df75

Please sign in to comment.