diff --git a/grammar.js b/grammar.js index da69a22..3dff64a 100644 --- a/grammar.js +++ b/grammar.js @@ -13,7 +13,9 @@ module.exports = grammar({ seq( $.identifier, repeat1(seq($.arrow, $.identifier)), - optional(seq($._colon, $.label)), + optional( + choice(seq($.dot, $._connection_attribute), seq($._colon, $.label)) + ), $._end ), @@ -21,9 +23,8 @@ module.exports = grammar({ seq( $.identifier, repeat(seq($.dot, $.identifier)), - choice( - optional(seq($.dot, $._shape_attribute)), - optional(seq($._colon, $.label)) + optional( + choice(seq($.dot, $._shape_attribute), seq($._colon, $.label)) ), $._end ), @@ -54,6 +55,9 @@ module.exports = grammar({ $._style_attribute ), + _connection_attribute: ($) => + seq(alias($._connection_attr_key, $.attr_key), $._colon, $.attr_value), + _shape_attr_key: ($) => choice( "shape", diff --git a/src/grammar.json b/src/grammar.json index 2c275d2..5bc6424 100644 --- a/src/grammar.json +++ b/src/grammar.json @@ -53,15 +53,33 @@ "type": "CHOICE", "members": [ { - "type": "SEQ", + "type": "CHOICE", "members": [ { - "type": "SYMBOL", - "name": "_colon" + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "dot" + }, + { + "type": "SYMBOL", + "name": "_connection_attribute" + } + ] }, { - "type": "SYMBOL", - "name": "label" + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "_colon" + }, + { + "type": "SYMBOL", + "name": "label" + } + ] } ] }, @@ -118,14 +136,6 @@ } ] }, - { - "type": "BLANK" - } - ] - }, - { - "type": "CHOICE", - "members": [ { "type": "SEQ", "members": [ @@ -138,11 +148,11 @@ "name": "label" } ] - }, - { - "type": "BLANK" } ] + }, + { + "type": "BLANK" } ] }, @@ -278,6 +288,28 @@ } ] }, + "_connection_attribute": { + "type": "SEQ", + "members": [ + { + "type": "ALIAS", + "content": { + "type": "SYMBOL", + "name": "_connection_attr_key" + }, + "named": true, + "value": "attr_key" + }, + { + "type": "SYMBOL", + "name": "_colon" + }, + { + "type": "SYMBOL", + "name": "attr_value" + } + ] + }, "_shape_attr_key": { "type": "CHOICE", "members": [ diff --git a/src/node-types.json b/src/node-types.json index 6e7a087..384dc18 100644 --- a/src/node-types.json +++ b/src/node-types.json @@ -36,6 +36,18 @@ "type": "arrow", "named": true }, + { + "type": "attr_key", + "named": true + }, + { + "type": "attr_value", + "named": true + }, + { + "type": "dot", + "named": true + }, { "type": "identifier", "named": true diff --git a/src/parser.c b/src/parser.c index e221615..d6ef1fd 100644 Binary files a/src/parser.c and b/src/parser.c differ