parent
731be00903
commit
e7507ddd98
29
grammar.js
29
grammar.js
|
@ -69,6 +69,7 @@ module.exports = grammar({
|
||||||
[$.class_list],
|
[$.class_list],
|
||||||
[$.attr_value_list],
|
[$.attr_value_list],
|
||||||
[$._text_block_attrs],
|
[$._text_block_attrs],
|
||||||
|
[$._identifier],
|
||||||
],
|
],
|
||||||
|
|
||||||
rules: {
|
rules: {
|
||||||
|
@ -93,12 +94,24 @@ module.exports = grammar({
|
||||||
|
|
||||||
connection: ($) =>
|
connection: ($) =>
|
||||||
seq(
|
seq(
|
||||||
$._connection_path,
|
choice(
|
||||||
repeat1(seq($.arrow, $._connection_path)),
|
$._full_connection_path,
|
||||||
|
alias($._referencing_full_connection_path, $.referencing)
|
||||||
|
),
|
||||||
optional(seq($._colon, optional($.label))),
|
optional(seq($._colon, optional($.label))),
|
||||||
optional(seq(alias($._connection_block, $.block)))
|
optional(seq(alias($._connection_block, $.block)))
|
||||||
),
|
),
|
||||||
|
|
||||||
|
_referencing_full_connection_path: ($) =>
|
||||||
|
seq("(", $._full_connection_path, $._referencing_end, optional($.index)),
|
||||||
|
|
||||||
|
_referencing_end: ($) => token(prec(PREC.IDENTIFIER + 1, ")")),
|
||||||
|
|
||||||
|
index: ($) => seq("[", $.integer, "]"),
|
||||||
|
|
||||||
|
_full_connection_path: ($) =>
|
||||||
|
seq($._connection_path, repeat1(seq($.arrow, $._connection_path))),
|
||||||
|
|
||||||
_connection_path: ($) =>
|
_connection_path: ($) =>
|
||||||
seq(
|
seq(
|
||||||
repeat(
|
repeat(
|
||||||
|
@ -201,11 +214,17 @@ module.exports = grammar({
|
||||||
repeat(
|
repeat(
|
||||||
choice(
|
choice(
|
||||||
$.escape_sequence,
|
$.escape_sequence,
|
||||||
token(prec(PREC.IDENTIFIER, /[\w\d'"$(),]+/)),
|
token(prec(PREC.IDENTIFIER, /[\w\d'"$(,]+/)),
|
||||||
token(prec(PREC.IDENTIFIER, /( +|-)[\w\d'"$()]+/))
|
token(prec(PREC.IDENTIFIER, /( +|-)[\w\d'"$(]+/)),
|
||||||
|
token(prec(PREC.IDENTIFIER, ")"))
|
||||||
|
)
|
||||||
|
),
|
||||||
|
optional(
|
||||||
|
choice(
|
||||||
|
token(prec(PREC.IDENTIFIER, /[\w\d'"$(]+/)),
|
||||||
|
token(prec(PREC.IDENTIFIER + 1, ")"))
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
optional(token(prec(PREC.IDENTIFIER, /[\w\d'"$()]+/))),
|
|
||||||
optional($._dash)
|
optional($._dash)
|
||||||
),
|
),
|
||||||
|
|
||||||
|
|
162
src/grammar.json
162
src/grammar.json
|
@ -69,24 +69,22 @@
|
||||||
"type": "SEQ",
|
"type": "SEQ",
|
||||||
"members": [
|
"members": [
|
||||||
{
|
{
|
||||||
"type": "SYMBOL",
|
"type": "CHOICE",
|
||||||
"name": "_connection_path"
|
"members": [
|
||||||
},
|
{
|
||||||
{
|
"type": "SYMBOL",
|
||||||
"type": "REPEAT1",
|
"name": "_full_connection_path"
|
||||||
"content": {
|
},
|
||||||
"type": "SEQ",
|
{
|
||||||
"members": [
|
"type": "ALIAS",
|
||||||
{
|
"content": {
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "arrow"
|
"name": "_referencing_full_connection_path"
|
||||||
},
|
},
|
||||||
{
|
"named": true,
|
||||||
"type": "SYMBOL",
|
"value": "referencing"
|
||||||
"name": "_connection_path"
|
}
|
||||||
}
|
]
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "CHOICE",
|
"type": "CHOICE",
|
||||||
|
@ -141,6 +139,88 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"_referencing_full_connection_path": {
|
||||||
|
"type": "SEQ",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "("
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "_full_connection_path"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "_referencing_end"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "CHOICE",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "index"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "BLANK"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"_referencing_end": {
|
||||||
|
"type": "TOKEN",
|
||||||
|
"content": {
|
||||||
|
"type": "PREC",
|
||||||
|
"value": 1,
|
||||||
|
"content": {
|
||||||
|
"type": "STRING",
|
||||||
|
"value": ")"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"index": {
|
||||||
|
"type": "SEQ",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "["
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "integer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "]"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"_full_connection_path": {
|
||||||
|
"type": "SEQ",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "_connection_path"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "REPEAT1",
|
||||||
|
"content": {
|
||||||
|
"type": "SEQ",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "arrow"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "_connection_path"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
"_connection_path": {
|
"_connection_path": {
|
||||||
"type": "SEQ",
|
"type": "SEQ",
|
||||||
"members": [
|
"members": [
|
||||||
|
@ -893,7 +973,7 @@
|
||||||
"value": 0,
|
"value": 0,
|
||||||
"content": {
|
"content": {
|
||||||
"type": "PATTERN",
|
"type": "PATTERN",
|
||||||
"value": "[\\w\\d'\"$(),]+"
|
"value": "[\\w\\d'\"$(,]+"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -904,7 +984,18 @@
|
||||||
"value": 0,
|
"value": 0,
|
||||||
"content": {
|
"content": {
|
||||||
"type": "PATTERN",
|
"type": "PATTERN",
|
||||||
"value": "( +|-)[\\w\\d'\"$()]+"
|
"value": "( +|-)[\\w\\d'\"$(]+"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "TOKEN",
|
||||||
|
"content": {
|
||||||
|
"type": "PREC",
|
||||||
|
"value": 0,
|
||||||
|
"content": {
|
||||||
|
"type": "STRING",
|
||||||
|
"value": ")"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -915,15 +1006,31 @@
|
||||||
"type": "CHOICE",
|
"type": "CHOICE",
|
||||||
"members": [
|
"members": [
|
||||||
{
|
{
|
||||||
"type": "TOKEN",
|
"type": "CHOICE",
|
||||||
"content": {
|
"members": [
|
||||||
"type": "PREC",
|
{
|
||||||
"value": 0,
|
"type": "TOKEN",
|
||||||
"content": {
|
"content": {
|
||||||
"type": "PATTERN",
|
"type": "PREC",
|
||||||
"value": "[\\w\\d'\"$()]+"
|
"value": 0,
|
||||||
|
"content": {
|
||||||
|
"type": "PATTERN",
|
||||||
|
"value": "[\\w\\d'\"$(]+"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "TOKEN",
|
||||||
|
"content": {
|
||||||
|
"type": "PREC",
|
||||||
|
"value": 1,
|
||||||
|
"content": {
|
||||||
|
"type": "STRING",
|
||||||
|
"value": ")"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "BLANK"
|
"type": "BLANK"
|
||||||
|
@ -2287,6 +2394,9 @@
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"_text_block_attrs"
|
"_text_block_attrs"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"_identifier"
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"precedences": [],
|
"precedences": [],
|
||||||
|
|
|
@ -261,7 +261,7 @@
|
||||||
"fields": {},
|
"fields": {},
|
||||||
"children": {
|
"children": {
|
||||||
"multiple": true,
|
"multiple": true,
|
||||||
"required": true,
|
"required": false,
|
||||||
"types": [
|
"types": [
|
||||||
{
|
{
|
||||||
"type": "arrow",
|
"type": "arrow",
|
||||||
|
@ -283,6 +283,10 @@
|
||||||
"type": "label",
|
"type": "label",
|
||||||
"named": true
|
"named": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "referencing",
|
||||||
|
"named": true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "shape_key",
|
"type": "shape_key",
|
||||||
"named": true
|
"named": true
|
||||||
|
@ -348,6 +352,21 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "index",
|
||||||
|
"named": true,
|
||||||
|
"fields": {},
|
||||||
|
"children": {
|
||||||
|
"multiple": false,
|
||||||
|
"required": true,
|
||||||
|
"types": [
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"named": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "label",
|
"type": "label",
|
||||||
"named": true,
|
"named": true,
|
||||||
|
@ -367,6 +386,37 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "referencing",
|
||||||
|
"named": true,
|
||||||
|
"fields": {},
|
||||||
|
"children": {
|
||||||
|
"multiple": true,
|
||||||
|
"required": false,
|
||||||
|
"types": [
|
||||||
|
{
|
||||||
|
"type": "arrow",
|
||||||
|
"named": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "container_key",
|
||||||
|
"named": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "dot",
|
||||||
|
"named": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "index",
|
||||||
|
"named": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "shape_key",
|
||||||
|
"named": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "reserved",
|
"type": "reserved",
|
||||||
"named": true,
|
"named": true,
|
||||||
|
@ -511,6 +561,14 @@
|
||||||
"type": "'",
|
"type": "'",
|
||||||
"named": false
|
"named": false
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "(",
|
||||||
|
"named": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": ")",
|
||||||
|
"named": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "3d",
|
"type": "3d",
|
||||||
"named": false
|
"named": false
|
||||||
|
|
BIN
src/parser.c
BIN
src/parser.c
Binary file not shown.
|
@ -248,7 +248,7 @@ Connection with espaced key fragments
|
||||||
|
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
Connection with espaced key fragments
|
Diclare a connection with espaced key fragments
|
||||||
================================================================================
|
================================================================================
|
||||||
\#hello\[\] -- \[world\]
|
\#hello\[\] -- \[world\]
|
||||||
|
|
||||||
|
@ -268,3 +268,111 @@ Connection with espaced key fragments
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
Declare a referencing connection
|
||||||
|
================================================================================
|
||||||
|
(x() -> y())
|
||||||
|
(x() -> y())[0]
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
(source_file
|
||||||
|
(connection
|
||||||
|
(referencing
|
||||||
|
(shape_key)
|
||||||
|
(arrow)
|
||||||
|
(shape_key)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(connection
|
||||||
|
(referencing
|
||||||
|
(shape_key)
|
||||||
|
(arrow)
|
||||||
|
(shape_key)
|
||||||
|
(index (integer))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
Declare a referencing connection with label
|
||||||
|
================================================================================
|
||||||
|
(x -> y): label
|
||||||
|
(x -> y)[0]: label
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
(source_file
|
||||||
|
(connection
|
||||||
|
(referencing
|
||||||
|
(shape_key)
|
||||||
|
(arrow)
|
||||||
|
(shape_key)
|
||||||
|
)
|
||||||
|
(label)
|
||||||
|
)
|
||||||
|
(connection
|
||||||
|
(referencing
|
||||||
|
(shape_key)
|
||||||
|
(arrow)
|
||||||
|
(shape_key)
|
||||||
|
(index (integer))
|
||||||
|
)
|
||||||
|
(label)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
Declare a referencing connection with block
|
||||||
|
================================================================================
|
||||||
|
(x() -> y()): {
|
||||||
|
style.stroke: \#ff0000
|
||||||
|
}
|
||||||
|
(x -> y)[0]: {
|
||||||
|
style.stroke: \#ff0000
|
||||||
|
}
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
(source_file
|
||||||
|
(connection
|
||||||
|
(referencing
|
||||||
|
(shape_key)
|
||||||
|
(arrow)
|
||||||
|
(shape_key)
|
||||||
|
)
|
||||||
|
(block
|
||||||
|
(attribute
|
||||||
|
(keyword_style)
|
||||||
|
(dot)
|
||||||
|
(attribute
|
||||||
|
(attr_key)
|
||||||
|
(attr_value
|
||||||
|
(escape_sequence)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(connection
|
||||||
|
(referencing
|
||||||
|
(shape_key)
|
||||||
|
(arrow)
|
||||||
|
(shape_key)
|
||||||
|
(index (integer))
|
||||||
|
)
|
||||||
|
(block
|
||||||
|
(attribute
|
||||||
|
(keyword_style)
|
||||||
|
(dot)
|
||||||
|
(attribute
|
||||||
|
(attr_key)
|
||||||
|
(attr_value
|
||||||
|
(escape_sequence)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue