Skip to content

Commit

Permalink
Merge pull request Wilfred#4 from nickcoutsos/feature/multi-labeled-n…
Browse files Browse the repository at this point in the history
…odes

Define labeled items recursively
  • Loading branch information
joelspadin authored Apr 7, 2023
2 parents ea30a05 + 6020ad7 commit 3c1c6cb
Show file tree
Hide file tree
Showing 5 changed files with 1,837 additions and 1,670 deletions.
7 changes: 2 additions & 5 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module.exports = grammar({
choice(
$.file_version,
$.memory_reservation,
alias($.labeled_node, $.labeled_item),
$.labeled_item,
$.node,
$.dtsi_include,
$.preproc_include,
Expand Down Expand Up @@ -107,14 +107,11 @@ module.exports = grammar({
'}'
),

labeled_node: ($) =>
seq(field('label', $.label_identifier), ':', field('item', $.node)),

labeled_item: ($) =>
seq(
field('label', $.label_identifier),
':',
field('item', choice($.node, $.property))
field('item', choice($.labeled_item, $.node, $.property))
),

node: ($) =>
Expand Down
38 changes: 6 additions & 32 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,8 @@
"name": "memory_reservation"
},
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "labeled_node"
},
"named": true,
"value": "labeled_item"
"type": "SYMBOL",
"name": "labeled_item"
},
{
"type": "SYMBOL",
Expand Down Expand Up @@ -279,31 +274,6 @@
}
]
},
"labeled_node": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "label",
"content": {
"type": "SYMBOL",
"name": "label_identifier"
}
},
{
"type": "STRING",
"value": ":"
},
{
"type": "FIELD",
"name": "item",
"content": {
"type": "SYMBOL",
"name": "node"
}
}
]
},
"labeled_item": {
"type": "SEQ",
"members": [
Expand All @@ -325,6 +295,10 @@
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "labeled_item"
},
{
"type": "SYMBOL",
"name": "node"
Expand Down
4 changes: 4 additions & 0 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,10 @@
"multiple": false,
"required": true,
"types": [
{
"type": "labeled_item",
"named": true
},
{
"type": "node",
"named": true
Expand Down
Loading

0 comments on commit 3c1c6cb

Please sign in to comment.