parent
06dcd2e8af
commit
bb238e37a1
6 changed files with 44624 additions and 44428 deletions
175
corpus/basic.tst
175
corpus/basic.tst
|
|
@ -952,7 +952,7 @@ List.1a - Basic: dash [-]
|
|||
|
||||
(document
|
||||
(body
|
||||
(list (listitem))
|
||||
(list (listitem (bullet) (itemtext)))
|
||||
))
|
||||
|
||||
==========
|
||||
|
|
@ -963,7 +963,7 @@ List.1b - Basic: plus [+]
|
|||
|
||||
(document
|
||||
(body
|
||||
(list (listitem))
|
||||
(list (listitem (bullet) (itemtext)))
|
||||
))
|
||||
|
||||
==========
|
||||
|
|
@ -974,7 +974,7 @@ List.1c - Basic: star [*]
|
|||
|
||||
(document
|
||||
(body
|
||||
(list (listitem))
|
||||
(list (listitem (bullet) (itemtext)))
|
||||
))
|
||||
|
||||
==========
|
||||
|
|
@ -985,7 +985,7 @@ List.1d - Basic: count dot [1.]
|
|||
|
||||
(document
|
||||
(body
|
||||
(list (listitem))
|
||||
(list (listitem (bullet) (itemtext)))
|
||||
))
|
||||
|
||||
==========
|
||||
|
|
@ -996,7 +996,7 @@ List.1e - Basic: count paren [1)]
|
|||
|
||||
(document
|
||||
(body
|
||||
(list (listitem))
|
||||
(list (listitem (bullet) (itemtext)))
|
||||
))
|
||||
|
||||
==========
|
||||
|
|
@ -1007,7 +1007,7 @@ List.1f - Basic: letter dot [a.]
|
|||
|
||||
(document
|
||||
(body
|
||||
(list (listitem))
|
||||
(list (listitem (bullet) (itemtext)))
|
||||
))
|
||||
|
||||
==========
|
||||
|
|
@ -1018,10 +1018,31 @@ List.1g - Basic: letter paren [a)]
|
|||
|
||||
(document
|
||||
(body
|
||||
(list (listitem))
|
||||
(list (listitem (bullet) (itemtext)))
|
||||
))
|
||||
|
||||
==========
|
||||
List.1h - Basic: checkbox
|
||||
==========
|
||||
- [ ] a
|
||||
----------
|
||||
|
||||
(document
|
||||
(body
|
||||
(list (listitem (bullet) (checkbox) (itemtext)))
|
||||
))
|
||||
|
||||
==========
|
||||
List.1j - Basic: description
|
||||
==========
|
||||
- a :: description
|
||||
----------
|
||||
|
||||
(document
|
||||
(body
|
||||
(list (listitem (bullet) (description) (itemtext)))
|
||||
))
|
||||
==========
|
||||
List.2a - two items
|
||||
==========
|
||||
|
||||
|
|
@ -1032,7 +1053,7 @@ List.2a - two items
|
|||
|
||||
(document
|
||||
(body
|
||||
(list (listitem) (listitem))
|
||||
(list (listitem (bullet) (itemtext)) (listitem (bullet) (itemtext)))
|
||||
))
|
||||
|
||||
==========
|
||||
|
|
@ -1046,7 +1067,7 @@ List.2d - two items
|
|||
|
||||
(document
|
||||
(body
|
||||
(list (listitem) (listitem))
|
||||
(list (listitem (bullet) (itemtext)) (listitem (bullet) (itemtext)))
|
||||
))
|
||||
|
||||
==========
|
||||
|
|
@ -1061,7 +1082,7 @@ List.2b - two items
|
|||
|
||||
(document
|
||||
(body
|
||||
(list (listitem) (listitem))
|
||||
(list (listitem (bullet) (itemtext)) (listitem (bullet) (itemtext)))
|
||||
))
|
||||
|
||||
==========
|
||||
|
|
@ -1077,12 +1098,12 @@ List.2c - two lists
|
|||
|
||||
(document
|
||||
(body
|
||||
(list (listitem))
|
||||
(list (listitem))
|
||||
(list (listitem (bullet) (itemtext)))
|
||||
(list (listitem (bullet) (itemtext)))
|
||||
))
|
||||
|
||||
==========
|
||||
List.3 - sublist
|
||||
List.3a - sublist
|
||||
==========
|
||||
|
||||
- a
|
||||
|
|
@ -1096,10 +1117,46 @@ List.3 - sublist
|
|||
(document
|
||||
(body
|
||||
(list
|
||||
(listitem
|
||||
(list (listitem)))
|
||||
(listitem)
|
||||
)))
|
||||
(listitem (bullet) (itemtext
|
||||
(list
|
||||
(listitem (bullet) (itemtext)))))
|
||||
(listitem (bullet) (itemtext))
|
||||
)))
|
||||
|
||||
==========
|
||||
List.3b - sublist with checkboxs
|
||||
==========
|
||||
|
||||
- [ ] a
|
||||
a
|
||||
- b
|
||||
- [ ] b
|
||||
a
|
||||
- a
|
||||
|
||||
==========
|
||||
List.3b - sublist with description and checkbox
|
||||
==========
|
||||
|
||||
- a :: description
|
||||
a
|
||||
- b :: description
|
||||
- [ ] b
|
||||
a
|
||||
- a
|
||||
|
||||
----------
|
||||
|
||||
(document
|
||||
(body
|
||||
(list
|
||||
(listitem (bullet) (description) (itemtext
|
||||
(list
|
||||
(listitem (bullet) (description) (itemtext))
|
||||
(listitem (bullet) (checkbox) (itemtext))
|
||||
)))
|
||||
(listitem (bullet) (itemtext))
|
||||
)))
|
||||
|
||||
==========
|
||||
List.4a - multiline item
|
||||
|
|
@ -1112,7 +1169,7 @@ List.4a - multiline item
|
|||
|
||||
(document
|
||||
(body
|
||||
(list (listitem))
|
||||
(list (listitem (bullet) (itemtext)))
|
||||
))
|
||||
|
||||
==========
|
||||
|
|
@ -1127,7 +1184,65 @@ List.4b - multiline item
|
|||
|
||||
(document
|
||||
(body
|
||||
(list (listitem))
|
||||
(list (listitem (bullet) (itemtext)))
|
||||
))
|
||||
|
||||
==========
|
||||
List.4c - multiline item checkbox
|
||||
==========
|
||||
|
||||
- [ ] a
|
||||
b
|
||||
|
||||
----------
|
||||
|
||||
(document
|
||||
(body
|
||||
(list (listitem (bullet) (checkbox) (itemtext)))
|
||||
))
|
||||
|
||||
==========
|
||||
List.4d - multiline item checkbox
|
||||
==========
|
||||
|
||||
- [ ] a
|
||||
|
||||
b
|
||||
|
||||
----------
|
||||
|
||||
(document
|
||||
(body
|
||||
(list (listitem (bullet) (checkbox) (itemtext)))
|
||||
))
|
||||
|
||||
==========
|
||||
List.4e - multiline item description
|
||||
==========
|
||||
|
||||
- a :: description
|
||||
b
|
||||
|
||||
----------
|
||||
|
||||
(document
|
||||
(body
|
||||
(list (listitem (bullet) (description) (itemtext)))
|
||||
))
|
||||
|
||||
==========
|
||||
List.4f - multiline item description
|
||||
==========
|
||||
|
||||
- a :: description
|
||||
|
||||
b
|
||||
|
||||
----------
|
||||
|
||||
(document
|
||||
(body
|
||||
(list (listitem (bullet) (description) (itemtext)))
|
||||
))
|
||||
|
||||
==========
|
||||
|
|
@ -1142,9 +1257,9 @@ List.5 - dedent
|
|||
|
||||
(document
|
||||
(body
|
||||
(list (listitem))
|
||||
(list (listitem (bullet) (itemtext)))
|
||||
(paragraph)
|
||||
(list (listitem))
|
||||
(list (listitem (bullet) (itemtext)))
|
||||
))
|
||||
|
||||
==========
|
||||
|
|
@ -1162,8 +1277,8 @@ b
|
|||
(body
|
||||
(paragraph)
|
||||
(list
|
||||
(listitem
|
||||
(list (listitem))))
|
||||
(listitem (bullet) (itemtext
|
||||
(list (listitem (bullet) (itemtext))))))
|
||||
(paragraph)
|
||||
))
|
||||
|
||||
|
|
@ -1178,8 +1293,8 @@ List.7a - changing
|
|||
|
||||
(document
|
||||
(body
|
||||
(list (listitem))
|
||||
(list (listitem))
|
||||
(list (listitem (bullet) (itemtext)))
|
||||
(list (listitem (bullet) (itemtext)))
|
||||
))
|
||||
|
||||
==========
|
||||
|
|
@ -1188,7 +1303,7 @@ List.8a - Whitespace
|
|||
-
|
||||
----------
|
||||
|
||||
(document (body (list (listitem))))
|
||||
(document (body (list (listitem (bullet)))))
|
||||
|
||||
==========
|
||||
List.8b - Whitespace after text
|
||||
|
|
@ -1196,14 +1311,14 @@ List.8b - Whitespace after text
|
|||
- a
|
||||
----------
|
||||
|
||||
(document (body (list (listitem))))
|
||||
(document (body (list (listitem (bullet) (itemtext)))))
|
||||
==========
|
||||
List.9 - With markup
|
||||
==========
|
||||
- A *b* c
|
||||
----------
|
||||
|
||||
(document (body (list (listitem (markup)))))
|
||||
(document (body (list (listitem (bullet) (itemtext (markup))))))
|
||||
|
||||
==============
|
||||
Directive.1 - Document
|
||||
|
|
@ -1274,7 +1389,7 @@ Directive.6a - List
|
|||
- c
|
||||
----------
|
||||
|
||||
(document (body (list (directive (name) (value)) (listitem))))
|
||||
(document (body (list (directive (name) (value)) (listitem (bullet) (itemtext)))))
|
||||
|
||||
==============
|
||||
Directive.6b - Sublist
|
||||
|
|
@ -1287,7 +1402,7 @@ Directive.6b - Sublist
|
|||
|
||||
----------
|
||||
|
||||
(document (body (list (directive (name) (value)) (listitem (list (directive (name) (value)) (listitem))))))
|
||||
(document (body (list (directive (name) (value)) (listitem (bullet) (itemtext (list (directive (name) (value)) (listitem (bullet) (itemtext))))))))
|
||||
|
||||
==============
|
||||
Directive.7 - Directive unrelated to section
|
||||
|
|
|
|||
18
grammar.js
18
grammar.js
|
|
@ -16,7 +16,7 @@ org_grammar = {
|
|||
$._liststart,
|
||||
$._listend,
|
||||
$._listitemend,
|
||||
$._bullet,
|
||||
$.bullet,
|
||||
$._stars,
|
||||
$._sectionend,
|
||||
$._markup,
|
||||
|
|
@ -37,7 +37,7 @@ org_grammar = {
|
|||
],
|
||||
|
||||
conflicts: $ => [
|
||||
[$._itemtag, $._textelement], // textelement in $._itemtext
|
||||
[$.description, $._textelement], // textelement in $.itemtext
|
||||
[$.item], // :tags: in headlines
|
||||
|
||||
// Markup
|
||||
|
|
@ -443,19 +443,19 @@ org_grammar = {
|
|||
),
|
||||
|
||||
listitem: $ => seq(
|
||||
$._bullet,
|
||||
optional($._checkbox),
|
||||
optional($._itemtag),
|
||||
optional($._itemtext),
|
||||
$.bullet,
|
||||
optional($.checkbox),
|
||||
optional($.description),
|
||||
optional($.itemtext),
|
||||
),
|
||||
|
||||
_checkbox: _ => /\[[ xX-]\]/,
|
||||
_itemtag: $ => seq(
|
||||
checkbox: _ => /\[[ xX-]\]/,
|
||||
description: $ => seq(
|
||||
repeat($._text),
|
||||
prec.dynamic(DYN.listtag, '::'), // precedence over itemtext
|
||||
),
|
||||
|
||||
_itemtext: $ => seq(
|
||||
itemtext: $ => seq(
|
||||
repeat1($._textelement),
|
||||
repeat(seq(
|
||||
$._nl,
|
||||
|
|
|
|||
|
|
@ -2408,14 +2408,14 @@
|
|||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_bullet"
|
||||
"name": "bullet"
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_checkbox"
|
||||
"name": "checkbox"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
|
|
@ -2427,7 +2427,7 @@
|
|||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_itemtag"
|
||||
"name": "description"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
|
|
@ -2439,7 +2439,7 @@
|
|||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_itemtext"
|
||||
"name": "itemtext"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
|
|
@ -2448,11 +2448,11 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"_checkbox": {
|
||||
"checkbox": {
|
||||
"type": "PATTERN",
|
||||
"value": "\\[[ xX-]\\]"
|
||||
},
|
||||
"_itemtag": {
|
||||
"description": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
|
|
@ -2472,7 +2472,7 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"_itemtext": {
|
||||
"itemtext": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
|
|
@ -2971,7 +2971,7 @@
|
|||
],
|
||||
"conflicts": [
|
||||
[
|
||||
"_itemtag",
|
||||
"description",
|
||||
"_textelement"
|
||||
],
|
||||
[
|
||||
|
|
@ -3026,7 +3026,7 @@
|
|||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_bullet"
|
||||
"name": "bullet"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
|
|
|
|||
|
|
@ -127,6 +127,11 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "description",
|
||||
"named": true,
|
||||
"fields": {}
|
||||
},
|
||||
{
|
||||
"type": "directive",
|
||||
"named": true,
|
||||
|
|
@ -372,6 +377,49 @@
|
|||
"named": true,
|
||||
"fields": {}
|
||||
},
|
||||
{
|
||||
"type": "itemtext",
|
||||
"named": true,
|
||||
"fields": {},
|
||||
"children": {
|
||||
"multiple": true,
|
||||
"required": false,
|
||||
"types": [
|
||||
{
|
||||
"type": "footnote",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "latex_fragment",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "link",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "list",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "markup",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "subscript",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "superscript",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "timestamp",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "keyword?",
|
||||
"named": false,
|
||||
|
|
@ -452,38 +500,22 @@
|
|||
"fields": {},
|
||||
"children": {
|
||||
"multiple": true,
|
||||
"required": false,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "footnote",
|
||||
"type": "bullet",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "latex_fragment",
|
||||
"type": "checkbox",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "link",
|
||||
"type": "description",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "list",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "markup",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "subscript",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "superscript",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "timestamp",
|
||||
"type": "itemtext",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
|
|
@ -928,6 +960,14 @@
|
|||
"type": "`",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "bullet",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "checkbox",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "delay",
|
||||
"named": true
|
||||
|
|
|
|||
88735
src/parser.c
88735
src/parser.c
File diff suppressed because it is too large
Load diff
|
|
@ -111,41 +111,41 @@ struct Scanner { // {{{1
|
|||
|
||||
Bullet getbullet(TSLexer *lexer) { // {{{1
|
||||
if (lexer->lookahead == '-') {
|
||||
skip(lexer);
|
||||
advance(lexer);
|
||||
if (iswspace(lexer->lookahead)) return DASH;
|
||||
} else if (lexer->lookahead == '+') {
|
||||
skip(lexer);
|
||||
advance(lexer);
|
||||
if (iswspace(lexer->lookahead)) return PLUS;
|
||||
} else if (lexer->lookahead == '*') {
|
||||
skip(lexer);
|
||||
advance(lexer);
|
||||
if (iswspace(lexer->lookahead)) return STAR;
|
||||
} else if ('a' <= lexer->lookahead && lexer->lookahead <= 'z') {
|
||||
skip(lexer);
|
||||
advance(lexer);
|
||||
if (lexer->lookahead == '.') {
|
||||
skip(lexer);
|
||||
advance(lexer);
|
||||
if (iswspace(lexer->lookahead)) return LOWERDOT;
|
||||
} else if (lexer->lookahead == ')') {
|
||||
skip(lexer);
|
||||
advance(lexer);
|
||||
if (iswspace(lexer->lookahead)) return LOWERPAREN;
|
||||
}
|
||||
} else if ('A' <= lexer->lookahead && lexer->lookahead <= 'Z') {
|
||||
skip(lexer);
|
||||
advance(lexer);
|
||||
if (lexer->lookahead == '.') {
|
||||
skip(lexer);
|
||||
advance(lexer);
|
||||
if (iswspace(lexer->lookahead)) return UPPERDOT;
|
||||
} else if (lexer->lookahead == ')') {
|
||||
skip(lexer);
|
||||
advance(lexer);
|
||||
if (iswspace(lexer->lookahead)) return UPPERPAREN;
|
||||
}
|
||||
} else if ('0' <= lexer->lookahead && lexer->lookahead <= '9') {
|
||||
do {
|
||||
skip(lexer);
|
||||
advance(lexer);
|
||||
} while ('0' <= lexer->lookahead && lexer->lookahead <= '9');
|
||||
if (lexer->lookahead == '.') {
|
||||
skip(lexer);
|
||||
advance(lexer);
|
||||
if (iswspace(lexer->lookahead)) return NUMDOT;
|
||||
} else if (lexer->lookahead == ')') {
|
||||
skip(lexer);
|
||||
advance(lexer);
|
||||
if (iswspace(lexer->lookahead)) return NUMPAREN;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue