Skip to content

Commit

Permalink
feat: add connection identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
ravsii committed Jul 27, 2023
1 parent 5acc0a2 commit bf331ef
Show file tree
Hide file tree
Showing 5 changed files with 866 additions and 327 deletions.
10 changes: 10 additions & 0 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,22 @@ module.exports = grammar({
)),

expression: $ => prec.right(seq(
optional("("),
repeat1(choice(
$.identifier,
$.connection,
)),
optional(")"),
optional(seq(
$.connection_identifier,
$.sub_identifier
)),
optional($.label),
optional(choice(/\n+/, ";")),
)),



label: _ => seq(":", choice(
// seq("|", /.+/, "|"),
/.+/,
Expand Down Expand Up @@ -79,6 +87,8 @@ module.exports = grammar({
seq(/<-+/, /\\\n+\s+/, /-+>/),
),

connection_identifier: _ => /\[\d+\]/,

// param_value: _ => /[\w\-_]+/i,

// const-like rules
Expand Down
49 changes: 49 additions & 0 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@
"content": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "("
},
{
"type": "BLANK"
}
]
},
{
"type": "REPEAT1",
"content": {
Expand All @@ -86,6 +98,39 @@
]
}
},
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": ")"
},
{
"type": "BLANK"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "connection_identifier"
},
{
"type": "SYMBOL",
"name": "sub_identifier"
}
]
},
{
"type": "BLANK"
}
]
},
{
"type": "CHOICE",
"members": [
Expand Down Expand Up @@ -266,6 +311,10 @@
}
]
},
"connection_identifier": {
"type": "PATTERN",
"value": "\\[\\d+\\]"
},
"_ident_regex": {
"type": "PATTERN",
"value": "[\\p{L}0-9_\"' ]+"
Expand Down
20 changes: 20 additions & 0 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,21 @@
"type": "connection",
"named": true
},
{
"type": "connection_identifier",
"named": true
},
{
"type": "identifier",
"named": true
},
{
"type": "label",
"named": true
},
{
"type": "sub_identifier",
"named": true
}
]
}
Expand Down Expand Up @@ -77,6 +85,14 @@
]
}
},
{
"type": "(",
"named": false
},
{
"type": ")",
"named": false
},
{
"type": "-",
"named": false
Expand All @@ -93,6 +109,10 @@
"type": ";",
"named": false
},
{
"type": "connection_identifier",
"named": true
},
{
"type": "direction",
"named": false
Expand Down
Loading

0 comments on commit bf331ef

Please sign in to comment.