Skip to content

Commit

Permalink
Merge #31 fix: errors from single ' or |
Browse files Browse the repository at this point in the history
  • Loading branch information
justinmk authored Oct 9, 2022
2 parents d595021 + 6cd420d commit c03640a
Show file tree
Hide file tree
Showing 5 changed files with 3,257 additions and 3,188 deletions.
34 changes: 34 additions & 0 deletions corpus/optionlink.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,40 @@ world 'hello' world
(word))
(word))))

================================================================================
NOT optionlink: ' followed by whitespace
================================================================================
'fillchars'
stl ' ' or '^' statusline
wbr ' ' windowbar
tricky: ' 'yes'


--------------------------------------------------------------------------------

(help_file
(block
(line
(optionlink
(word)))
(line
(word)
(word)
(word)
(word)
(word)
(word))
(line
(word)
(word)
(word)
(word))
(line
(word)
(word)
(optionlink
(word)))))

================================================================================
NOT optionlink #7 #14
================================================================================
Expand Down
14 changes: 13 additions & 1 deletion corpus/taglink.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ taglink in parentheses
================================================================================
NOT a taglink
================================================================================

whitespace |world foo bar|
|
rx |
rx | ry
adjacent || |||
table-borders |=========| |---------|

Expand All @@ -93,6 +95,16 @@ Note: ":autocmd" can...
(MISSING "|"))
(word)
(word))
(line
(word
(MISSING "_word_common_token5")))
(line
(word)
(ERROR))
(line
(word)
(word)
(word))
(line
(word)
(word)
Expand Down
6 changes: 4 additions & 2 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,15 @@ module.exports = grammar({
// Explicit special cases: these are plaintext, not errors.
_word_common: () => choice(
// NOT optionlink: single "'".
/[\t ]'[\t ]/,
/'[\t ]/,
// NOT optionlink: contains any non-lowercase char.
seq("'", token.immediate(/[^'\n\t ]*[^'a-z\n\t ][^'\n\t ]*/), token.immediate("'")),
// NOT optionlink: single char surrounded by "'".
seq("'", token.immediate(/[^'\n\t ]/), token.immediate("'")),
// NOT taglink: single "|".
/[\t ]\|[\t ]/,
/\|[\t ]/,
// NOT taglink: "|foo".
seq('|', /[^|\n\t ]+/),
// NOT taglink: "||".
/\|\|*/,
// NOT argument: "{}".
Expand Down
17 changes: 15 additions & 2 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
"members": [
{
"type": "PATTERN",
"value": "[\\t ]'[\\t ]"
"value": "'[\\t ]"
},
{
"type": "SEQ",
Expand Down Expand Up @@ -219,7 +219,20 @@
},
{
"type": "PATTERN",
"value": "[\\t ]\\|[\\t ]"
"value": "\\|[\\t ]"
},
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "|"
},
{
"type": "PATTERN",
"value": "[^|\\n\\t ]+"
}
]
},
{
"type": "PATTERN",
Expand Down
Loading

0 comments on commit c03640a

Please sign in to comment.