diff --git a/grammar.js b/grammar.js index d3aa871..ca21f25 100644 --- a/grammar.js +++ b/grammar.js @@ -73,6 +73,8 @@ module.exports = grammar({ ) ), + _dash: ($) => token.immediate("-"), + label: ($) => choice($.string, $._unquoted_string), attr_value: ($) => seq(spaces, choice($.string, $._unquoted_string)), @@ -175,8 +177,6 @@ module.exports = grammar({ arrow: ($) => choice(/-+>/, /--+/, /<-+/, /<-+>/), - _dash: ($) => token.immediate("-"), - dot: ($) => token.immediate("."), _unquoted_string: ($) => token.immediate(/[^'"`\n;{}]+/), diff --git a/src/grammar.json b/src/grammar.json index 1ae98d3..7c743d0 100644 --- a/src/grammar.json +++ b/src/grammar.json @@ -366,6 +366,13 @@ } ] }, + "_dash": { + "type": "IMMEDIATE_TOKEN", + "content": { + "type": "STRING", + "value": "-" + } + }, "label": { "type": "CHOICE", "members": [ @@ -1024,13 +1031,6 @@ } ] }, - "_dash": { - "type": "IMMEDIATE_TOKEN", - "content": { - "type": "STRING", - "value": "-" - } - }, "dot": { "type": "IMMEDIATE_TOKEN", "content": { diff --git a/src/parser.c b/src/parser.c index 3a03490..d8233ff 100644 Binary files a/src/parser.c and b/src/parser.c differ diff --git a/test/highlight/connection.d2 b/test/highlight/connection.d2 new file mode 100644 index 0000000..8551999 --- /dev/null +++ b/test/highlight/connection.d2 @@ -0,0 +1,33 @@ +a <- b <-> c -- d -> e +# <- variable +# ^ operator +# ^ variable +# ^ operator +# ^ variable +# ^ operator +# ^ variable +# ^ operator +# ^ variable + +a ----- b +# ^ operator + +a ----> b +# ^ operator + +a <---- b +# ^ operator + +a <---> b +# ^ operator + +a.b.c --> d.e +# <- constant +# ^ constant +# ^ variable +# ^ operator +# ^ constant +# ^ variable + + + diff --git a/tree-sitter-d2.wasm b/tree-sitter-d2.wasm index 0949518..c9f5b7d 100755 Binary files a/tree-sitter-d2.wasm and b/tree-sitter-d2.wasm differ