grammar: add link and tooltip attributes

Closes #18
This commit is contained in:
Dmitriy Pleshevskiy 2023-01-05 16:53:32 +03:00
parent 32b1fa5555
commit 6a04387009
Signed by: pleshevskiy
GPG key ID: 1B59187B161C0215
9 changed files with 84 additions and 10 deletions

View file

@ -190,6 +190,8 @@ module.exports = grammar({
choice(
"shape",
"label",
"link",
"tooltip",
// sql
"constraint",
// image

View file

@ -777,6 +777,14 @@
"type": "STRING",
"value": "label"
},
{
"type": "STRING",
"value": "link"
},
{
"type": "STRING",
"value": "tooltip"
},
{
"type": "STRING",
"value": "constraint"
@ -1286,14 +1294,26 @@
}
},
"_unquoted_string": {
"type": "TOKEN",
"type": "REPEAT1",
"content": {
"type": "PREC",
"value": -1,
"content": {
"type": "PATTERN",
"value": "[^'\"`|\\n\\s;{}]([^\\n;{}]*[^\\n\\s;{}])?"
}
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "escape_sequence"
},
{
"type": "TOKEN",
"content": {
"type": "PREC",
"value": -1,
"content": {
"type": "PATTERN",
"value": "[^'\"`\\\\|\\n\\s;{}]([^\\\\\\n;{}]*[^\\\\\\n\\s;{}])?"
}
}
}
]
}
},
"string": {

View file

@ -19,13 +19,17 @@
"named": true,
"fields": {},
"children": {
"multiple": false,
"multiple": true,
"required": false,
"types": [
{
"type": "boolean",
"named": true
},
{
"type": "escape_sequence",
"named": true
},
{
"type": "float",
"named": true
@ -202,9 +206,13 @@
"named": true,
"fields": {},
"children": {
"multiple": false,
"multiple": true,
"required": false,
"types": [
{
"type": "escape_sequence",
"named": true
},
{
"type": "string",
"named": true
@ -476,6 +484,10 @@
"type": "target-arrowhead",
"named": false
},
{
"type": "tooltip",
"named": false
},
{
"type": "true",
"named": false

Binary file not shown.

View file

@ -125,6 +125,8 @@ foo: {
icon: pathto
width: 100
height: 200
link: https://microsoft.com
tooltip: Gee, I feel kind of LIGHT in the head now,\nknowing I can't make my satellite dish PAYMENTS!
}
--------------------------------------------------------------------------------
@ -139,6 +141,8 @@ foo: {
(attribute (attr_key) (attr_value))
(attribute (attr_key) (attr_value (integer)))
(attribute (attr_key) (attr_value (integer)))
(attribute (attr_key) (attr_value))
(attribute (attr_key) (attr_value (escape_sequence)))
)
)
)

View file

@ -103,6 +103,21 @@ a: Foo Bar; b: Biz Baz
(shape (shape_key) (label))
)
================================================================================
Label with escape sequence
================================================================================
a: Foo\nB\#ar
a: Foo\nB\@r; b: Biz\nBaz
--------------------------------------------------------------------------------
(source_file
(shape (shape_key) (label (escape_sequence) (escape_sequence)))
(shape (shape_key) (label (escape_sequence) (escape_sequence)))
(shape (shape_key) (label (escape_sequence)))
)
================================================================================
It should skip white spaces
================================================================================

View file

@ -26,7 +26,6 @@ foo: Label {
# ^ property
}
foo: {
style: {
opacity: 0.5
@ -43,3 +42,18 @@ foo: {
# ^ boolean
}
}
foo: Label {
tooltip: Gee, I feel kind of LIGHT in the head now,\nknowing I can't make my satellite dish PAYMENTS!
# <- property
# ^ string
# ^ string.escape
link: https://microsoft.com
# <- property
# ^ string
style.fill: red
# <- property
# ^ property
}

View file

@ -35,3 +35,10 @@ foo: Foo Bar {
# ^ variable
}
# <- punctuation.bracket
foo: Foo\#Ba\@r {
# ^ text.title
# ^ string.escape
# ^ text.title
# ^ string.escape
}

Binary file not shown.