Start adding fields

This commit is contained in:
Max Brunsfeld 2019-12-10 13:18:29 -08:00
parent 2a3aec5635
commit de690d849a
5 changed files with 81663 additions and 79644 deletions

View File

@ -9,11 +9,18 @@ cat foo | grep -v bar
(program (program
(pipeline (pipeline
(command (command_name (word))) (command
(command (command_name (word)))) name: (command_name (word)))
(command
name: (command_name (word))))
(pipeline (pipeline
(command (command_name (word)) (word)) (command
(command (command_name (word)) (word) (word)))) name: (command_name (word))
argument: (word))
(command
name: (command_name (word))
argument: (word)
argument: (word))))
=================================== ===================================
Lists Lists
@ -48,10 +55,12 @@ done
(program (program
(while_statement (while_statement
(command (command_name (word)) (word)) condition: (command
(do_group name: (command_name (word))
(command (command_name (word)) (word)) argument: (word))
(command (command_name (word)) (word))))) body: (do_group
(command name: (command_name (word)) argument: (word))
(command name: (command_name (word)) argument: (word)))))
==================================== ====================================
While statements with IO redirects While statements with IO redirects
@ -65,12 +74,18 @@ done < <(cat file)
(program (program
(redirected_statement (redirected_statement
(while_statement body: (while_statement
(command (command_name (word)) (word)) condition: (command
(do_group name: (command_name (word))
(command (command_name (word)) (simple_expansion (variable_name))))) argument: (word))
(file_redirect (process_substitution body: (do_group
(command (command_name (word)) (word)))))) (command
name: (command_name (word))
argument: (simple_expansion (variable_name)))))
redirect: (file_redirect
destination: (process_substitution (command
name: (command_name (word))
argument: (word))))))
==================================== ====================================
For statements For statements
@ -89,17 +104,26 @@ done
(program (program
(for_statement (for_statement
(variable_name) variable: (variable_name)
(word) value: (word)
(word) value: (word)
(command_substitution (command (command_name (word)) (word) (word))) value: (command_substitution (command
(do_group name: (command_name (word))
(command (command_name (word)) (simple_expansion (variable_name))))) argument: (word)
argument: (word)))
body: (do_group
(command
name: (command_name (word))
argument: (simple_expansion (variable_name)))))
(for_statement (for_statement
(variable_name) variable: (variable_name)
(do_group body: (do_group
(command (command_name (word)) (simple_expansion (variable_name))) (command
(variable_assignment (variable_name) (raw_string))))) name: (command_name (word))
argument: (simple_expansion (variable_name)))
(variable_assignment
name: (variable_name)
value: (raw_string)))))
==================================== ====================================
C-style for statements C-style for statements

View File

@ -97,45 +97,45 @@ module.exports = grammar({
), ),
redirected_statement: $ => prec(-1, seq( redirected_statement: $ => prec(-1, seq(
$._statement, field('body', $._statement),
repeat1(choice( field('redirect', repeat1(choice(
$.file_redirect, $.file_redirect,
$.heredoc_redirect, $.heredoc_redirect,
$.herestring_redirect $.herestring_redirect
)) )))
)), )),
for_statement: $ => seq( for_statement: $ => seq(
'for', 'for',
$._simple_variable_name, field('variable', $._simple_variable_name),
optional(seq( optional(seq(
'in', 'in',
repeat1($._literal) field('value', repeat1($._literal))
)), )),
$._terminator, $._terminator,
$.do_group field('body', $.do_group)
), ),
c_style_for_statement: $ => seq( c_style_for_statement: $ => seq(
'for', 'for',
'((', '((',
optional($._expression), field('initializer', optional($._expression)),
$._terminator, $._terminator,
optional($._expression), field('condition', optional($._expression)),
$._terminator, $._terminator,
optional($._expression), field('update', optional($._expression)),
'))', '))',
optional(';'), optional(';'),
choice( field('body', choice(
$.do_group, $.do_group,
$.compound_statement $.compound_statement
) ))
), ),
while_statement: $ => seq( while_statement: $ => seq(
'while', 'while',
$._terminated_statement, field('condition', $._terminated_statement),
$.do_group field('body', $.do_group)
), ),
do_group: $ => seq( do_group: $ => seq(
@ -146,7 +146,7 @@ module.exports = grammar({
if_statement: $ => seq( if_statement: $ => seq(
'if', 'if',
$._terminated_statement, field('condition', $._terminated_statement),
'then', 'then',
optional($._statements2), optional($._statements2),
repeat($.elif_clause), repeat($.elif_clause),
@ -168,7 +168,7 @@ module.exports = grammar({
case_statement: $ => seq( case_statement: $ => seq(
'case', 'case',
$._literal, field('value', $._literal),
optional($._terminator), optional($._terminator),
'in', 'in',
$._terminator, $._terminator,
@ -180,16 +180,16 @@ module.exports = grammar({
), ),
case_item: $ => seq( case_item: $ => seq(
$._literal, field('value', $._literal),
repeat(seq('|', $._literal)), repeat(seq('|', field('value', $._literal))),
')', ')',
optional($._statements), optional($._statements),
prec(1, ';;') prec(1, ';;')
), ),
last_case_item: $ => seq( last_case_item: $ => seq(
$._literal, field('value', $._literal),
repeat(seq('|', $._literal)), repeat(seq('|', field('value', $._literal))),
')', ')',
optional($._statements), optional($._statements),
optional(prec(1, ';;')) optional(prec(1, ';;'))
@ -197,19 +197,22 @@ module.exports = grammar({
function_definition: $ => seq( function_definition: $ => seq(
choice( choice(
seq('function', $.word, optional(seq('(', ')'))), seq(
seq($.word, '(', ')') 'function',
field('name', $.word),
optional(seq('(', ')'))
), ),
$.compound_statement seq(
field('name', $.word),
'(', ')'
)
),
field('body', $.compound_statement)
), ),
compound_statement: $ => seq( compound_statement: $ => seq(
'{', '{',
repeat(seq( optional($._statements2),
$._statement,
optional(seq('\n', $.heredoc_body)),
$._terminator
)),
'}' '}'
), ),
@ -272,47 +275,47 @@ module.exports = grammar({
$.variable_assignment, $.variable_assignment,
$.file_redirect $.file_redirect
)), )),
$.command_name, field('name', $.command_name),
repeat(choice( repeat(field('argument', choice(
$._literal, $._literal,
seq( seq(
choice('=~', '=='), choice('=~', '=='),
choice($._literal, $.regex) choice($._literal, $.regex)
) )
)) )))
)), )),
command_name: $ => $._literal, command_name: $ => $._literal,
variable_assignment: $ => seq( variable_assignment: $ => seq(
choice( field('name', choice(
$.variable_name, $.variable_name,
$.subscript $.subscript
), )),
choice( choice(
'=', '=',
'+=' '+='
), ),
choice( field('value', choice(
$._literal, $._literal,
$.array, $.array,
$._empty_value $._empty_value
) ))
), ),
subscript: $ => seq( subscript: $ => seq(
$.variable_name, field('name', $.variable_name),
'[', '[',
$._literal, field('index', $._literal),
optional($._concat), optional($._concat),
']', ']',
optional($._concat) optional($._concat)
), ),
file_redirect: $ => prec.left(seq( file_redirect: $ => prec.left(seq(
optional($.file_descriptor), field('descriptor', optional($.file_descriptor)),
choice('<', '>', '>>', '&>', '&>>', '<&', '>&'), choice('<', '>', '>>', '&>', '&>>', '<&', '>&'),
$._literal field('destination', $._literal)
)), )),
heredoc_redirect: $ => seq( heredoc_redirect: $ => seq(
@ -351,20 +354,20 @@ module.exports = grammar({
binary_expression: $ => prec.left(choice( binary_expression: $ => prec.left(choice(
seq( seq(
$._expression, field('left', $._expression),
choice( field('operator', choice(
'=', '==', '=~', '!=', '=', '==', '=~', '!=',
'+', '-', '+=', '-=', '+', '-', '+=', '-=',
'<', '>', '<=', '>=', '<', '>', '<=', '>=',
'||', '&&', '||', '&&',
$.test_operator $.test_operator
), )),
$._expression field('right', $._expression)
), ),
seq( seq(
$._expression, field('left', $._expression),
choice('==', '=~'), field('operator', choice('==', '=~')),
$.regex field('right', $.regex)
) )
)), )),

163
src/grammar.json vendored
View File

@ -227,10 +227,17 @@
"type": "SEQ", "type": "SEQ",
"members": [ "members": [
{ {
"type": "FIELD",
"name": "body",
"content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_statement" "name": "_statement"
}
}, },
{ {
"type": "FIELD",
"name": "redirect",
"content": {
"type": "REPEAT1", "type": "REPEAT1",
"content": { "content": {
"type": "CHOICE", "type": "CHOICE",
@ -250,6 +257,7 @@
] ]
} }
} }
}
] ]
} }
}, },
@ -261,8 +269,12 @@
"value": "for" "value": "for"
}, },
{ {
"type": "FIELD",
"name": "variable",
"content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_simple_variable_name" "name": "_simple_variable_name"
}
}, },
{ {
"type": "CHOICE", "type": "CHOICE",
@ -275,12 +287,16 @@
"value": "in" "value": "in"
}, },
{ {
"type": "FIELD",
"name": "value",
"content": {
"type": "REPEAT1", "type": "REPEAT1",
"content": { "content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_literal" "name": "_literal"
} }
} }
}
] ]
}, },
{ {
@ -293,9 +309,13 @@
"name": "_terminator" "name": "_terminator"
}, },
{ {
"type": "FIELD",
"name": "body",
"content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "do_group" "name": "do_group"
} }
}
] ]
}, },
"c_style_for_statement": { "c_style_for_statement": {
@ -310,6 +330,9 @@
"value": "((" "value": "(("
}, },
{ {
"type": "FIELD",
"name": "initializer",
"content": {
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [
{ {
@ -320,12 +343,16 @@
"type": "BLANK" "type": "BLANK"
} }
] ]
}
}, },
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_terminator" "name": "_terminator"
}, },
{ {
"type": "FIELD",
"name": "condition",
"content": {
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [
{ {
@ -336,12 +363,16 @@
"type": "BLANK" "type": "BLANK"
} }
] ]
}
}, },
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_terminator" "name": "_terminator"
}, },
{ {
"type": "FIELD",
"name": "update",
"content": {
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [
{ {
@ -352,6 +383,7 @@
"type": "BLANK" "type": "BLANK"
} }
] ]
}
}, },
{ {
"type": "STRING", "type": "STRING",
@ -370,6 +402,9 @@
] ]
}, },
{ {
"type": "FIELD",
"name": "body",
"content": {
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [
{ {
@ -382,6 +417,7 @@
} }
] ]
} }
}
] ]
}, },
"while_statement": { "while_statement": {
@ -392,13 +428,21 @@
"value": "while" "value": "while"
}, },
{ {
"type": "FIELD",
"name": "condition",
"content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_terminated_statement" "name": "_terminated_statement"
}
}, },
{ {
"type": "FIELD",
"name": "body",
"content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "do_group" "name": "do_group"
} }
}
] ]
}, },
"do_group": { "do_group": {
@ -434,8 +478,12 @@
"value": "if" "value": "if"
}, },
{ {
"type": "FIELD",
"name": "condition",
"content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_terminated_statement" "name": "_terminated_statement"
}
}, },
{ {
"type": "STRING", "type": "STRING",
@ -536,8 +584,12 @@
"value": "case" "value": "case"
}, },
{ {
"type": "FIELD",
"name": "value",
"content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_literal" "name": "_literal"
}
}, },
{ {
"type": "CHOICE", "type": "CHOICE",
@ -598,8 +650,12 @@
"type": "SEQ", "type": "SEQ",
"members": [ "members": [
{ {
"type": "FIELD",
"name": "value",
"content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_literal" "name": "_literal"
}
}, },
{ {
"type": "REPEAT", "type": "REPEAT",
@ -611,9 +667,13 @@
"value": "|" "value": "|"
}, },
{ {
"type": "FIELD",
"name": "value",
"content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_literal" "name": "_literal"
} }
}
] ]
} }
}, },
@ -647,8 +707,12 @@
"type": "SEQ", "type": "SEQ",
"members": [ "members": [
{ {
"type": "FIELD",
"name": "value",
"content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_literal" "name": "_literal"
}
}, },
{ {
"type": "REPEAT", "type": "REPEAT",
@ -660,9 +724,13 @@
"value": "|" "value": "|"
}, },
{ {
"type": "FIELD",
"name": "value",
"content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_literal" "name": "_literal"
} }
}
] ]
} }
}, },
@ -714,8 +782,12 @@
"value": "function" "value": "function"
}, },
{ {
"type": "FIELD",
"name": "name",
"content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "word" "name": "word"
}
}, },
{ {
"type": "CHOICE", "type": "CHOICE",
@ -744,8 +816,12 @@
"type": "SEQ", "type": "SEQ",
"members": [ "members": [
{ {
"type": "FIELD",
"name": "name",
"content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "word" "name": "word"
}
}, },
{ {
"type": "STRING", "type": "STRING",
@ -760,9 +836,13 @@
] ]
}, },
{ {
"type": "FIELD",
"name": "body",
"content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "compound_statement" "name": "compound_statement"
} }
}
] ]
}, },
"compound_statement": { "compound_statement": {
@ -772,43 +852,18 @@
"type": "STRING", "type": "STRING",
"value": "{" "value": "{"
}, },
{
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_statement"
},
{ {
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "\n"
},
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "heredoc_body" "name": "_statements2"
}
]
}, },
{ {
"type": "BLANK" "type": "BLANK"
} }
] ]
}, },
{
"type": "SYMBOL",
"name": "_terminator"
}
]
}
},
{ {
"type": "STRING", "type": "STRING",
"value": "}" "value": "}"
@ -1094,11 +1149,18 @@
} }
}, },
{ {
"type": "FIELD",
"name": "name",
"content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "command_name" "name": "command_name"
}
}, },
{ {
"type": "REPEAT", "type": "REPEAT",
"content": {
"type": "FIELD",
"name": "argument",
"content": { "content": {
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [
@ -1140,6 +1202,7 @@
] ]
} }
} }
}
] ]
} }
}, },
@ -1151,6 +1214,9 @@
"type": "SEQ", "type": "SEQ",
"members": [ "members": [
{ {
"type": "FIELD",
"name": "name",
"content": {
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [
{ {
@ -1162,6 +1228,7 @@
"name": "subscript" "name": "subscript"
} }
] ]
}
}, },
{ {
"type": "CHOICE", "type": "CHOICE",
@ -1177,6 +1244,9 @@
] ]
}, },
{ {
"type": "FIELD",
"name": "value",
"content": {
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [
{ {
@ -1193,22 +1263,31 @@
} }
] ]
} }
}
] ]
}, },
"subscript": { "subscript": {
"type": "SEQ", "type": "SEQ",
"members": [ "members": [
{ {
"type": "FIELD",
"name": "name",
"content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "variable_name" "name": "variable_name"
}
}, },
{ {
"type": "STRING", "type": "STRING",
"value": "[" "value": "["
}, },
{ {
"type": "FIELD",
"name": "index",
"content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_literal" "name": "_literal"
}
}, },
{ {
"type": "CHOICE", "type": "CHOICE",
@ -1247,6 +1326,9 @@
"type": "SEQ", "type": "SEQ",
"members": [ "members": [
{ {
"type": "FIELD",
"name": "descriptor",
"content": {
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [
{ {
@ -1257,6 +1339,7 @@
"type": "BLANK" "type": "BLANK"
} }
] ]
}
}, },
{ {
"type": "CHOICE", "type": "CHOICE",
@ -1292,9 +1375,13 @@
] ]
}, },
{ {
"type": "FIELD",
"name": "destination",
"content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_literal" "name": "_literal"
} }
}
] ]
} }
}, },
@ -1414,10 +1501,17 @@
"type": "SEQ", "type": "SEQ",
"members": [ "members": [
{ {
"type": "FIELD",
"name": "left",
"content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_expression" "name": "_expression"
}
}, },
{ {
"type": "FIELD",
"name": "operator",
"content": {
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [
{ {
@ -1481,21 +1575,33 @@
"name": "test_operator" "name": "test_operator"
} }
] ]
}
}, },
{ {
"type": "FIELD",
"name": "right",
"content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_expression" "name": "_expression"
} }
}
] ]
}, },
{ {
"type": "SEQ", "type": "SEQ",
"members": [ "members": [
{ {
"type": "FIELD",
"name": "left",
"content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_expression" "name": "_expression"
}
}, },
{ {
"type": "FIELD",
"name": "operator",
"content": {
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [
{ {
@ -1507,11 +1613,16 @@
"value": "=~" "value": "=~"
} }
] ]
}
}, },
{ {
"type": "FIELD",
"name": "right",
"content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "regex" "name": "regex"
} }
}
] ]
} }
] ]

717
src/node-types.json vendored
View File

@ -53,9 +53,137 @@
{ {
"type": "binary_expression", "type": "binary_expression",
"named": true, "named": true,
"fields": {}, "fields": {
"children": { "left": {
"multiple": true, "multiple": false,
"required": true,
"types": [
{
"type": "ansii_c_string",
"named": true
},
{
"type": "binary_expression",
"named": true
},
{
"type": "command_substitution",
"named": true
},
{
"type": "concatenation",
"named": true
},
{
"type": "expansion",
"named": true
},
{
"type": "parenthesized_expression",
"named": true
},
{
"type": "postfix_expression",
"named": true
},
{
"type": "process_substitution",
"named": true
},
{
"type": "raw_string",
"named": true
},
{
"type": "simple_expansion",
"named": true
},
{
"type": "string",
"named": true
},
{
"type": "string_expansion",
"named": true
},
{
"type": "unary_expression",
"named": true
},
{
"type": "word",
"named": true
}
]
},
"operator": {
"multiple": false,
"required": true,
"types": [
{
"type": "!=",
"named": false
},
{
"type": "&&",
"named": false
},
{
"type": "+",
"named": false
},
{
"type": "+=",
"named": false
},
{
"type": "-",
"named": false
},
{
"type": "-=",
"named": false
},
{
"type": "<",
"named": false
},
{
"type": "<=",
"named": false
},
{
"type": "=",
"named": false
},
{
"type": "==",
"named": false
},
{
"type": "=~",
"named": false
},
{
"type": ">",
"named": false
},
{
"type": ">=",
"named": false
},
{
"type": "test_operator",
"named": true
},
{
"type": "||",
"named": false
}
]
},
"right": {
"multiple": false,
"required": true, "required": true,
"types": [ "types": [
{ {
@ -110,10 +238,6 @@
"type": "string_expansion", "type": "string_expansion",
"named": true "named": true
}, },
{
"type": "test_operator",
"named": true
},
{ {
"type": "unary_expression", "type": "unary_expression",
"named": true "named": true
@ -124,14 +248,29 @@
} }
] ]
} }
}
}, },
{ {
"type": "c_style_for_statement", "type": "c_style_for_statement",
"named": true, "named": true,
"fields": {}, "fields": {
"children": { "body": {
"multiple": true, "multiple": false,
"required": true, "required": true,
"types": [
{
"type": "compound_statement",
"named": true
},
{
"type": "do_group",
"named": true
}
]
},
"condition": {
"multiple": false,
"required": false,
"types": [ "types": [
{ {
"type": "ansii_c_string", "type": "ansii_c_string",
@ -146,7 +285,65 @@
"named": true "named": true
}, },
{ {
"type": "compound_statement", "type": "concatenation",
"named": true
},
{
"type": "expansion",
"named": true
},
{
"type": "parenthesized_expression",
"named": true
},
{
"type": "postfix_expression",
"named": true
},
{
"type": "process_substitution",
"named": true
},
{
"type": "raw_string",
"named": true
},
{
"type": "simple_expansion",
"named": true
},
{
"type": "string",
"named": true
},
{
"type": "string_expansion",
"named": true
},
{
"type": "unary_expression",
"named": true
},
{
"type": "word",
"named": true
}
]
},
"initializer": {
"multiple": false,
"required": false,
"types": [
{
"type": "ansii_c_string",
"named": true
},
{
"type": "binary_expression",
"named": true
},
{
"type": "command_substitution",
"named": true "named": true
}, },
{ {
@ -154,7 +351,65 @@
"named": true "named": true
}, },
{ {
"type": "do_group", "type": "expansion",
"named": true
},
{
"type": "parenthesized_expression",
"named": true
},
{
"type": "postfix_expression",
"named": true
},
{
"type": "process_substitution",
"named": true
},
{
"type": "raw_string",
"named": true
},
{
"type": "simple_expansion",
"named": true
},
{
"type": "string",
"named": true
},
{
"type": "string_expansion",
"named": true
},
{
"type": "unary_expression",
"named": true
},
{
"type": "word",
"named": true
}
]
},
"update": {
"multiple": false,
"required": false,
"types": [
{
"type": "ansii_c_string",
"named": true
},
{
"type": "binary_expression",
"named": true
},
{
"type": "command_substitution",
"named": true
},
{
"type": "concatenation",
"named": true "named": true
}, },
{ {
@ -199,12 +454,13 @@
} }
] ]
} }
}
}, },
{ {
"type": "case_item", "type": "case_item",
"named": true, "named": true,
"fields": {}, "fields": {
"children": { "value": {
"multiple": true, "multiple": true,
"required": true, "required": true,
"types": [ "types": [
@ -212,6 +468,49 @@
"type": "ansii_c_string", "type": "ansii_c_string",
"named": true "named": true
}, },
{
"type": "command_substitution",
"named": true
},
{
"type": "concatenation",
"named": true
},
{
"type": "expansion",
"named": true
},
{
"type": "process_substitution",
"named": true
},
{
"type": "raw_string",
"named": true
},
{
"type": "simple_expansion",
"named": true
},
{
"type": "string",
"named": true
},
{
"type": "string_expansion",
"named": true
},
{
"type": "word",
"named": true
}
]
}
},
"children": {
"multiple": true,
"required": false,
"types": [
{ {
"type": "c_style_for_statement", "type": "c_style_for_statement",
"named": true "named": true
@ -224,26 +523,14 @@
"type": "command", "type": "command",
"named": true "named": true
}, },
{
"type": "command_substitution",
"named": true
},
{ {
"type": "compound_statement", "type": "compound_statement",
"named": true "named": true
}, },
{
"type": "concatenation",
"named": true
},
{ {
"type": "declaration_command", "type": "declaration_command",
"named": true "named": true
}, },
{
"type": "expansion",
"named": true
},
{ {
"type": "for_statement", "type": "for_statement",
"named": true "named": true
@ -272,30 +559,10 @@
"type": "pipeline", "type": "pipeline",
"named": true "named": true
}, },
{
"type": "process_substitution",
"named": true
},
{
"type": "raw_string",
"named": true
},
{ {
"type": "redirected_statement", "type": "redirected_statement",
"named": true "named": true
}, },
{
"type": "simple_expansion",
"named": true
},
{
"type": "string",
"named": true
},
{
"type": "string_expansion",
"named": true
},
{ {
"type": "subshell", "type": "subshell",
"named": true "named": true
@ -315,10 +582,6 @@
{ {
"type": "while_statement", "type": "while_statement",
"named": true "named": true
},
{
"type": "word",
"named": true
} }
] ]
} }
@ -326,19 +589,15 @@
{ {
"type": "case_statement", "type": "case_statement",
"named": true, "named": true,
"fields": {}, "fields": {
"children": { "value": {
"multiple": true, "multiple": false,
"required": true, "required": true,
"types": [ "types": [
{ {
"type": "ansii_c_string", "type": "ansii_c_string",
"named": true "named": true
}, },
{
"type": "case_item",
"named": true
},
{ {
"type": "command_substitution", "type": "command_substitution",
"named": true "named": true
@ -378,20 +637,35 @@
] ]
} }
}, },
"children": {
"multiple": true,
"required": false,
"types": [
{
"type": "case_item",
"named": true
}
]
}
},
{ {
"type": "command", "type": "command",
"named": true, "named": true,
"fields": {}, "fields": {
"children": { "argument": {
"multiple": true, "multiple": true,
"required": true, "required": false,
"types": [ "types": [
{ {
"type": "ansii_c_string", "type": "==",
"named": true "named": false
}, },
{ {
"type": "command_name", "type": "=~",
"named": false
},
{
"type": "ansii_c_string",
"named": true "named": true
}, },
{ {
@ -406,10 +680,6 @@
"type": "expansion", "type": "expansion",
"named": true "named": true
}, },
{
"type": "file_redirect",
"named": true
},
{ {
"type": "process_substitution", "type": "process_substitution",
"named": true "named": true
@ -435,11 +705,32 @@
"named": true "named": true
}, },
{ {
"type": "variable_assignment", "type": "word",
"named": true
}
]
},
"name": {
"multiple": false,
"required": true,
"types": [
{
"type": "command_name",
"named": true
}
]
}
},
"children": {
"multiple": true,
"required": false,
"types": [
{
"type": "file_redirect",
"named": true "named": true
}, },
{ {
"type": "word", "type": "variable_assignment",
"named": true "named": true
} }
] ]
@ -1091,9 +1382,19 @@
{ {
"type": "file_redirect", "type": "file_redirect",
"named": true, "named": true,
"fields": {}, "fields": {
"children": { "descriptor": {
"multiple": true, "multiple": false,
"required": false,
"types": [
{
"type": "file_descriptor",
"named": true
}
]
},
"destination": {
"multiple": false,
"required": true, "required": true,
"types": [ "types": [
{ {
@ -1112,10 +1413,6 @@
"type": "expansion", "type": "expansion",
"named": true "named": true
}, },
{
"type": "file_descriptor",
"named": true
},
{ {
"type": "process_substitution", "type": "process_substitution",
"named": true "named": true
@ -1142,14 +1439,25 @@
} }
] ]
} }
}
}, },
{ {
"type": "for_statement", "type": "for_statement",
"named": true, "named": true,
"fields": {}, "fields": {
"children": { "body": {
"multiple": true, "multiple": false,
"required": true, "required": true,
"types": [
{
"type": "do_group",
"named": true
}
]
},
"value": {
"multiple": false,
"required": false,
"types": [ "types": [
{ {
"type": "ansii_c_string", "type": "ansii_c_string",
@ -1163,10 +1471,6 @@
"type": "concatenation", "type": "concatenation",
"named": true "named": true
}, },
{
"type": "do_group",
"named": true
},
{ {
"type": "expansion", "type": "expansion",
"named": true "named": true
@ -1191,35 +1495,49 @@
"type": "string_expansion", "type": "string_expansion",
"named": true "named": true
}, },
{
"type": "variable_name",
"named": true
},
{ {
"type": "word", "type": "word",
"named": true "named": true
} }
] ]
},
"variable": {
"multiple": false,
"required": true,
"types": [
{
"type": "variable_name",
"named": true
}
]
}
} }
}, },
{ {
"type": "function_definition", "type": "function_definition",
"named": true, "named": true,
"fields": {}, "fields": {
"children": { "body": {
"multiple": true, "multiple": false,
"required": true, "required": true,
"types": [ "types": [
{ {
"type": "compound_statement", "type": "compound_statement",
"named": true "named": true
}
]
}, },
"name": {
"multiple": false,
"required": true,
"types": [
{ {
"type": "word", "type": "word",
"named": true "named": true
} }
] ]
} }
}
}, },
{ {
"type": "heredoc_body", "type": "heredoc_body",
@ -1313,10 +1631,101 @@
{ {
"type": "if_statement", "type": "if_statement",
"named": true, "named": true,
"fields": {}, "fields": {
"condition": {
"multiple": false,
"required": true,
"types": [
{
"type": "\n",
"named": false
},
{
"type": "&",
"named": false
},
{
"type": ";",
"named": false
},
{
"type": ";;",
"named": false
},
{
"type": "c_style_for_statement",
"named": true
},
{
"type": "case_statement",
"named": true
},
{
"type": "command",
"named": true
},
{
"type": "compound_statement",
"named": true
},
{
"type": "declaration_command",
"named": true
},
{
"type": "for_statement",
"named": true
},
{
"type": "function_definition",
"named": true
},
{
"type": "if_statement",
"named": true
},
{
"type": "list",
"named": true
},
{
"type": "negated_command",
"named": true
},
{
"type": "pipeline",
"named": true
},
{
"type": "redirected_statement",
"named": true
},
{
"type": "subshell",
"named": true
},
{
"type": "test_command",
"named": true
},
{
"type": "unset_command",
"named": true
},
{
"type": "variable_assignment",
"named": true
},
{
"type": "while_statement",
"named": true
}
]
}
},
"children": { "children": {
"multiple": true, "multiple": true,
"required": true, "required": false,
"types": [ "types": [
{ {
"type": "c_style_for_statement", "type": "c_style_for_statement",
@ -1885,9 +2294,9 @@
{ {
"type": "redirected_statement", "type": "redirected_statement",
"named": true, "named": true,
"fields": {}, "fields": {
"children": { "body": {
"multiple": true, "multiple": false,
"required": true, "required": true,
"types": [ "types": [
{ {
@ -1910,10 +2319,6 @@
"type": "declaration_command", "type": "declaration_command",
"named": true "named": true
}, },
{
"type": "file_redirect",
"named": true
},
{ {
"type": "for_statement", "type": "for_statement",
"named": true "named": true
@ -1922,14 +2327,6 @@
"type": "function_definition", "type": "function_definition",
"named": true "named": true
}, },
{
"type": "heredoc_redirect",
"named": true
},
{
"type": "herestring_redirect",
"named": true
},
{ {
"type": "if_statement", "type": "if_statement",
"named": true "named": true
@ -1971,6 +2368,25 @@
"named": true "named": true
} }
] ]
},
"redirect": {
"multiple": false,
"required": true,
"types": [
{
"type": "file_redirect",
"named": true
},
{
"type": "heredoc_redirect",
"named": true
},
{
"type": "herestring_redirect",
"named": true
}
]
}
} }
}, },
{ {
@ -2037,9 +2453,9 @@
{ {
"type": "subscript", "type": "subscript",
"named": true, "named": true,
"fields": {}, "fields": {
"children": { "index": {
"multiple": true, "multiple": false,
"required": true, "required": true,
"types": [ "types": [
{ {
@ -2078,15 +2494,22 @@
"type": "string_expansion", "type": "string_expansion",
"named": true "named": true
}, },
{
"type": "variable_name",
"named": true
},
{ {
"type": "word", "type": "word",
"named": true "named": true
} }
] ]
},
"name": {
"multiple": false,
"required": true,
"types": [
{
"type": "variable_name",
"named": true
}
]
}
} }
}, },
{ {
@ -2368,9 +2791,23 @@
{ {
"type": "variable_assignment", "type": "variable_assignment",
"named": true, "named": true,
"fields": {}, "fields": {
"children": { "name": {
"multiple": true, "multiple": false,
"required": true,
"types": [
{
"type": "subscript",
"named": true
},
{
"type": "variable_name",
"named": true
}
]
},
"value": {
"multiple": false,
"required": true, "required": true,
"types": [ "types": [
{ {
@ -2413,29 +2850,48 @@
"type": "string_expansion", "type": "string_expansion",
"named": true "named": true
}, },
{
"type": "subscript",
"named": true
},
{
"type": "variable_name",
"named": true
},
{ {
"type": "word", "type": "word",
"named": true "named": true
} }
] ]
} }
}
}, },
{ {
"type": "while_statement", "type": "while_statement",
"named": true, "named": true,
"fields": {}, "fields": {
"children": { "body": {
"multiple": true, "multiple": false,
"required": true, "required": true,
"types": [ "types": [
{
"type": "do_group",
"named": true
}
]
},
"condition": {
"multiple": false,
"required": true,
"types": [
{
"type": "\n",
"named": false
},
{
"type": "&",
"named": false
},
{
"type": ";",
"named": false
},
{
"type": ";;",
"named": false
},
{ {
"type": "c_style_for_statement", "type": "c_style_for_statement",
"named": true "named": true
@ -2456,10 +2912,6 @@
"type": "declaration_command", "type": "declaration_command",
"named": true "named": true
}, },
{
"type": "do_group",
"named": true
},
{ {
"type": "for_statement", "type": "for_statement",
"named": true "named": true
@ -2510,6 +2962,7 @@
} }
] ]
} }
}
}, },
{ {
"type": "\n", "type": "\n",

158672
src/parser.c vendored

File diff suppressed because it is too large Load Diff