Reformat grammar.js

pull/813/head
Patrick Förster 2024-04-28 09:20:40 +07:00
parent ae2134af67
commit 01973c115c
2 changed files with 139 additions and 174 deletions

@ -1,4 +1,5 @@
{ {
"singleQuote": true, "singleQuote": true,
"arrowParens": "avoid" "arrowParens": "avoid",
"trailingComma": "all"
} }

@ -15,20 +15,20 @@ const specialEnvironment = ({ rule, name, content, options }) => {
seq( seq(
field('begin', alias($[beginRule], $.begin)), field('begin', alias($[beginRule], $.begin)),
content($), content($),
field('end', alias($[endRule], $.end)) field('end', alias($[endRule], $.end)),
), ),
[beginRule]: $ => [beginRule]: $ =>
seq( seq(
field('command', '\\begin'), field('command', '\\begin'),
field('name', alias($[groupRule], $.curly_group_text)), field('name', alias($[groupRule], $.curly_group_text)),
options ? options($) : seq() options ? options($) : seq(),
), ),
[endRule]: $ => [endRule]: $ =>
seq( seq(
field('command', '\\end'), field('command', '\\end'),
field('name', alias($[groupRule], $.curly_group_text)) field('name', alias($[groupRule], $.curly_group_text)),
), ),
[groupRule]: $ => seq('{', field('text', alias($[nameRule], $.text)), '}'), [groupRule]: $ => seq('{', field('text', alias($[nameRule], $.text)), '}'),
@ -64,7 +64,7 @@ module.exports = grammar({
seq( seq(
field('begin', '\\iffalse'), field('begin', '\\iffalse'),
field('comment', optional(alias($._trivia_raw_fi, $.comment))), field('comment', optional(alias($._trivia_raw_fi, $.comment))),
field('end', optional('\\fi')) field('end', optional('\\fi')),
), ),
//--- Content //--- Content
@ -86,7 +86,7 @@ module.exports = grammar({
$.sageblock_environment, $.sageblock_environment,
$.generic_environment, $.generic_environment,
$.math_environment, $.math_environment,
$._text_content $._text_content,
), ),
_text_content: $ => _text_content: $ =>
@ -102,8 +102,8 @@ module.exports = grammar({
$.math_delimiter, $.math_delimiter,
$.text_mode, $.text_mode,
'(', '(',
')' ')',
) ),
), ),
//--- Sections //--- Sections
@ -115,8 +115,8 @@ module.exports = grammar({
repeat1($.chapter), repeat1($.chapter),
repeat1($.section), repeat1($.section),
repeat1($.subsection), repeat1($.subsection),
repeat1($.subsubsection) repeat1($.subsubsection),
) ),
), ),
_paragraph: $ => _paragraph: $ =>
@ -124,8 +124,8 @@ module.exports = grammar({
choice( choice(
repeat1($.paragraph), repeat1($.paragraph),
repeat1($.subparagraph), repeat1($.subparagraph),
repeat1($.enum_item) repeat1($.enum_item),
) ),
), ),
_section_part: $ => _section_part: $ =>
@ -136,10 +136,10 @@ module.exports = grammar({
seq( seq(
field( field(
'command', 'command',
choice('\\part', '\\part*', '\\addpart', '\\addpart*') choice('\\part', '\\part*', '\\addpart', '\\addpart*'),
), ),
optional($._section_part) optional($._section_part),
) ),
), ),
part: $ => part: $ =>
@ -156,10 +156,10 @@ module.exports = grammar({
repeat1($.section), repeat1($.section),
repeat1($.subsection), repeat1($.subsection),
repeat1($.subsubsection), repeat1($.subsubsection),
) ),
) ),
) ),
) ),
), ),
_chapter_declaration: $ => _chapter_declaration: $ =>
@ -167,10 +167,10 @@ module.exports = grammar({
seq( seq(
field( field(
'command', 'command',
choice('\\chapter', '\\chapter*', '\\addchap', '\\addchap*') choice('\\chapter', '\\chapter*', '\\addchap', '\\addchap*'),
), ),
optional($._section_part) optional($._section_part),
) ),
), ),
chapter: $ => chapter: $ =>
@ -186,10 +186,10 @@ module.exports = grammar({
repeat1($.section), repeat1($.section),
repeat1($.subsection), repeat1($.subsection),
repeat1($.subsubsection), repeat1($.subsubsection),
) ),
) ),
) ),
) ),
), ),
_section_declaration: $ => _section_declaration: $ =>
@ -197,10 +197,10 @@ module.exports = grammar({
seq( seq(
field( field(
'command', 'command',
choice('\\section', '\\section*', '\\addsec', '\\addsec*') choice('\\section', '\\section*', '\\addsec', '\\addsec*'),
), ),
optional($._section_part) optional($._section_part),
) ),
), ),
section: $ => section: $ =>
@ -211,22 +211,17 @@ module.exports = grammar({
repeat($._flat_content), repeat($._flat_content),
optional(prec.right(-1, $._paragraph)), optional(prec.right(-1, $._paragraph)),
optional( optional(
prec.right( prec.right(choice(repeat1($.subsection), repeat1($.subsubsection))),
choice( ),
repeat1($.subsection), ),
repeat1($.subsubsection)
)
)
)
)
), ),
_subsection_declaration: $ => _subsection_declaration: $ =>
prec.right( prec.right(
seq( seq(
field('command', choice('\\subsection', '\\subsection*')), field('command', choice('\\subsection', '\\subsection*')),
optional($._section_part) optional($._section_part),
) ),
), ),
subsection: $ => subsection: $ =>
@ -236,20 +231,16 @@ module.exports = grammar({
$._subsection_declaration, $._subsection_declaration,
repeat($._flat_content), repeat($._flat_content),
optional(prec.right(-1, $._paragraph)), optional(prec.right(-1, $._paragraph)),
optional( optional(prec.right(repeat1($.subsubsection))),
prec.right( ),
repeat1($.subsubsection)
)
)
)
), ),
_subsubsection_declaration: $ => _subsubsection_declaration: $ =>
prec.right( prec.right(
seq( seq(
field('command', choice('\\subsubsection', '\\subsubsection*')), field('command', choice('\\subsubsection', '\\subsubsection*')),
optional($._section_part) optional($._section_part),
) ),
), ),
subsubsection: $ => subsubsection: $ =>
@ -259,15 +250,15 @@ module.exports = grammar({
$._subsubsection_declaration, $._subsubsection_declaration,
repeat($._flat_content), repeat($._flat_content),
optional(prec.right(-1, $._paragraph)), optional(prec.right(-1, $._paragraph)),
) ),
), ),
_paragraph_declaration: $ => _paragraph_declaration: $ =>
prec.right( prec.right(
seq( seq(
field('command', choice('\\paragraph', '\\paragraph*')), field('command', choice('\\paragraph', '\\paragraph*')),
optional($._section_part) optional($._section_part),
) ),
), ),
paragraph: $ => paragraph: $ =>
@ -277,22 +268,17 @@ module.exports = grammar({
$._paragraph_declaration, $._paragraph_declaration,
repeat($._flat_content), repeat($._flat_content),
optional( optional(
prec.right( prec.right(choice(repeat1($.subparagraph), repeat1($.enum_item))),
choice( ),
repeat1($.subparagraph), ),
repeat1($.enum_item)
)
)
)
)
), ),
_subparagraph_declaration: $ => _subparagraph_declaration: $ =>
prec.right( prec.right(
seq( seq(
field('command', choice('\\subparagraph', '\\subparagraph*')), field('command', choice('\\subparagraph', '\\subparagraph*')),
optional($._section_part) optional($._section_part),
) ),
), ),
subparagraph: $ => subparagraph: $ =>
@ -301,22 +287,16 @@ module.exports = grammar({
seq( seq(
$._subparagraph_declaration, $._subparagraph_declaration,
repeat($._flat_content), repeat($._flat_content),
optional( optional(prec.right(choice(repeat1($.enum_item)))),
prec.right( ),
choice(
repeat1($.enum_item)
)
)
)
)
), ),
_enum_itemdeclaration: $ => _enum_itemdeclaration: $ =>
prec.right( prec.right(
seq( seq(
field('command', choice('\\item', '\\item*')), field('command', choice('\\item', '\\item*')),
field('label', optional($.brack_group_text)) field('label', optional($.brack_group_text)),
) ),
), ),
enum_item: $ => enum_item: $ =>
@ -325,12 +305,8 @@ module.exports = grammar({
seq( seq(
$._enum_itemdeclaration, $._enum_itemdeclaration,
repeat($._flat_content), repeat($._flat_content),
optional( optional(prec.right(choice())),
prec.right( ),
choice()
)
)
)
), ),
//--- Group //--- Group
@ -364,9 +340,9 @@ module.exports = grammar({
'{', '{',
sepBy( sepBy(
alias(repeat1($._text_content), $.author), alias(repeat1($._text_content), $.author),
alias('\\and', $.command_name) alias('\\and', $.command_name),
), ),
'}' '}',
), ),
brack_group: $ => brack_group: $ =>
@ -393,10 +369,10 @@ module.exports = grammar({
$.block_comment, $.block_comment,
$._command, $._command,
$.superscript, $.superscript,
$.subscript $.subscript,
) ),
) ),
) ),
), ),
word: $ => /[^\s\\%\{\},\$\[\]\(\)=\#_\^\-\+\/\*]+/, word: $ => /[^\s\\%\{\},\$\[\]\(\)=\#_\^\-\+\/\*]+/,
@ -412,7 +388,7 @@ module.exports = grammar({
_glob_pattern_fragment: $ => _glob_pattern_fragment: $ =>
choice( choice(
seq('{', repeat($._glob_pattern_fragment), '}'), seq('{', repeat($._glob_pattern_fragment), '}'),
/[^\"\[\]:;\|\{\}<>]+/ /[^\"\[\]:;\|\{\}<>]+/,
), ),
operator: $ => choice('+', '-', '*', '/', '<', '>', '!', '|', ':', "'"), operator: $ => choice('+', '-', '*', '/', '<', '>', '!', '|', ':', "'"),
@ -420,13 +396,13 @@ module.exports = grammar({
subscript: $ => subscript: $ =>
seq( seq(
'_', '_',
field('subscript', choice($.curly_group, $.word, $.generic_command)) field('subscript', choice($.curly_group, $.word, $.generic_command)),
), ),
superscript: $ => superscript: $ =>
seq( seq(
'^', '^',
field('superscript', choice($.curly_group, $.word, $.generic_command)) field('superscript', choice($.curly_group, $.word, $.generic_command)),
), ),
//--- Key / Value //--- Key / Value
@ -440,12 +416,12 @@ module.exports = grammar({
displayed_equation: $ => displayed_equation: $ =>
prec.left( prec.left(
seq(choice('$$', '\\['), repeat($._root_content), choice('$$', '\\]')) seq(choice('$$', '\\['), repeat($._root_content), choice('$$', '\\]')),
), ),
inline_formula: $ => inline_formula: $ =>
prec.left( prec.left(
seq(choice('$', '\\('), repeat($._root_content), choice('$', '\\)')) seq(choice('$', '\\('), repeat($._root_content), choice('$', '\\)')),
), ),
//--- Environments //--- Environments
@ -455,20 +431,20 @@ module.exports = grammar({
seq( seq(
field('command', '\\begin'), field('command', '\\begin'),
field('name', $.curly_group_text), field('name', $.curly_group_text),
field('options', optional($.brack_group)) field('options', optional($.brack_group)),
) ),
), ),
end: $ => end: $ =>
prec.right( prec.right(
seq(field('command', '\\end'), field('name', $.curly_group_text)) seq(field('command', '\\end'), field('name', $.curly_group_text)),
), ),
generic_environment: $ => generic_environment: $ =>
seq( seq(
field('begin', $.begin), field('begin', $.begin),
repeat($._root_content), repeat($._root_content),
field('end', $.end) field('end', $.end),
), ),
//--- Trivia environments //--- Trivia environments
@ -505,7 +481,7 @@ module.exports = grammar({
options: $ => options: $ =>
seq( seq(
field('options', optional($.brack_group_key_value)), field('options', optional($.brack_group_key_value)),
field('language', $.curly_group_text) field('language', $.curly_group_text),
), ),
}), }),
@ -556,7 +532,7 @@ module.exports = grammar({
'gather', 'gather',
'gather*', 'gather*',
'flalign', 'flalign',
'flalign*' 'flalign*',
), ),
content: $ => repeat($._flat_content), content: $ => repeat($._flat_content),
options: undefined, options: undefined,
@ -599,15 +575,15 @@ module.exports = grammar({
$.color_set_definition, $.color_set_definition,
$.color_reference, $.color_reference,
$.tikz_library_import, $.tikz_library_import,
$.generic_command $.generic_command,
), ),
generic_command: $ => generic_command: $ =>
prec.right( prec.right(
seq( seq(
field('command', $.command_name), field('command', $.command_name),
repeat(field('arg', $.curly_group)) repeat(field('arg', $.curly_group)),
) ),
), ),
command_name: $ => /\\([^\r\n]|[@a-zA-Z]+\*?)?/, command_name: $ => /\\([^\r\n]|[@a-zA-Z]+\*?)?/,
@ -616,83 +592,83 @@ module.exports = grammar({
seq( seq(
field('command', '\\title'), field('command', '\\title'),
field('options', optional($.brack_group)), field('options', optional($.brack_group)),
field('text', $.curly_group) field('text', $.curly_group),
), ),
author_declaration: $ => author_declaration: $ =>
seq( seq(
field('command', '\\author'), field('command', '\\author'),
field('options', optional($.brack_group)), field('options', optional($.brack_group)),
field('authors', $.curly_group_author_list) field('authors', $.curly_group_author_list),
), ),
package_include: $ => package_include: $ =>
seq( seq(
field('command', choice('\\usepackage', '\\RequirePackage')), field('command', choice('\\usepackage', '\\RequirePackage')),
field('options', optional($.brack_group_key_value)), field('options', optional($.brack_group_key_value)),
field('paths', $.curly_group_path_list) field('paths', $.curly_group_path_list),
), ),
class_include: $ => class_include: $ =>
seq( seq(
field('command', '\\documentclass'), field('command', '\\documentclass'),
field('options', optional($.brack_group_key_value)), field('options', optional($.brack_group_key_value)),
field('path', $.curly_group_path) field('path', $.curly_group_path),
), ),
latex_include: $ => latex_include: $ =>
seq( seq(
field( field(
'command', 'command',
choice('\\include', '\\subfileinclude', '\\input', '\\subfile') choice('\\include', '\\subfileinclude', '\\input', '\\subfile'),
), ),
field('path', $.curly_group_path) field('path', $.curly_group_path),
), ),
biblatex_include: $ => biblatex_include: $ =>
seq( seq(
'\\addbibresource', '\\addbibresource',
field('options', optional($.brack_group_key_value)), field('options', optional($.brack_group_key_value)),
field('glob', $.curly_group_glob_pattern) field('glob', $.curly_group_glob_pattern),
), ),
bibstyle_include: $ => bibstyle_include: $ =>
seq( seq(
field('command', '\\bibliographystyle'), field('command', '\\bibliographystyle'),
field('path', $.curly_group_path) field('path', $.curly_group_path),
), ),
bibtex_include: $ => bibtex_include: $ =>
seq( seq(
field('command', '\\bibliography'), field('command', '\\bibliography'),
field('paths', $.curly_group_path_list) field('paths', $.curly_group_path_list),
), ),
graphics_include: $ => graphics_include: $ =>
seq( seq(
field('command', '\\includegraphics'), field('command', '\\includegraphics'),
field('options', optional($.brack_group_key_value)), field('options', optional($.brack_group_key_value)),
field('path', $.curly_group_path) field('path', $.curly_group_path),
), ),
svg_include: $ => svg_include: $ =>
seq( seq(
field('command', '\\includesvg'), field('command', '\\includesvg'),
field('options', optional($.brack_group_key_value)), field('options', optional($.brack_group_key_value)),
field('path', $.curly_group_path) field('path', $.curly_group_path),
), ),
inkscape_include: $ => inkscape_include: $ =>
seq( seq(
field('command', '\\includeinkscape'), field('command', '\\includeinkscape'),
field('options', optional($.brack_group_key_value)), field('options', optional($.brack_group_key_value)),
field('path', $.curly_group_path) field('path', $.curly_group_path),
), ),
verbatim_include: $ => verbatim_include: $ =>
seq( seq(
field('command', choice('\\verbatiminput', '\\VerbatimInput')), field('command', choice('\\verbatiminput', '\\VerbatimInput')),
field('path', $.curly_group_path) field('path', $.curly_group_path),
), ),
import_include: $ => import_include: $ =>
@ -705,18 +681,18 @@ module.exports = grammar({
'\\inputfrom', '\\inputfrom',
'\\subimportfrom', '\\subimportfrom',
'\\includefrom', '\\includefrom',
'\\subincludefrom' '\\subincludefrom',
) ),
), ),
field('directory', $.curly_group_path), field('directory', $.curly_group_path),
field('file', $.curly_group_path) field('file', $.curly_group_path),
), ),
caption: $ => caption: $ =>
seq( seq(
field('command', '\\caption'), field('command', '\\caption'),
field('short', optional($.brack_group)), field('short', optional($.brack_group)),
field('long', $.curly_group) field('long', $.curly_group),
), ),
citation: $ => citation: $ =>
@ -783,16 +759,16 @@ module.exports = grammar({
'\\Notecite', '\\Notecite',
'\\pnotecite', '\\pnotecite',
'\\Pnotecite', '\\Pnotecite',
'\\fnotecite' '\\fnotecite',
) ),
), ),
optional( optional(
seq( seq(
field('prenote', $.brack_group), field('prenote', $.brack_group),
field('postnote', optional($.brack_group)) field('postnote', optional($.brack_group)),
) ),
), ),
field('keys', $.curly_group_text_list) field('keys', $.curly_group_text_list),
), ),
label_definition: $ => label_definition: $ =>
@ -820,27 +796,27 @@ module.exports = grammar({
'\\nameCrefs', '\\nameCrefs',
'\\lcnamecrefs', '\\lcnamecrefs',
'\\labelcref', '\\labelcref',
'\\labelcpageref' '\\labelcpageref',
) ),
), ),
field('names', $.curly_group_text_list) field('names', $.curly_group_text_list),
), ),
label_reference_range: $ => label_reference_range: $ =>
seq( seq(
field( field(
'command', 'command',
choice('\\crefrange', '\\crefrange*', '\\Crefrange', '\\Crefrange*') choice('\\crefrange', '\\crefrange*', '\\Crefrange', '\\Crefrange*'),
), ),
field('from', $.curly_group_text), field('from', $.curly_group_text),
field('to', $.curly_group_text) field('to', $.curly_group_text),
), ),
label_number: $ => label_number: $ =>
seq( seq(
field('command', '\\newlabel'), field('command', '\\newlabel'),
field('name', $.curly_group_text), field('name', $.curly_group_text),
field('number', $.curly_group) field('number', $.curly_group),
), ),
new_command_definition: $ => new_command_definition: $ =>
@ -863,17 +839,17 @@ module.exports = grammar({
'\\NewExpandableDocumentCommand', '\\NewExpandableDocumentCommand',
'\\RenewExpandableDocumentCommand', '\\RenewExpandableDocumentCommand',
'\\ProvideExpandableDocumentCommand', '\\ProvideExpandableDocumentCommand',
'\\DeclareExpandableDocumentCommand' '\\DeclareExpandableDocumentCommand',
) ),
), ),
field('declaration', $.curly_group_command_name), field('declaration', $.curly_group_command_name),
optional( optional(
seq( seq(
field('argc', $.brack_group_argc), field('argc', $.brack_group_argc),
field('default', optional($.brack_group)) field('default', optional($.brack_group)),
) ),
), ),
field('implementation', $.curly_group) field('implementation', $.curly_group),
), ),
old_command_definition: $ => old_command_definition: $ =>
@ -884,7 +860,7 @@ module.exports = grammar({
field('command', '\\let'), field('command', '\\let'),
field('declaration', $.command_name), field('declaration', $.command_name),
optional('='), optional('='),
field('implementation', $.command_name) field('implementation', $.command_name),
), ),
_math_delimiter_part: $ => _math_delimiter_part: $ =>
@ -895,28 +871,16 @@ module.exports = grammar({
seq( seq(
field( field(
'left_command', 'left_command',
choice( choice('\\left', '\\bigl', '\\Bigl', '\\biggl', '\\Biggl'),
'\\left',
'\\bigl',
'\\Bigl',
'\\biggl',
'\\Biggl'
)
), ),
field('left_delimiter', $._math_delimiter_part), field('left_delimiter', $._math_delimiter_part),
repeat($._root_content), repeat($._root_content),
field( field(
'right_command', 'right_command',
choice( choice('\\right', '\\bigr', '\\Bigr', '\\biggr', '\\Biggr'),
'\\right',
'\\bigr',
'\\Bigr',
'\\biggr',
'\\Biggr'
)
), ),
field('right_delimiter', $._math_delimiter_part) field('right_delimiter', $._math_delimiter_part),
) ),
), ),
paired_delimiter_definition: $ => paired_delimiter_definition: $ =>
@ -924,14 +888,14 @@ module.exports = grammar({
seq( seq(
field( field(
'command', 'command',
choice('\\DeclarePairedDelimiter', '\\DeclarePairedDelimiterX') choice('\\DeclarePairedDelimiter', '\\DeclarePairedDelimiterX'),
), ),
field('declaration', $.curly_group_command_name), field('declaration', $.curly_group_command_name),
field('argc', optional($.brack_group_argc)), field('argc', optional($.brack_group_argc)),
field('left', choice($.curly_group_impl, $.command_name)), field('left', choice($.curly_group_impl, $.command_name)),
field('right', choice($.curly_group_impl, $.command_name)), field('right', choice($.curly_group_impl, $.command_name)),
field('body', optional($.curly_group)) field('body', optional($.curly_group)),
) ),
), ),
environment_definition: $ => environment_definition: $ =>
@ -944,20 +908,20 @@ module.exports = grammar({
'\\NewDocumentEnvironment', '\\NewDocumentEnvironment',
'\\RenewDocumentEnvironment', '\\RenewDocumentEnvironment',
'\\ProvideDocumentEnvironment', '\\ProvideDocumentEnvironment',
'\\DeclareDocumentEnvironment' '\\DeclareDocumentEnvironment',
) ),
), ),
field('name', $.curly_group_text), field('name', $.curly_group_text),
field('argc', optional($.brack_group_argc)), field('argc', optional($.brack_group_argc)),
field('begin', $.curly_group_impl), field('begin', $.curly_group_impl),
field('end', $.curly_group_impl) field('end', $.curly_group_impl),
), ),
glossary_entry_definition: $ => glossary_entry_definition: $ =>
seq( seq(
field('command', '\\newglossaryentry'), field('command', '\\newglossaryentry'),
field('name', $.curly_group_text), field('name', $.curly_group_text),
field('options', $.curly_group_key_value) field('options', $.curly_group_key_value),
), ),
glossary_entry_reference: $ => glossary_entry_reference: $ =>
@ -1010,11 +974,11 @@ module.exports = grammar({
'\\GLSuserv', '\\GLSuserv',
'\\glsuservi', '\\glsuservi',
'\\Glsuservi', '\\Glsuservi',
'\\GLSuservi' '\\GLSuservi',
) ),
), ),
field('options', optional($.brack_group_key_value)), field('options', optional($.brack_group_key_value)),
field('name', $.curly_group_text) field('name', $.curly_group_text),
), ),
acronym_definition: $ => acronym_definition: $ =>
@ -1023,7 +987,7 @@ module.exports = grammar({
field('options', optional($.brack_group_key_value)), field('options', optional($.brack_group_key_value)),
field('name', $.curly_group_text), field('name', $.curly_group_text),
field('short', $.curly_group), field('short', $.curly_group),
field('long', $.curly_group) field('long', $.curly_group),
), ),
acronym_reference: $ => acronym_reference: $ =>
@ -1073,11 +1037,11 @@ module.exports = grammar({
'\\glsentryshortpl', '\\glsentryshortpl',
'\\Glsentryshortpl', '\\Glsentryshortpl',
'\\glsentryfullpl', '\\glsentryfullpl',
'\\Glsentryfullpl' '\\Glsentryfullpl',
) ),
), ),
field('options', optional($.brack_group_key_value)), field('options', optional($.brack_group_key_value)),
field('name', $.curly_group_text) field('name', $.curly_group_text),
), ),
theorem_definition: $ => theorem_definition: $ =>
@ -1089,8 +1053,8 @@ module.exports = grammar({
'\\newtheorem', '\\newtheorem',
'\\newtheorem*', '\\newtheorem*',
'\\declaretheorem', '\\declaretheorem',
'\\declaretheorem*' '\\declaretheorem*',
) ),
), ),
optional(field('options', $.brack_group_key_value)), optional(field('options', $.brack_group_key_value)),
field('name', $.curly_group_text), field('name', $.curly_group_text),
@ -1098,15 +1062,15 @@ module.exports = grammar({
choice( choice(
seq( seq(
field('title', $.curly_group), field('title', $.curly_group),
field('counter', optional($.brack_group_text)) field('counter', optional($.brack_group_text)),
), ),
seq( seq(
field('counter', $.brack_group_text), field('counter', $.brack_group_text),
field('title', $.curly_group) field('title', $.curly_group),
) ),
) ),
) ),
) ),
), ),
color_definition: $ => color_definition: $ =>
@ -1115,7 +1079,7 @@ module.exports = grammar({
optional($.brack_group_text), optional($.brack_group_text),
field('name', $.curly_group_text), field('name', $.curly_group_text),
field('model', $.curly_group_text), field('model', $.curly_group_text),
field('spec', $.curly_group) field('spec', $.curly_group),
), ),
color_set_definition: $ => color_set_definition: $ =>
@ -1125,28 +1089,28 @@ module.exports = grammar({
field('model', $.curly_group_text_list), field('model', $.curly_group_text_list),
field('head', $.curly_group), field('head', $.curly_group),
field('tail', $.curly_group), field('tail', $.curly_group),
field('spec', $.curly_group) field('spec', $.curly_group),
), ),
color_reference: $ => color_reference: $ =>
seq( seq(
field( field(
'command', 'command',
choice('\\color', '\\colorbox', '\\textcolor', '\\pagecolor') choice('\\color', '\\colorbox', '\\textcolor', '\\pagecolor'),
), ),
field('name', $.curly_group_text) field('name', $.curly_group_text),
), ),
tikz_library_import: $ => tikz_library_import: $ =>
seq( seq(
field('command', choice('\\usepgflibrary', '\\usetikzlibrary')), field('command', choice('\\usepgflibrary', '\\usetikzlibrary')),
field('paths', $.curly_group_path_list) field('paths', $.curly_group_path_list),
), ),
text_mode: $ => text_mode: $ =>
seq( seq(
field('command', choice('\\text', '\\intertext', '\\shortintertext')), field('command', choice('\\text', '\\intertext', '\\shortintertext')),
field('content', $.curly_group) field('content', $.curly_group),
), ),
}, },
}); });