Rename command to generic_command

pull/511/head
Patrick Förster 2022-02-26 21:15:52 +07:00
parent 899b7408d8
commit 7a3d14d057
9 changed files with 819 additions and 551 deletions

@ -61,6 +61,11 @@ module.exports = grammar({
$.inline_formula, $.inline_formula,
$.math_set, $.math_set,
$.block_comment, $.block_comment,
$._command
),
_command: $ =>
choice(
$.package_include, $.package_include,
$.class_include, $.class_include,
$.latex_include, $.latex_include,
@ -90,7 +95,7 @@ module.exports = grammar({
$.color_set_definition, $.color_set_definition,
$.color_reference, $.color_reference,
$.tikz_library_import, $.tikz_library_import,
$.command $.generic_command
), ),
//--- Sections //--- Sections
@ -557,7 +562,7 @@ module.exports = grammar({
//--- Command //--- Command
command: $ => generic_command: $ =>
prec.right( prec.right(
seq( seq(
field('command', $.command_name), field('command', $.command_name),

13
src/grammar.json vendored

@ -177,6 +177,15 @@
"type": "SYMBOL", "type": "SYMBOL",
"name": "block_comment" "name": "block_comment"
}, },
{
"type": "SYMBOL",
"name": "_command"
}
]
},
"_command": {
"type": "CHOICE",
"members": [
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "package_include" "name": "package_include"
@ -295,7 +304,7 @@
}, },
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "command" "name": "generic_command"
} }
] ]
}, },
@ -2758,7 +2767,7 @@
} }
] ]
}, },
"command": { "generic_command": {
"type": "PREC_RIGHT", "type": "PREC_RIGHT",
"value": 0, "value": 0,
"content": { "content": {

204
src/node-types.json vendored

@ -459,10 +459,6 @@
"type": "color_set_definition", "type": "color_set_definition",
"named": true "named": true
}, },
{
"type": "command",
"named": true
},
{ {
"type": "comment_environment", "type": "comment_environment",
"named": true "named": true
@ -479,6 +475,10 @@
"type": "environment_definition", "type": "environment_definition",
"named": true "named": true
}, },
{
"type": "generic_command",
"named": true
},
{ {
"type": "generic_environment", "type": "generic_environment",
"named": true "named": true
@ -755,10 +755,6 @@
"type": "color_set_definition", "type": "color_set_definition",
"named": true "named": true
}, },
{
"type": "command",
"named": true
},
{ {
"type": "comment_environment", "type": "comment_environment",
"named": true "named": true
@ -779,6 +775,10 @@
"type": "environment_definition", "type": "environment_definition",
"named": true "named": true
}, },
{
"type": "generic_command",
"named": true
},
{ {
"type": "generic_environment", "type": "generic_environment",
"named": true "named": true
@ -1368,36 +1368,6 @@
} }
} }
}, },
{
"type": "command",
"named": true,
"fields": {
"arg": {
"multiple": true,
"required": false,
"types": [
{
"type": "curly_group",
"named": true
},
{
"type": "mixed_group",
"named": true
}
]
},
"command": {
"multiple": false,
"required": true,
"types": [
{
"type": "command_name",
"named": true
}
]
}
}
},
{ {
"type": "comment_environment", "type": "comment_environment",
"named": true, "named": true,
@ -1490,10 +1460,6 @@
"type": "color_set_definition", "type": "color_set_definition",
"named": true "named": true
}, },
{
"type": "command",
"named": true
},
{ {
"type": "comment_environment", "type": "comment_environment",
"named": true "named": true
@ -1514,6 +1480,10 @@
"type": "environment_definition", "type": "environment_definition",
"named": true "named": true
}, },
{
"type": "generic_command",
"named": true
},
{ {
"type": "generic_environment", "type": "generic_environment",
"named": true "named": true
@ -1729,10 +1699,6 @@
"type": "color_set_definition", "type": "color_set_definition",
"named": true "named": true
}, },
{
"type": "command",
"named": true
},
{ {
"type": "curly_group", "type": "curly_group",
"named": true "named": true
@ -1745,6 +1711,10 @@
"type": "environment_definition", "type": "environment_definition",
"named": true "named": true
}, },
{
"type": "generic_command",
"named": true
},
{ {
"type": "glossary_entry_definition", "type": "glossary_entry_definition",
"named": true "named": true
@ -1978,10 +1948,6 @@
"type": "color_set_definition", "type": "color_set_definition",
"named": true "named": true
}, },
{
"type": "command",
"named": true
},
{ {
"type": "comment_environment", "type": "comment_environment",
"named": true "named": true
@ -2002,6 +1968,10 @@
"type": "environment_definition", "type": "environment_definition",
"named": true "named": true
}, },
{
"type": "generic_command",
"named": true
},
{ {
"type": "generic_environment", "type": "generic_environment",
"named": true "named": true
@ -2246,10 +2216,6 @@
"type": "color_set_definition", "type": "color_set_definition",
"named": true "named": true
}, },
{
"type": "command",
"named": true
},
{ {
"type": "comment_environment", "type": "comment_environment",
"named": true "named": true
@ -2266,6 +2232,10 @@
"type": "environment_definition", "type": "environment_definition",
"named": true "named": true
}, },
{
"type": "generic_command",
"named": true
},
{ {
"type": "generic_environment", "type": "generic_environment",
"named": true "named": true
@ -2419,6 +2389,36 @@
} }
} }
}, },
{
"type": "generic_command",
"named": true,
"fields": {
"arg": {
"multiple": true,
"required": false,
"types": [
{
"type": "curly_group",
"named": true
},
{
"type": "mixed_group",
"named": true
}
]
},
"command": {
"multiple": false,
"required": true,
"types": [
{
"type": "command_name",
"named": true
}
]
}
}
},
{ {
"type": "generic_environment", "type": "generic_environment",
"named": true, "named": true,
@ -2496,10 +2496,6 @@
"type": "color_set_definition", "type": "color_set_definition",
"named": true "named": true
}, },
{
"type": "command",
"named": true
},
{ {
"type": "comment_environment", "type": "comment_environment",
"named": true "named": true
@ -2520,6 +2516,10 @@
"type": "environment_definition", "type": "environment_definition",
"named": true "named": true
}, },
{
"type": "generic_command",
"named": true
},
{ {
"type": "generic_environment", "type": "generic_environment",
"named": true "named": true
@ -3092,10 +3092,6 @@
"type": "color_set_definition", "type": "color_set_definition",
"named": true "named": true
}, },
{
"type": "command",
"named": true
},
{ {
"type": "comment_environment", "type": "comment_environment",
"named": true "named": true
@ -3116,6 +3112,10 @@
"type": "environment_definition", "type": "environment_definition",
"named": true "named": true
}, },
{
"type": "generic_command",
"named": true
},
{ {
"type": "generic_environment", "type": "generic_environment",
"named": true "named": true
@ -3643,10 +3643,6 @@
"type": "color_set_definition", "type": "color_set_definition",
"named": true "named": true
}, },
{
"type": "command",
"named": true
},
{ {
"type": "comment_environment", "type": "comment_environment",
"named": true "named": true
@ -3667,6 +3663,10 @@
"type": "environment_definition", "type": "environment_definition",
"named": true "named": true
}, },
{
"type": "generic_command",
"named": true
},
{ {
"type": "generic_environment", "type": "generic_environment",
"named": true "named": true
@ -3886,10 +3886,6 @@
"type": "color_set_definition", "type": "color_set_definition",
"named": true "named": true
}, },
{
"type": "command",
"named": true
},
{ {
"type": "comment_environment", "type": "comment_environment",
"named": true "named": true
@ -3906,6 +3902,10 @@
"type": "environment_definition", "type": "environment_definition",
"named": true "named": true
}, },
{
"type": "generic_command",
"named": true
},
{ {
"type": "generic_environment", "type": "generic_environment",
"named": true "named": true
@ -4249,10 +4249,6 @@
"type": "color_set_definition", "type": "color_set_definition",
"named": true "named": true
}, },
{
"type": "command",
"named": true
},
{ {
"type": "comment_environment", "type": "comment_environment",
"named": true "named": true
@ -4273,6 +4269,10 @@
"type": "environment_definition", "type": "environment_definition",
"named": true "named": true
}, },
{
"type": "generic_command",
"named": true
},
{ {
"type": "generic_environment", "type": "generic_environment",
"named": true "named": true
@ -4473,10 +4473,6 @@
"type": "color_set_definition", "type": "color_set_definition",
"named": true "named": true
}, },
{
"type": "command",
"named": true
},
{ {
"type": "comment_environment", "type": "comment_environment",
"named": true "named": true
@ -4497,6 +4493,10 @@
"type": "environment_definition", "type": "environment_definition",
"named": true "named": true
}, },
{
"type": "generic_command",
"named": true
},
{ {
"type": "generic_environment", "type": "generic_environment",
"named": true "named": true
@ -4745,10 +4745,6 @@
"type": "color_set_definition", "type": "color_set_definition",
"named": true "named": true
}, },
{
"type": "command",
"named": true
},
{ {
"type": "comment_environment", "type": "comment_environment",
"named": true "named": true
@ -4769,6 +4765,10 @@
"type": "environment_definition", "type": "environment_definition",
"named": true "named": true
}, },
{
"type": "generic_command",
"named": true
},
{ {
"type": "generic_environment", "type": "generic_environment",
"named": true "named": true
@ -4948,10 +4948,6 @@
"type": "color_set_definition", "type": "color_set_definition",
"named": true "named": true
}, },
{
"type": "command",
"named": true
},
{ {
"type": "comment_environment", "type": "comment_environment",
"named": true "named": true
@ -4972,6 +4968,10 @@
"type": "environment_definition", "type": "environment_definition",
"named": true "named": true
}, },
{
"type": "generic_command",
"named": true
},
{ {
"type": "generic_environment", "type": "generic_environment",
"named": true "named": true
@ -5180,10 +5180,6 @@
"type": "color_set_definition", "type": "color_set_definition",
"named": true "named": true
}, },
{
"type": "command",
"named": true
},
{ {
"type": "comment_environment", "type": "comment_environment",
"named": true "named": true
@ -5204,6 +5200,10 @@
"type": "environment_definition", "type": "environment_definition",
"named": true "named": true
}, },
{
"type": "generic_command",
"named": true
},
{ {
"type": "generic_environment", "type": "generic_environment",
"named": true "named": true
@ -5388,10 +5388,6 @@
"type": "color_set_definition", "type": "color_set_definition",
"named": true "named": true
}, },
{
"type": "command",
"named": true
},
{ {
"type": "comment_environment", "type": "comment_environment",
"named": true "named": true
@ -5412,6 +5408,10 @@
"type": "environment_definition", "type": "environment_definition",
"named": true "named": true
}, },
{
"type": "generic_command",
"named": true
},
{ {
"type": "generic_environment", "type": "generic_environment",
"named": true "named": true
@ -5608,10 +5608,6 @@
"type": "color_set_definition", "type": "color_set_definition",
"named": true "named": true
}, },
{
"type": "command",
"named": true
},
{ {
"type": "comment_environment", "type": "comment_environment",
"named": true "named": true
@ -5632,6 +5628,10 @@
"type": "environment_definition", "type": "environment_definition",
"named": true "named": true
}, },
{
"type": "generic_command",
"named": true
},
{ {
"type": "generic_environment", "type": "generic_environment",
"named": true "named": true
@ -5963,10 +5963,6 @@
"type": "color_set_definition", "type": "color_set_definition",
"named": true "named": true
}, },
{
"type": "command",
"named": true
},
{ {
"type": "curly_group", "type": "curly_group",
"named": true "named": true
@ -5979,6 +5975,10 @@
"type": "environment_definition", "type": "environment_definition",
"named": true "named": true
}, },
{
"type": "generic_command",
"named": true
},
{ {
"type": "glossary_entry_definition", "type": "glossary_entry_definition",
"named": true "named": true

1084
src/parser.c vendored

File diff suppressed because it is too large Load Diff

@ -7,7 +7,7 @@ Command without arguments
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
(source_file (source_file
(command (generic_command
(command_name)) (command_name))
(text (text
(word))) (word)))
@ -21,7 +21,7 @@ Command with one curly argument
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
(source_file (source_file
(command (generic_command
(command_name) (command_name)
(curly_group (curly_group
(text (text
@ -36,7 +36,7 @@ Command with one curly argument and one mixed argument
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
(source_file (source_file
(command (generic_command
(command_name) (command_name)
(curly_group (curly_group
(text (text
@ -54,7 +54,7 @@ Command with nested paren argument
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
(source_file (source_file
(command (generic_command
(command_name) (command_name)
(mixed_group (mixed_group
(mixed_group (mixed_group

@ -42,7 +42,7 @@ Package include with options
(value (value
(text (text
(word)) (word))
(command (generic_command
(command_name)))) (command_name))))
(key_value_pair (key_value_pair
(text (text
@ -98,7 +98,7 @@ Class include with options
(value (value
(text (text
(word)) (word))
(command (generic_command
(command_name)))) (command_name))))
(key_value_pair (key_value_pair
(text (text

@ -25,7 +25,7 @@ foo foo foo foo foo foo
(curly_group_text (curly_group_text
(text (text
(word)))) (word))))
(command (generic_command
(command_name) (command_name)
(curly_group (curly_group
(text (text
@ -38,7 +38,7 @@ foo foo foo foo foo foo
(word) (word)
(word) (word)
(word)) (word))
(command (generic_command
(command_name) (command_name)
(curly_group (curly_group
(text (text
@ -56,7 +56,7 @@ foo foo foo foo foo foo
(word) (word)
(word) (word)
(word)) (word))
(command (generic_command
(command_name) (command_name)
(curly_group (curly_group
(text (text
@ -143,23 +143,23 @@ tree-sitter-latex (Issue #10)
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
(source_file (source_file
(command (generic_command
(command_name) (command_name)
(curly_group (curly_group
(section)) (section))
(curly_group (curly_group
(command (generic_command
(command_name))) (command_name)))
(curly_group (curly_group
(command (generic_command
(command_name))) (command_name)))
(curly_group (curly_group
(text (text
(word))) (word)))
(curly_group (curly_group
(command (generic_command
(command_name)))) (command_name))))
(command (generic_command
(command_name) (command_name)
(curly_group (curly_group
(paragraph)) (paragraph))
@ -169,12 +169,12 @@ tree-sitter-latex (Issue #10)
(curly_group (curly_group
(text (text
(word)) (word))
(command (generic_command
(command_name))) (command_name)))
(curly_group (curly_group
(text (text
(word)) (word))
(command (generic_command
(command_name))))) (command_name)))))
================================================================================ ================================================================================
@ -197,7 +197,7 @@ rm -rf "$(biber --cache)"
(text (text
(word) (word)
(word)) (word))
(command (generic_command
(command_name) (command_name)
(curly_group (curly_group
(text (text
@ -233,13 +233,13 @@ tree-sitter-latex (Issue #11)
(text (text
(word))) (word)))
(curly_group_impl (curly_group_impl
(command (generic_command
(command_name) (command_name)
(curly_group (curly_group
(text (text
(word))))) (word)))))
(curly_group_impl (curly_group_impl
(command (generic_command
(command_name) (command_name)
(curly_group (curly_group
(text (text
@ -255,23 +255,23 @@ tree-sitter-latex (Issue #10)
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
(source_file (source_file
(command (generic_command
(command_name) (command_name)
(curly_group (curly_group
(section)) (section))
(curly_group (curly_group
(command (generic_command
(command_name))) (command_name)))
(curly_group (curly_group
(command (generic_command
(command_name))) (command_name)))
(curly_group (curly_group
(text (text
(word))) (word)))
(curly_group (curly_group
(command (generic_command
(command_name)))) (command_name))))
(command (generic_command
(command_name) (command_name)
(curly_group (curly_group
(paragraph)) (paragraph))
@ -281,12 +281,12 @@ tree-sitter-latex (Issue #10)
(curly_group (curly_group
(text (text
(word)) (word))
(command (generic_command
(command_name))) (command_name)))
(curly_group (curly_group
(text (text
(word)) (word))
(command (generic_command
(command_name))))) (command_name)))))
================================================================================ ================================================================================
@ -306,7 +306,7 @@ tree-sitter-latex (Issue #13)
(value (value
(text (text
(word)) (word))
(command (generic_command
(command_name))))) (command_name)))))
(curly_group_path (curly_group_path
(path)))) (path))))
@ -364,7 +364,7 @@ tree-sitter-latex (Issue #25 Nesting of document structure)
(enum_item (enum_item
(text (text
word: (word)) word: (word))
(command (generic_command
command: (command_name) command: (command_name)
arg: (curly_group arg: (curly_group
(text (text

@ -68,7 +68,7 @@ Nested sections
(word)) (word))
(part (part
(curly_group (curly_group
(command (generic_command
(command_name))) (command_name)))
(text (text
(word)) (word))

@ -21,7 +21,7 @@ Escaped percent
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
(source_file (source_file
(command (generic_command
(command_name)) (command_name))
(text (text
(word))) (word)))