use regex for arrow to fix long arrow bug

This commit is contained in:
Dmitriy Pleshevskiy 2022-12-08 01:30:23 +03:00
parent 6835da6d3c
commit 8921cc8bbc
Signed by: pleshevskiy
GPG key ID: 1B59187B161C0215
5 changed files with 42 additions and 87 deletions

View file

@ -9,7 +9,6 @@ module.exports = grammar({
conflicts: ($) => [ conflicts: ($) => [
[$.shape_key], [$.shape_key],
[$.arrow],
[$._shape_path], [$._shape_path],
[$._shape_block], [$._shape_block],
[$._shape_block_definition], [$._shape_block_definition],
@ -174,13 +173,7 @@ module.exports = grammar({
_arrow: ($) => seq(spaces, $.arrow), _arrow: ($) => seq(spaces, $.arrow),
arrow: ($) => arrow: ($) => choice(/-+>/, /--+/, /<-+/, /<-+>/),
choice(
seq("--", repeat($._dash)),
seq("<-", repeat($._dash)),
seq("<-", repeat($._dash), ">"),
seq(repeat($._dash), "->")
),
_dash: ($) => token.immediate("-"), _dash: ($) => token.immediate("-"),

View file

@ -1007,72 +1007,20 @@
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [
{ {
"type": "SEQ", "type": "PATTERN",
"members": [ "value": "-+>"
{
"type": "STRING",
"value": "--"
}, },
{ {
"type": "REPEAT", "type": "PATTERN",
"content": { "value": "--+"
"type": "SYMBOL",
"name": "_dash"
}
}
]
}, },
{ {
"type": "SEQ", "type": "PATTERN",
"members": [ "value": "<-+"
{
"type": "STRING",
"value": "<-"
}, },
{ {
"type": "REPEAT", "type": "PATTERN",
"content": { "value": "<-+>"
"type": "SYMBOL",
"name": "_dash"
}
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "<-"
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_dash"
}
},
{
"type": "STRING",
"value": ">"
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_dash"
}
},
{
"type": "STRING",
"value": "->"
}
]
} }
] ]
}, },
@ -1274,9 +1222,6 @@
[ [
"shape_key" "shape_key"
], ],
[
"arrow"
],
[ [
"_shape_path" "_shape_path"
], ],

View file

@ -254,14 +254,6 @@
"type": "'", "type": "'",
"named": false "named": false
}, },
{
"type": "--",
"named": false
},
{
"type": "->",
"named": false
},
{ {
"type": "3d", "type": "3d",
"named": false "named": false
@ -274,14 +266,6 @@
"type": ";", "type": ";",
"named": false "named": false
}, },
{
"type": "<-",
"named": false
},
{
"type": ">",
"named": false
},
{ {
"type": "`", "type": "`",
"named": false "named": false

Binary file not shown.

View file

@ -64,6 +64,39 @@ biz <- baz
) )
) )
================================================================================
Connection with looooong arrow
================================================================================
foo ----------- bar
biz ----------> baz
biz <---------> baz
biz <---------- baz
--------------------------------------------------------------------------------
(source_file
(connection
(shape_key)
(arrow)
(shape_key)
)
(connection
(shape_key)
(arrow)
(shape_key)
)
(connection
(shape_key)
(arrow)
(shape_key)
)
(connection
(shape_key)
(arrow)
(shape_key)
)
)
================================================================================ ================================================================================
Complex identifier connection Complex identifier connection