add connection attributes

This commit is contained in:
Dmitriy Pleshevskiy 2022-12-05 10:37:04 +03:00
parent fcc6316ba1
commit acf249ef24
Signed by: pleshevskiy
GPG key ID: 1B59187B161C0215
4 changed files with 68 additions and 20 deletions

View file

@ -13,7 +13,9 @@ module.exports = grammar({
seq( seq(
$.identifier, $.identifier,
repeat1(seq($.arrow, $.identifier)), repeat1(seq($.arrow, $.identifier)),
optional(seq($._colon, $.label)), optional(
choice(seq($.dot, $._connection_attribute), seq($._colon, $.label))
),
$._end $._end
), ),
@ -21,9 +23,8 @@ module.exports = grammar({
seq( seq(
$.identifier, $.identifier,
repeat(seq($.dot, $.identifier)), repeat(seq($.dot, $.identifier)),
choice( optional(
optional(seq($.dot, $._shape_attribute)), choice(seq($.dot, $._shape_attribute), seq($._colon, $.label))
optional(seq($._colon, $.label))
), ),
$._end $._end
), ),
@ -54,6 +55,9 @@ module.exports = grammar({
$._style_attribute $._style_attribute
), ),
_connection_attribute: ($) =>
seq(alias($._connection_attr_key, $.attr_key), $._colon, $.attr_value),
_shape_attr_key: ($) => _shape_attr_key: ($) =>
choice( choice(
"shape", "shape",

View file

@ -52,6 +52,22 @@
{ {
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "dot"
},
{
"type": "SYMBOL",
"name": "_connection_attribute"
}
]
},
{ {
"type": "SEQ", "type": "SEQ",
"members": [ "members": [
@ -64,6 +80,8 @@
"name": "label" "name": "label"
} }
] ]
}
]
}, },
{ {
"type": "BLANK" "type": "BLANK"
@ -118,14 +136,6 @@
} }
] ]
}, },
{
"type": "BLANK"
}
]
},
{
"type": "CHOICE",
"members": [
{ {
"type": "SEQ", "type": "SEQ",
"members": [ "members": [
@ -138,13 +148,13 @@
"name": "label" "name": "label"
} }
] ]
}
]
}, },
{ {
"type": "BLANK" "type": "BLANK"
} }
] ]
}
]
}, },
{ {
"type": "SYMBOL", "type": "SYMBOL",
@ -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": { "_shape_attr_key": {
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [

View file

@ -36,6 +36,18 @@
"type": "arrow", "type": "arrow",
"named": true "named": true
}, },
{
"type": "attr_key",
"named": true
},
{
"type": "attr_value",
"named": true
},
{
"type": "dot",
"named": true
},
{ {
"type": "identifier", "type": "identifier",
"named": true "named": true

Binary file not shown.