Skip to content

Commit 031031f

Browse files
committed
fix: add alias to (expr) for block end name
1 parent 428fd9a commit 031031f

File tree

5 files changed

+213
-158
lines changed

5 files changed

+213
-158
lines changed

corpus/basic.tst

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,10 @@ Block.1 - Empty
349349
--------------------------------------------------------------------------------
350350

351351
(document
352-
(body
352+
body: (body
353353
(block
354-
(expr))))
354+
name: (expr)
355+
end_name: (expr))))
355356

356357
================================================================================
357358
Block.2 - Contents
@@ -362,12 +363,13 @@ a
362363
--------------------------------------------------------------------------------
363364

364365
(document
365-
(body
366+
body: (body
366367
(block
367-
(expr)
368-
(expr)
369-
(contents
370-
(expr)))))
368+
name: (expr)
369+
parameter: (expr)
370+
contents: (contents
371+
(expr))
372+
end_name: (expr))))
371373

372374
================================================================================
373375
Block.3 - In section
@@ -380,17 +382,18 @@ a
380382
--------------------------------------------------------------------------------
381383

382384
(document
383-
(section
384-
(headline
385-
(stars)
386-
(item
385+
subsection: (section
386+
headline: (headline
387+
stars: (stars)
388+
item: (item
387389
(expr)))
388-
(body
390+
body: (body
389391
(block
390-
(expr)
391-
(expr)
392-
(contents
393-
(expr))))))
392+
name: (expr)
393+
parameter: (expr)
394+
contents: (contents
395+
(expr))
396+
end_name: (expr)))))
394397

395398
================================================================================
396399
Block.4 - lowercase
@@ -400,9 +403,10 @@ Block.4 - lowercase
400403
--------------------------------------------------------------------------------
401404

402405
(document
403-
(body
406+
body: (body
404407
(block
405-
(expr))))
408+
name: (expr)
409+
end_name: (expr))))
406410

407411
================================================================================
408412
DynamicBlock.1 - Empty

grammar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ org_grammar = {
222222
$._nl,
223223
optional(field('contents', $.contents)),
224224
caseInsensitive('#+end_'),
225-
$._immediate_expr,
225+
field('end_name',alias($._immediate_expr, $.expr)),
226226
$._eol,
227227
),
228228

src/grammar.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,8 +1250,17 @@
12501250
"value": "#+end_"
12511251
},
12521252
{
1253-
"type": "SYMBOL",
1254-
"name": "_immediate_expr"
1253+
"type": "FIELD",
1254+
"name": "end_name",
1255+
"content": {
1256+
"type": "ALIAS",
1257+
"content": {
1258+
"type": "SYMBOL",
1259+
"name": "_immediate_expr"
1260+
},
1261+
"named": true,
1262+
"value": "expr"
1263+
}
12551264
},
12561265
{
12571266
"type": "SYMBOL",

src/node-types.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@
2323
}
2424
]
2525
},
26+
"end_name": {
27+
"multiple": false,
28+
"required": true,
29+
"types": [
30+
{
31+
"type": "expr",
32+
"named": true
33+
}
34+
]
35+
},
2636
"name": {
2737
"multiple": false,
2838
"required": true,

0 commit comments

Comments
 (0)