Skip to content

Commit d1a283b

Browse files
committed
use prec() more surgically
1 parent 65bcf74 commit d1a283b

File tree

4 files changed

+12
-19
lines changed

4 files changed

+12
-19
lines changed

corpus/arguments.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,7 @@ EXTERNAL *netrw-externapp* {{{2
101101
(word)
102102
(word)
103103
(word)
104-
(ERROR
105-
(word))
104+
(word)
106105
(word)
107106
(word)
108107
(word)

corpus/line_block.txt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,7 @@ li continues
130130
(line_li
131131
(line
132132
(word)
133-
(word
134-
(ERROR
135-
(word)))
133+
(word)
136134
(word)
137135
(word)
138136
(word))
@@ -149,9 +147,7 @@ li continues
149147
(block
150148
(line_li
151149
(line
152-
(word
153-
(ERROR
154-
(word)))
150+
(word)
155151
(word)
156152
(word))
157153
(line))

corpus/optionlink.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,7 @@ Regular / :help /[
109109
(word)
110110
(word)
111111
(word)
112-
(word
113-
(ERROR
114-
(word))))
112+
(word))
115113
(line
116114
(word)
117115
(word)

grammar.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@ module.exports = grammar({
3737
$._word_common,
3838
),
3939

40-
_atom_noli: ($) => prec(1, choice(
40+
_atom_noli: ($) => choice(
4141
alias($.word_noli, $.word),
4242
$._atom_common,
43-
)),
44-
word_noli: ($) => prec(1, choice(
43+
),
44+
word_noli: ($) => choice(
4545
// Lines contained by line_li must not start with a listitem symbol.
4646
token(prec(-1, /[^-\n\t ][^\n\t ]*/)),
4747
token(prec(-1, /[-][^\n\t ]+/)),
4848
$._word_common,
49-
)),
49+
),
5050

5151
_atom_common: ($) =>
5252
choice(
@@ -193,7 +193,7 @@ module.exports = grammar({
193193
),
194194

195195
tag: ($) => _word($,
196-
/[^*\n\t ]+/, // Tag text without surrounding "*".
196+
prec(1, /[^*\n\t ]+/), // Tag text without surrounding "*".
197197
'*', '*'),
198198

199199
// URL without surrounding (), [], etc.
@@ -207,15 +207,15 @@ module.exports = grammar({
207207
// Link to option: 'foo'. Lowercase non-digit ASCII, minimum 2 chars. #14
208208
optionlink: ($) => _word($, /[a-z][a-z]+/, "'", "'"),
209209
// Link to tag: |foo|
210-
taglink: ($) => _word($, choice(
210+
taglink: ($) => _word($, prec(1, choice(
211211
/[^|\n\t ]+/,
212212
// Special cases: |(| |{| …
213213
'{',
214214
'}',
215215
'(',
216216
')',
217217
'`',
218-
),
218+
)),
219219
'|', '|'),
220220
// Inline code (may contain whitespace!): `foo bar`
221221
codespan: ($) => _word($, /[^``\n]+/, '`', '`'),
@@ -231,5 +231,5 @@ function _word($, rule, c1, c2, fname) {
231231
// rule = rule.test ? token.immediate(rule) : rule
232232
// rule = token.immediate(rule)
233233
fname = fname ?? 'text';
234-
return seq(c1, field(fname, alias(token.immediate(prec(1, rule)), $.word)), token.immediate(c2));
234+
return seq(c1, field(fname, alias(token.immediate(rule), $.word)), token.immediate(c2));
235235
}

0 commit comments

Comments
 (0)