Skip to content

Commit

Permalink
fix: invalid optionlink #48
Browse files Browse the repository at this point in the history
fix #45
fix #46
  • Loading branch information
justinmk authored Oct 18, 2022
1 parent eb90ebc commit 30cd470
Show file tree
Hide file tree
Showing 6 changed files with 5,082 additions and 4,867 deletions.
1 change: 1 addition & 0 deletions corpus/line_block.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ li continues
(word)
(word)
(word)
(word)
(word))
(line)
(line
Expand Down
35 changes: 26 additions & 9 deletions corpus/optionlink.txt
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,22 @@ number: '04' 'ISO-10646-1' 'python3'
(word)
(word)
(word)
(word)
(tag
(word)
(MISSING "*"))
(word)
(word)
(word)
(ERROR
(word))
(argument
(word))
(word)
(word))
(line
(word)
(word)
(word)
(word)
(word)
Expand All @@ -121,7 +135,7 @@ number: '04' 'ISO-10646-1' 'python3'
(word))))

================================================================================
NOT optionlink 2 (FIXME)
NOT optionlink 2
================================================================================
'{a-z} `{a-z} foo
x `after_codespan`'s
Expand All @@ -130,21 +144,22 @@ x `after_codespan`'s
--------------------------------------------------------------------------------

(help_file
(ERROR)
(block
(line
(argument
(word))
(word))
(word)
(word)
(codespan
(word)
(MISSING "`")))
(line
(word)
(codespan
(word))
(word
(MISSING "'")))))
(word)
(ERROR))))

================================================================================
NOT optionlink 3 (FIXME)
NOT optionlink 3
================================================================================
foo '"\ '. Notice
|foo|
Expand All @@ -156,7 +171,9 @@ foo '"\ '. Notice
(block
(line
(word)
(ERROR)
(word)
(word)
(word)
(word))
(line
(taglink
Expand Down
2 changes: 2 additions & 0 deletions corpus/taglink.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ Note: ":autocmd" can...
(word)
(word))
(line
(word)
(word)
(word)
(word))
(line
Expand Down
6 changes: 3 additions & 3 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ module.exports = grammar({
// Explicit special cases: these are plaintext, not errors.
_word_common: () => choice(
// NOT optionlink: single "'".
/'[\t ]/,
// NOT optionlink: contains any non-lowercase char.
seq("'", token.immediate(/[^'\n\t ]*[^'a-z\n\t ][^'\n\t ]*/), token.immediate("'")),
"'",
// NOT optionlink: followed by non-lowercase char.
seq("'", token.immediate(/[a-z]*[^'a-z\n\t ][a-z]*/), optional(token.immediate("'"))),
// NOT optionlink: single char surrounded by "'".
seq("'", token.immediate(/[^'\n\t ]/), token.immediate("'")),
// NOT taglink: "||", "|"
Expand Down
24 changes: 16 additions & 8 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "'[\\t ]"
"type": "STRING",
"value": "'"
},
{
"type": "SEQ",
Expand All @@ -182,15 +182,23 @@
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "PATTERN",
"value": "[^'\\n\\t ]*[^'a-z\\n\\t ][^'\\n\\t ]*"
"value": "[a-z]*[^'a-z\\n\\t ][a-z]*"
}
},
{
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "STRING",
"value": "'"
}
"type": "CHOICE",
"members": [
{
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "STRING",
"value": "'"
}
},
{
"type": "BLANK"
}
]
}
]
},
Expand Down
Loading

0 comments on commit 30cd470

Please sign in to comment.