Skip to content

Commit eb90ebc

Browse files
authored
Merge #43 from justinmk/fixes
2 parents 22d5dcd + 9e2f26f commit eb90ebc

File tree

9 files changed

+5724
-4546
lines changed

9 files changed

+5724
-4546
lines changed

corpus/codespan.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@ an error`.
4040
(word))
4141
(word)
4242
(word)
43-
(ERROR
43+
(codespan
4444
(word)
45-
(word))
45+
(MISSING "`")))
46+
(line
47+
(word)
4648
(word))))
4749

4850
================================================================================

corpus/heading3-column_heading.txt

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,13 @@ NOT column_heading
236236
tilde ~/foo/bar foo~ bar
237237
trailing-space-is-NOT-column_heading ~
238238

239+
buffer-diagram
240+
|-----|
241+
|foo |
242+
|~ |
243+
|~ |
244+
|-----|
245+
239246

240247
--------------------------------------------------------------------------------
241248

@@ -245,7 +252,30 @@ trailing-space-is-NOT-column_heading ~
245252
(word)
246253
(word)
247254
(word)
255+
(word)
248256
(word))
249257
(line
250258
(word)
251-
(word))))
259+
(word)))
260+
(block
261+
(line
262+
(word))
263+
(line
264+
(taglink
265+
(word)))
266+
(line
267+
(word)
268+
(ERROR
269+
(word))
270+
(word))
271+
(line
272+
(word)
273+
(word)
274+
(word))
275+
(line
276+
(word)
277+
(word)
278+
(word))
279+
(line
280+
(taglink
281+
(word)))))

corpus/line_block.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ text text text text
5353
(word)
5454
(word)
5555
(word))
56-
(MISSING "help_file_token1")))
56+
(MISSING "<")))
5757

5858
================================================================================
5959
blocks: with blank line at end of document
@@ -119,6 +119,7 @@ li continues
119119
(word)
120120
(word)
121121
(word)
122+
(word)
122123
(word))
123124
(line
124125
(optionlink
@@ -128,6 +129,7 @@ li continues
128129
(word))))
129130
(line_li
130131
(line
132+
(word)
131133
(word)
132134
(word)
133135
(word))

corpus/optionlink.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,12 @@ x `after_codespan`'s
136136
(argument
137137
(word))
138138
(word))
139-
(ERROR
139+
(line
140140
(word)
141141
(codespan
142-
(word)))))
142+
(word))
143+
(word
144+
(MISSING "'")))))
143145

144146
================================================================================
145147
NOT optionlink 3 (FIXME)

corpus/taglink.txt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,16 @@ Note: ":autocmd" can...
9090
(block
9191
(line
9292
(word)
93-
(taglink
94-
(word)
95-
(MISSING "|"))
93+
(word)
94+
(ERROR
95+
(word))
9696
(word)
9797
(word))
9898
(line
99-
(word
100-
(MISSING "_word_common_token5")))
99+
(word))
101100
(line
102101
(word)
103-
(ERROR))
102+
(word))
104103
(line
105104
(word)
106105
(word)

grammar.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module.exports = grammar({
2121
rules: {
2222
help_file: ($) =>
2323
seq(
24-
repeat(/[\t ]*\n/), // Eat whitespace at top of file.
24+
repeat($._blank), // Eat blank lines at top of file.
2525
repeat($.block),
2626
),
2727

@@ -67,19 +67,19 @@ module.exports = grammar({
6767
seq("'", token.immediate(/[^'\n\t ]*[^'a-z\n\t ][^'\n\t ]*/), token.immediate("'")),
6868
// NOT optionlink: single char surrounded by "'".
6969
seq("'", token.immediate(/[^'\n\t ]/), token.immediate("'")),
70-
// NOT taglink: single "|".
71-
/\|[\t ]/,
72-
// NOT taglink: "|foo".
73-
seq('|', /[^|\n\t ]+/),
74-
// NOT taglink: "||".
75-
/\|\|*/,
70+
// NOT taglink: "||", "|"
71+
/\|\|+/,
72+
'|',
73+
// NOT listitem: "-" or "•" followed by tab.
74+
/[-]\t/,
7675
// NOT argument:
7776
'{',
7877
'}',
7978
'{}',
8079
/\{\{+[0-9]*/,
8180
'(',
8281
/\w+\(/,
82+
'~',
8383
),
8484

8585
keycode: () => choice(
@@ -126,7 +126,7 @@ module.exports = grammar({
126126
)),
127127

128128
// Lines.
129-
_blank: () => field('blank', /[\t ]*\n/),
129+
_blank: () => field('blank', '\n'),
130130
line: ($) => choice(
131131
$.column_heading,
132132
$.h1,

src/grammar.json

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
{
88
"type": "REPEAT",
99
"content": {
10-
"type": "PATTERN",
11-
"value": "[\\t ]*\\n"
10+
"type": "SYMBOL",
11+
"name": "_blank"
1212
}
1313
},
1414
{
@@ -219,24 +219,15 @@
219219
},
220220
{
221221
"type": "PATTERN",
222-
"value": "\\|[\\t ]"
222+
"value": "\\|\\|+"
223223
},
224224
{
225-
"type": "SEQ",
226-
"members": [
227-
{
228-
"type": "STRING",
229-
"value": "|"
230-
},
231-
{
232-
"type": "PATTERN",
233-
"value": "[^|\\n\\t ]+"
234-
}
235-
]
225+
"type": "STRING",
226+
"value": "|"
236227
},
237228
{
238229
"type": "PATTERN",
239-
"value": "\\|\\|*"
230+
"value": "[-•]\\t"
240231
},
241232
{
242233
"type": "STRING",
@@ -261,6 +252,10 @@
261252
{
262253
"type": "PATTERN",
263254
"value": "\\w+\\("
255+
},
256+
{
257+
"type": "STRING",
258+
"value": "~"
264259
}
265260
]
266261
},
@@ -448,8 +443,8 @@
448443
"type": "FIELD",
449444
"name": "blank",
450445
"content": {
451-
"type": "PATTERN",
452-
"value": "[\\t ]*\\n"
446+
"type": "STRING",
447+
"value": "\n"
453448
}
454449
},
455450
"line": {

src/node-types.json

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,18 @@
1818
{
1919
"type": "block",
2020
"named": true,
21-
"fields": {},
21+
"fields": {
22+
"blank": {
23+
"multiple": true,
24+
"required": false,
25+
"types": [
26+
{
27+
"type": "\n",
28+
"named": false
29+
}
30+
]
31+
}
32+
},
2233
"children": {
2334
"multiple": true,
2435
"required": true,
@@ -224,7 +235,18 @@
224235
{
225236
"type": "help_file",
226237
"named": true,
227-
"fields": {},
238+
"fields": {
239+
"blank": {
240+
"multiple": true,
241+
"required": false,
242+
"types": [
243+
{
244+
"type": "\n",
245+
"named": false
246+
}
247+
]
248+
}
249+
},
228250
"children": {
229251
"multiple": true,
230252
"required": false,
@@ -436,5 +458,9 @@
436458
{
437459
"type": "}",
438460
"named": false
461+
},
462+
{
463+
"type": "~",
464+
"named": false
439465
}
440466
]

0 commit comments

Comments
 (0)