fix: immediate hash in string is considered content instead of comment (#18)

This commit is contained in:
Ika 2020-11-14 12:57:50 +08:00 committed by GitHub
parent e1aa4dd51b
commit 4993307f61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 782 additions and 803 deletions

19
corpus/issues.txt Normal file
View file

@ -0,0 +1,19 @@
================================================================================
VALID - issue #17 - immediate hash in string is considered content instead of comment
================================================================================
# This is a full-line comment
key = "value" # This is a comment at the end of a line
another = "# This is not a comment"
--------------------------------------------------------------------------------
(document
(comment)
(pair
(bare_key)
(string)
(comment))
(pair
(bare_key)
(string)))

View file

@ -40,7 +40,10 @@ module.exports = grammar({
),
comment: $ =>
token(seq("#", repeat(getInverseRegex(control_chars.subtract("\t"))))),
token(prec(-1, seq(
"#",
repeat(getInverseRegex(control_chars.subtract("\t"))),
))),
table: $ =>
seq(

30
src/grammar.json generated
View file

@ -41,20 +41,24 @@
"comment": {
"type": "TOKEN",
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "#"
},
{
"type": "REPEAT",
"content": {
"type": "PATTERN",
"value": "[^\\u0000-\\u0008\\u000a-\\u001f\\u007f]"
"type": "PREC",
"value": -1,
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "#"
},
{
"type": "REPEAT",
"content": {
"type": "PATTERN",
"value": "[^\\u0000-\\u0008\\u000a-\\u001f\\u007f]"
}
}
}
]
]
}
}
},
"table": {

1531
src/parser.c generated

File diff suppressed because it is too large Load diff