Skip to content

Commit

Permalink
fix: support comments as part of key value lists
Browse files Browse the repository at this point in the history
  • Loading branch information
korrat authored and Brian Ryall committed Mar 29, 2024
1 parent 9f6eb73 commit c25f803
Show file tree
Hide file tree
Showing 5 changed files with 7,723 additions and 5,191 deletions.
15 changes: 13 additions & 2 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ module.exports = grammar({
$.posting,
seq(
$._indent,
$.comment,
field("comment", $.comment),
$._eol
)
)
Expand Down Expand Up @@ -326,7 +326,12 @@ module.exports = grammar({
),
seq(
$._key_value_line
)
),
seq(
$._indent,
field("comment", $.comment),
$._eol
),
)
),

Expand Down Expand Up @@ -522,6 +527,7 @@ module.exports = grammar({
"price",
field("currency", $.currency),
field("amount", $.amount),
field("comment", optional($.comment)),
$._eol,
optional($._key_value_list)
),
Expand All @@ -532,6 +538,7 @@ module.exports = grammar({
"event",
field("type", $.string),
field("desc", $.string),
field("comment", optional($.comment)),
$._eol,
optional($._key_value_list)
),
Expand All @@ -542,6 +549,7 @@ module.exports = grammar({
"query",
field("name", $.string),
field("query", $.string),
field("comment", optional($.comment)),
$._eol,
optional($._key_value_list)
),
Expand All @@ -552,6 +560,7 @@ module.exports = grammar({
"note",
field("account", $.account),
field("note", $.string),
field("comment", optional($.comment)),
$._eol,
optional($._key_value_list)
),
Expand All @@ -565,6 +574,7 @@ module.exports = grammar({
field("account", $.account),
field("filename", $.filename),
field("tags_links", optional($.tags_links)),
field("comment", optional($.comment)),
$._eol,
optional($._key_value_list)
),
Expand All @@ -590,6 +600,7 @@ module.exports = grammar({
$.custom_value
),
)),
field("comment", optional($.comment)),
$._eol,
optional($._key_value_list)
),
Expand Down
125 changes: 123 additions & 2 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -653,8 +653,12 @@
"name": "_indent"
},
{
"type": "SYMBOL",
"name": "comment"
"type": "FIELD",
"name": "comment",
"content": {
"type": "SYMBOL",
"name": "comment"
}
},
{
"type": "SYMBOL",
Expand Down Expand Up @@ -1174,6 +1178,27 @@
"name": "_key_value_line"
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_indent"
},
{
"type": "FIELD",
"name": "comment",
"content": {
"type": "SYMBOL",
"name": "comment"
}
},
{
"type": "SYMBOL",
"name": "_eol"
}
]
}
]
}
Expand Down Expand Up @@ -1920,6 +1945,22 @@
"name": "amount"
}
},
{
"type": "FIELD",
"name": "comment",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "comment"
},
{
"type": "BLANK"
}
]
}
},
{
"type": "SYMBOL",
"name": "_eol"
Expand Down Expand Up @@ -1969,6 +2010,22 @@
"name": "string"
}
},
{
"type": "FIELD",
"name": "comment",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "comment"
},
{
"type": "BLANK"
}
]
}
},
{
"type": "SYMBOL",
"name": "_eol"
Expand Down Expand Up @@ -2018,6 +2075,22 @@
"name": "string"
}
},
{
"type": "FIELD",
"name": "comment",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "comment"
},
{
"type": "BLANK"
}
]
}
},
{
"type": "SYMBOL",
"name": "_eol"
Expand Down Expand Up @@ -2067,6 +2140,22 @@
"name": "string"
}
},
{
"type": "FIELD",
"name": "comment",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "comment"
},
{
"type": "BLANK"
}
]
}
},
{
"type": "SYMBOL",
"name": "_eol"
Expand Down Expand Up @@ -2136,6 +2225,22 @@
]
}
},
{
"type": "FIELD",
"name": "comment",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "comment"
},
{
"type": "BLANK"
}
]
}
},
{
"type": "SYMBOL",
"name": "_eol"
Expand Down Expand Up @@ -2225,6 +2330,22 @@
]
}
},
{
"type": "FIELD",
"name": "comment",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "comment"
},
{
"type": "BLANK"
}
]
}
},
{
"type": "SYMBOL",
"name": "_eol"
Expand Down
Loading

0 comments on commit c25f803

Please # to comment.