Skip to content

Commit

Permalink
fix: broken parsing of values with special chars
Browse files Browse the repository at this point in the history
  • Loading branch information
vhyrro committed Oct 9, 2022
1 parent 4687b53 commit e93dcbc
Show file tree
Hide file tree
Showing 3 changed files with 637 additions and 545 deletions.
16 changes: 7 additions & 9 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ module.exports = grammar({
key: _ => /[^\-\s:][^\s:]*/,

value: $ => seq(
/[^\s\[\]\{\}][^\n\[\]\{\}\~]*/,
/[^\s][^\n\~]*/,
optional(
choice(
seq(
"~",
/[^\n\[\]\{\}\~]+/,
/[^\n\~]+/,
),
seq(
"~\n",
Expand Down Expand Up @@ -47,14 +47,12 @@ module.exports = grammar({
$.key,
token.immediate(':'),
/[\t\v ]*/,
seq(
choice(
$.array,
$.value,
$.object,
'\n',
),
choice(
$.array,
$.value,
$.object,
),
optional(token.immediate('\n')),
),

delimiter: _ => seq(
Expand Down
50 changes: 28 additions & 22 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"members": [
{
"type": "PATTERN",
"value": "[^\\s\\[\\]\\{\\}][^\\n\\[\\]\\{\\}\\~]*"
"value": "[^\\s][^\\n\\~]*"
},
{
"type": "CHOICE",
Expand All @@ -43,7 +43,7 @@
},
{
"type": "PATTERN",
"value": "[^\\n\\[\\]\\{\\}\\~]+"
"value": "[^\\n\\~]+"
}
]
},
Expand Down Expand Up @@ -146,28 +146,34 @@
"value": "[\\t\\v ]*"
},
{
"type": "SEQ",
"type": "CHOICE",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "array"
},
{
"type": "SYMBOL",
"name": "value"
},
{
"type": "SYMBOL",
"name": "object"
},
{
"type": "STRING",
"value": "\n"
}
]
"type": "SYMBOL",
"name": "array"
},
{
"type": "SYMBOL",
"name": "value"
},
{
"type": "SYMBOL",
"name": "object"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "STRING",
"value": "\n"
}
},
{
"type": "BLANK"
}
]
}
Expand Down
Loading

0 comments on commit e93dcbc

Please sign in to comment.