Replace $.first with anonymous "keyword?"

Query like: (item "keyword?" @keyword (#eq? @keyword "TODO"))
This commit is contained in:
Emilia Simmons 2021-08-25 17:44:26 -04:00
parent d0fa0d5acb
commit 06dcd2e8af
5 changed files with 59 additions and 64 deletions

View file

@ -4,7 +4,7 @@ Headlines.1a - No eols
* l1
----------
(document (section (headline (stars) (item (first)))))
(document (section (headline (stars) (item))))
==============
Headlines.1b - pre eol
@ -13,7 +13,7 @@ Headlines.1b - pre eol
* l1
----------
(document (section (headline (stars) (item (first)))))
(document (section (headline (stars) (item))))
==============
Headlines.1c - Post eols (body)
@ -23,7 +23,7 @@ Headlines.1c - Post eols (body)
----------
(document (section (headline (stars) (item (first)))))
(document (section (headline (stars) (item))))
==============
Headlines.1d - More eols
@ -34,7 +34,7 @@ Headlines.1d - More eols
----------
(document (section (headline (stars) (item (first)))))
(document (section (headline (stars) (item))))
==============
Headlines.2 - level 2
@ -43,7 +43,7 @@ Headlines.2 - level 2
----------
(document (section (headline (stars) (item (first)))))
(document (section (headline (stars) (item))))
==============
Headlines.3a - Two sections
@ -54,8 +54,8 @@ Headlines.3a - Two sections
----------
(document
(section (headline (stars) (item (first))))
(section (headline (stars) (item (first))))
(section (headline (stars) (item)))
(section (headline (stars) (item)))
)
==============
@ -67,8 +67,8 @@ Headlines.3b - Two sections, eol
----------
(document
(section (headline (stars) (item (first))))
(section (headline (stars) (item (first))))
(section (headline (stars) (item)))
(section (headline (stars) (item)))
)
==============
@ -81,8 +81,8 @@ Headlines.4 - Subsection
(document
(section
(headline (stars) (item (first)))
(section (headline (stars) (item (first)))))
(headline (stars) (item))
(section (headline (stars) (item))))
)
==============
@ -96,8 +96,8 @@ Headlines.4a - Subsection eols
(document
(section
(headline (stars) (item (first)))
(section (headline (stars) (item (first))))
(headline (stars) (item))
(section (headline (stars) (item)))
))
==============
@ -110,9 +110,9 @@ Headlines.5 - Subsection & continued section
(document
(section
(headline (stars) (item (first)))
(section (headline (stars) (item (first)))))
(section (headline (stars) (item (first))))
(headline (stars) (item))
(section (headline (stars) (item))))
(section (headline (stars) (item)))
)
==============
@ -123,8 +123,8 @@ Headlines.6 - Top high level section
----------
(document
(section (headline (stars) (item (first))))
(section (headline (stars) (item (first))))
(section (headline (stars) (item)))
(section (headline (stars) (item)))
)
==============
@ -133,7 +133,7 @@ Headlines.7a - Item/tag conflict (:)
* a: b
----------
(document (section (headline (stars) (item (first)))))
(document (section (headline (stars) (item))))
==============
Headlines.7b - Item/tag conflict (:)
@ -141,7 +141,7 @@ Headlines.7b - Item/tag conflict (:)
* a: b:
----------
(document (section (headline (stars) (item (first)))))
(document (section (headline (stars) (item))))
==============
Headlines.8a - Tag
@ -149,7 +149,7 @@ Headlines.8a - Tag
* a :b:
----------
(document (section (headline (stars) (item (first)) (tag))))
(document (section (headline (stars) (item) (tag))))
==============
Headlines.8b - Multitag
@ -157,7 +157,7 @@ Headlines.8b - Multitag
* a :b:c:
----------
(document (section (headline (stars) (item (first)) (tag) (tag))))
(document (section (headline (stars) (item) (tag) (tag))))
==============
Headlines.8c - Junk
@ -165,7 +165,7 @@ Headlines.8c - Junk
* a :b: c:
----------
(document (section (headline (stars) (item (first)))))
(document (section (headline (stars) (item))))
==============
Headlines.9a - Non-markup
@ -175,7 +175,7 @@ Headlines.9a - Non-markup
(document
(section
(headline (stars) (item (first)))
(headline (stars) (item))
))
==============
@ -187,7 +187,7 @@ c*
(document
(section
(headline (stars) (item (first)))
(headline (stars) (item))
(body (paragraph))
))
@ -203,10 +203,10 @@ Headlines.10 - Precedences
(document
(section
(headline (stars) (item (first)))
(headline (stars) (item))
(body (paragraph)))
(section
(headline (stars) (item (first)))
(headline (stars) (item))
(body (paragraph)))
)
@ -223,7 +223,7 @@ PropertyDrawer.1 -
(section
(headline
(stars)
(item (first)))
(item))
(property_drawer
(property))
))
@ -242,7 +242,7 @@ PropertyDrawer.2 -
(section
(headline
(stars)
(item (first)))
(item))
(property_drawer
(property))
))
@ -536,7 +536,7 @@ Plan.1
(document
(section
(headline (stars) (item (first)))
(headline (stars) (item))
(plan (timestamp (date)))
))
@ -550,7 +550,7 @@ SCHEDULED: <1111-11-11 Day>
(document
(section
(headline (stars) (item (first)))
(headline (stars) (item))
(plan (scheduled (timestamp (date))))
))
@ -564,7 +564,7 @@ DEADLINE: <1111-11-11 Day> <1111-11-11 Day> CLOSED: [1111-11-11 Day]
(document
(section
(headline (stars) (item (first)))
(headline (stars) (item))
(plan
(deadline (timestamp (date)))
(timestamp (date))
@ -628,7 +628,7 @@ a
----------
(document (section
(headline (stars) (item (first)))
(headline (stars) (item))
(body
(block (name) (parameters) (contents))
)))
@ -898,7 +898,7 @@ b *a
(document
(body (paragraph))
(section (headline (stars) (item (first))))
(section (headline (stars) (item)))
)
===========
@ -910,7 +910,7 @@ Markup.6 - markup section
(document
(section
(headline (stars) (item (first)))
(headline (stars) (item))
(body (paragraph (markup)))
))
@ -1262,7 +1262,7 @@ c
(document
(section
(headline (stars) (item (first)))
(headline (stars) (item))
(body (paragraph (directive (name) (value))))
))
@ -1297,7 +1297,7 @@ Directive.7 - Directive unrelated to section
* c
----------
(document (body (directive (name) (value))) (section (headline (stars) (item (first)))))
(document (body (directive (name) (value))) (section (headline (stars) (item))))
=============
LatexEnv.1 -
@ -1434,7 +1434,7 @@ Combined.1 -
(document
(directive (name) (value))
(section
(headline (stars) (item (first)))
(headline (stars) (item))
(property_drawer (property))
))

View file

@ -142,7 +142,7 @@ org_grammar = {
// the choice with ':' allows for the conflict of $.title to operate
item: $ => seq(
alias(choice($._text, /[ \t]:/), $.first),
alias(choice($._text, /[ \t]:/), 'keyword?'),
repeat(choice($._text, /[ \t]:/)),
),
@ -531,6 +531,7 @@ org_grammar = {
repeat($._text),
sep1(repeat1($._nl), repeat1($._text)),
),
}
};

View file

@ -504,8 +504,8 @@
}
]
},
"named": true,
"value": "first"
"named": false,
"value": "keyword?"
},
{
"type": "REPEAT",

View file

@ -246,11 +246,6 @@
]
}
},
{
"type": "first",
"named": true,
"fields": {}
},
{
"type": "fndef",
"named": true,
@ -375,17 +370,12 @@
{
"type": "item",
"named": true,
"fields": {},
"children": {
"multiple": false,
"required": true,
"types": [
{
"type": "first",
"named": true
}
]
}
"fields": {}
},
{
"type": "keyword?",
"named": false,
"fields": {}
},
{
"type": "latex_env",
@ -942,6 +932,10 @@
"type": "delay",
"named": true
},
{
"type": "keyword?",
"named": false
},
{
"type": "linktext",
"named": true

View file

@ -210,7 +210,7 @@ enum {
aux_sym_row_repeat1 = 183,
aux_sym__hrule_repeat1 = 184,
aux_sym_contents_repeat1 = 185,
alias_sym_first = 186,
anon_alias_sym_keyword_QMARK = 186,
alias_sym_parameters = 187,
alias_sym_value = 188,
};
@ -402,7 +402,7 @@ static const char * const ts_symbol_names[] = {
[aux_sym_row_repeat1] = "row_repeat1",
[aux_sym__hrule_repeat1] = "_hrule_repeat1",
[aux_sym_contents_repeat1] = "contents_repeat1",
[alias_sym_first] = "first",
[anon_alias_sym_keyword_QMARK] = "keyword\?",
[alias_sym_parameters] = "parameters",
[alias_sym_value] = "value",
};
@ -594,7 +594,7 @@ static const TSSymbol ts_symbol_map[] = {
[aux_sym_row_repeat1] = aux_sym_row_repeat1,
[aux_sym__hrule_repeat1] = aux_sym__hrule_repeat1,
[aux_sym_contents_repeat1] = aux_sym_contents_repeat1,
[alias_sym_first] = alias_sym_first,
[anon_alias_sym_keyword_QMARK] = anon_alias_sym_keyword_QMARK,
[alias_sym_parameters] = alias_sym_parameters,
[alias_sym_value] = alias_sym_value,
};
@ -1344,9 +1344,9 @@ static const TSSymbolMetadata ts_symbol_metadata[] = {
.visible = false,
.named = false,
},
[alias_sym_first] = {
[anon_alias_sym_keyword_QMARK] = {
.visible = true,
.named = true,
.named = false,
},
[alias_sym_parameters] = {
.visible = true,
@ -1423,7 +1423,7 @@ static const TSSymbol ts_alias_sequences[PRODUCTION_ID_COUNT][MAX_ALIAS_SEQUENCE
[1] = aux_sym__dynamic_begin_token1,
},
[5] = {
[0] = alias_sym_first,
[0] = anon_alias_sym_keyword_QMARK,
},
[7] = {
[1] = aux_sym__dynamic_begin_token1,
@ -1456,7 +1456,7 @@ static const uint16_t ts_non_terminal_alias_map[] = {
sym_timestamp,
sym__text, 2,
sym__text,
alias_sym_first,
anon_alias_sym_keyword_QMARK,
aux_sym_property_repeat1, 3,
aux_sym_property_repeat1,
alias_sym_parameters,