diff --git a/grammar.js b/grammar.js index 299313d..896042f 100644 --- a/grammar.js +++ b/grammar.js @@ -95,10 +95,8 @@ module.exports = grammar({ seq( $._connection_path, repeat1(seq($.arrow, $._connection_path)), - seq( - optional(seq($._colon, optional($.label))), - optional(seq(alias($._connection_block, $.block))) - ) + optional(seq($._colon, optional($.label))), + optional(seq(alias($._connection_block, $.block))) ), _connection_path: ($) => @@ -370,13 +368,13 @@ module.exports = grammar({ attr_value_list: mkList(($) => $.attr_value), attr_value: ($) => - seq(choice($.boolean, $.integer, $.float, $.string, $._unquoted_string)), + choice($.boolean, $.integer, $.float, $.string, $._unquoted_string), // -------------------------------------------- _dash: ($) => token.immediate("-"), - _colon: ($) => seq(":"), + _colon: ($) => token(":"), arrow: ($) => token(prec(PREC.ARROW, choice(/-+>/, /--+/, /<-+/, /<-+>/))), diff --git a/src/grammar.json b/src/grammar.json index 9eca909..90a9fb0 100644 --- a/src/grammar.json +++ b/src/grammar.json @@ -89,58 +89,53 @@ } }, { - "type": "SEQ", + "type": "CHOICE", "members": [ { - "type": "CHOICE", + "type": "SEQ", "members": [ { - "type": "SEQ", + "type": "SYMBOL", + "name": "_colon" + }, + { + "type": "CHOICE", "members": [ { "type": "SYMBOL", - "name": "_colon" + "name": "label" }, { - "type": "CHOICE", - "members": [ - { - "type": "SYMBOL", - "name": "label" - }, - { - "type": "BLANK" - } - ] + "type": "BLANK" } ] - }, - { - "type": "BLANK" } ] }, { - "type": "CHOICE", + "type": "BLANK" + } + ] + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", "members": [ { - "type": "SEQ", - "members": [ - { - "type": "ALIAS", - "content": { - "type": "SYMBOL", - "name": "_connection_block" - }, - "named": true, - "value": "block" - } - ] - }, - { - "type": "BLANK" + "type": "ALIAS", + "content": { + "type": "SYMBOL", + "name": "_connection_block" + }, + "named": true, + "value": "block" } ] + }, + { + "type": "BLANK" } ] } @@ -1976,32 +1971,27 @@ ] }, "attr_value": { - "type": "SEQ", + "type": "CHOICE", "members": [ { - "type": "CHOICE", - "members": [ - { - "type": "SYMBOL", - "name": "boolean" - }, - { - "type": "SYMBOL", - "name": "integer" - }, - { - "type": "SYMBOL", - "name": "float" - }, - { - "type": "SYMBOL", - "name": "string" - }, - { - "type": "SYMBOL", - "name": "_unquoted_string" - } - ] + "type": "SYMBOL", + "name": "boolean" + }, + { + "type": "SYMBOL", + "name": "integer" + }, + { + "type": "SYMBOL", + "name": "float" + }, + { + "type": "SYMBOL", + "name": "string" + }, + { + "type": "SYMBOL", + "name": "_unquoted_string" } ] }, @@ -2013,13 +2003,11 @@ } }, "_colon": { - "type": "SEQ", - "members": [ - { - "type": "STRING", - "value": ":" - } - ] + "type": "TOKEN", + "content": { + "type": "STRING", + "value": ":" + } }, "arrow": { "type": "TOKEN", diff --git a/src/node-types.json b/src/node-types.json index 212b2f4..307e03b 100644 --- a/src/node-types.json +++ b/src/node-types.json @@ -515,10 +515,6 @@ "type": "3d", "named": false }, - { - "type": ":", - "named": false - }, { "type": ";", "named": false diff --git a/src/parser.c b/src/parser.c index e8c3622..be0e836 100644 Binary files a/src/parser.c and b/src/parser.c differ diff --git a/tree-sitter-d2.wasm b/tree-sitter-d2.wasm index e8a10a6..bb6e05b 100755 Binary files a/tree-sitter-d2.wasm and b/tree-sitter-d2.wasm differ