{ "name": "bash", "rules": { "program": { "type": "REPEAT", "content": { "type": "SYMBOL", "name": "_terminated_statement" } }, "_terminated_statement": { "type": "SEQ", "members": [ { "type": "SYMBOL", "name": "_statement" }, { "type": "SYMBOL", "name": "_terminator" } ] }, "_statement": { "type": "CHOICE", "members": [ { "type": "SYMBOL", "name": "environment_variable_assignment" }, { "type": "SYMBOL", "name": "command" }, { "type": "SYMBOL", "name": "bracket_command" }, { "type": "SYMBOL", "name": "for_statement" }, { "type": "SYMBOL", "name": "while_statement" }, { "type": "SYMBOL", "name": "if_statement" }, { "type": "SYMBOL", "name": "case_statement" }, { "type": "SYMBOL", "name": "pipeline" }, { "type": "SYMBOL", "name": "list" }, { "type": "SYMBOL", "name": "subshell" }, { "type": "SYMBOL", "name": "function_definition" } ] }, "for_statement": { "type": "SEQ", "members": [ { "type": "STRING", "value": "for" }, { "type": "SYMBOL", "name": "word" }, { "type": "STRING", "value": "in" }, { "type": "SYMBOL", "name": "_terminated_statement" }, { "type": "SYMBOL", "name": "do_group" } ] }, "while_statement": { "type": "SEQ", "members": [ { "type": "STRING", "value": "while" }, { "type": "SYMBOL", "name": "_terminated_statement" }, { "type": "SYMBOL", "name": "do_group" } ] }, "do_group": { "type": "SEQ", "members": [ { "type": "STRING", "value": "do" }, { "type": "REPEAT", "content": { "type": "SYMBOL", "name": "_terminated_statement" } }, { "type": "STRING", "value": "done" } ] }, "if_statement": { "type": "SEQ", "members": [ { "type": "STRING", "value": "if" }, { "type": "SYMBOL", "name": "_terminated_statement" }, { "type": "STRING", "value": "then" }, { "type": "REPEAT", "content": { "type": "SYMBOL", "name": "_terminated_statement" } }, { "type": "REPEAT", "content": { "type": "SYMBOL", "name": "elif_clause" } }, { "type": "CHOICE", "members": [ { "type": "SYMBOL", "name": "else_clause" }, { "type": "BLANK" } ] }, { "type": "STRING", "value": "fi" } ] }, "elif_clause": { "type": "SEQ", "members": [ { "type": "STRING", "value": "elif" }, { "type": "SYMBOL", "name": "_terminated_statement" }, { "type": "STRING", "value": "then" }, { "type": "REPEAT", "content": { "type": "SYMBOL", "name": "_terminated_statement" } } ] }, "else_clause": { "type": "SEQ", "members": [ { "type": "STRING", "value": "else" }, { "type": "REPEAT", "content": { "type": "SYMBOL", "name": "_terminated_statement" } } ] }, "case_statement": { "type": "SEQ", "members": [ { "type": "STRING", "value": "case" }, { "type": "SYMBOL", "name": "_expression" }, { "type": "CHOICE", "members": [ { "type": "SYMBOL", "name": "_terminator" }, { "type": "BLANK" } ] }, { "type": "STRING", "value": "in" }, { "type": "SYMBOL", "name": "_terminator" }, { "type": "REPEAT", "content": { "type": "SYMBOL", "name": "case_item" } }, { "type": "STRING", "value": "esac" } ] }, "case_item": { "type": "SEQ", "members": [ { "type": "SYMBOL", "name": "_expression" }, { "type": "STRING", "value": ")" }, { "type": "REPEAT", "content": { "type": "SYMBOL", "name": "_terminated_statement" } }, { "type": "STRING", "value": ";;" } ] }, "function_definition": { "type": "SEQ", "members": [ { "type": "CHOICE", "members": [ { "type": "STRING", "value": "function" }, { "type": "BLANK" } ] }, { "type": "RENAME", "content": { "type": "SYMBOL", "name": "leading_word" }, "value": "command_name" }, { "type": "STRING", "value": "(" }, { "type": "STRING", "value": ")" }, { "type": "SYMBOL", "name": "compound_statement" } ] }, "compound_statement": { "type": "SEQ", "members": [ { "type": "STRING", "value": "{" }, { "type": "REPEAT", "content": { "type": "SYMBOL", "name": "_terminated_statement" } }, { "type": "STRING", "value": "}" } ] }, "subshell": { "type": "SEQ", "members": [ { "type": "STRING", "value": "(" }, { "type": "REPEAT", "content": { "type": "SYMBOL", "name": "_terminated_statement" } }, { "type": "STRING", "value": ")" } ] }, "pipeline": { "type": "PREC_LEFT", "value": 1, "content": { "type": "SEQ", "members": [ { "type": "SYMBOL", "name": "_statement" }, { "type": "CHOICE", "members": [ { "type": "STRING", "value": "|" }, { "type": "STRING", "value": "|&" } ] }, { "type": "SYMBOL", "name": "_statement" } ] } }, "list": { "type": "PREC_LEFT", "value": 0, "content": { "type": "SEQ", "members": [ { "type": "SYMBOL", "name": "_statement" }, { "type": "CHOICE", "members": [ { "type": "STRING", "value": "&&" }, { "type": "STRING", "value": "||" } ] }, { "type": "SYMBOL", "name": "_statement" } ] } }, "bracket_command": { "type": "CHOICE", "members": [ { "type": "SEQ", "members": [ { "type": "STRING", "value": "[" }, { "type": "REPEAT1", "content": { "type": "SYMBOL", "name": "_expression" } }, { "type": "STRING", "value": "]" } ] }, { "type": "SEQ", "members": [ { "type": "STRING", "value": "[[" }, { "type": "REPEAT1", "content": { "type": "SYMBOL", "name": "_expression" } }, { "type": "STRING", "value": "]]" } ] } ] }, "command": { "type": "PREC_LEFT", "value": 0, "content": { "type": "SEQ", "members": [ { "type": "REPEAT", "content": { "type": "CHOICE", "members": [ { "type": "SYMBOL", "name": "environment_variable_assignment" }, { "type": "SYMBOL", "name": "file_redirect" } ] } }, { "type": "CHOICE", "members": [ { "type": "RENAME", "content": { "type": "CHOICE", "members": [ { "type": "SYMBOL", "name": "leading_word" } ] }, "value": "command_name" }, { "type": "STRING", "value": ":" }, { "type": "SYMBOL", "name": "string" }, { "type": "SYMBOL", "name": "raw_string" }, { "type": "SYMBOL", "name": "command_substitution" } ] }, { "type": "CHOICE", "members": [ { "type": "SEQ", "members": [ { "type": "PATTERN", "value": "\\s+" }, { "type": "REPEAT", "content": { "type": "SYMBOL", "name": "_expression" } } ] }, { "type": "BLANK" } ] }, { "type": "REPEAT", "content": { "type": "CHOICE", "members": [ { "type": "SYMBOL", "name": "file_redirect" }, { "type": "SYMBOL", "name": "heredoc_redirect" } ] } } ] } }, "environment_variable_assignment": { "type": "SEQ", "members": [ { "type": "RENAME", "content": { "type": "SYMBOL", "name": "leading_word" }, "value": "variable_name" }, { "type": "STRING", "value": "=" }, { "type": "CHOICE", "members": [ { "type": "SYMBOL", "name": "_expression" }, { "type": "SYMBOL", "name": "_empty_value" } ] } ] }, "file_redirect": { "type": "SEQ", "members": [ { "type": "CHOICE", "members": [ { "type": "SYMBOL", "name": "file_descriptor" }, { "type": "BLANK" } ] }, { "type": "CHOICE", "members": [ { "type": "STRING", "value": "<" }, { "type": "STRING", "value": ">" }, { "type": "STRING", "value": ">>" }, { "type": "STRING", "value": "&>" }, { "type": "STRING", "value": "&>>" }, { "type": "STRING", "value": "<&" }, { "type": "STRING", "value": ">&" } ] }, { "type": "SYMBOL", "name": "_expression" } ] }, "heredoc_redirect": { "type": "SEQ", "members": [ { "type": "CHOICE", "members": [ { "type": "STRING", "value": "<<" }, { "type": "STRING", "value": "<<-" } ] }, { "type": "SYMBOL", "name": "heredoc" } ] }, "heredoc": { "type": "CHOICE", "members": [ { "type": "SYMBOL", "name": "_simple_heredoc" }, { "type": "SEQ", "members": [ { "type": "SYMBOL", "name": "_heredoc_beginning" }, { "type": "REPEAT", "content": { "type": "CHOICE", "members": [ { "type": "SYMBOL", "name": "expansion" }, { "type": "SYMBOL", "name": "simple_expansion" }, { "type": "SYMBOL", "name": "_heredoc_middle" } ] } }, { "type": "SYMBOL", "name": "_heredoc_end" } ] } ] }, "_expression": { "type": "CHOICE", "members": [ { "type": "SYMBOL", "name": "word" }, { "type": "SYMBOL", "name": "string" }, { "type": "SYMBOL", "name": "raw_string" }, { "type": "SYMBOL", "name": "expansion" }, { "type": "SYMBOL", "name": "simple_expansion" }, { "type": "SYMBOL", "name": "command_substitution" }, { "type": "SYMBOL", "name": "process_substitution" } ] }, "string": { "type": "SEQ", "members": [ { "type": "STRING", "value": "\"" }, { "type": "REPEAT", "content": { "type": "CHOICE", "members": [ { "type": "PATTERN", "value": "[^\"$]+" }, { "type": "SYMBOL", "name": "expansion" }, { "type": "SYMBOL", "name": "simple_expansion" }, { "type": "SYMBOL", "name": "command_substitution" } ] } }, { "type": "STRING", "value": "\"" } ] }, "raw_string": { "type": "PATTERN", "value": "'[^']*'" }, "simple_expansion": { "type": "SEQ", "members": [ { "type": "STRING", "value": "$" }, { "type": "CHOICE", "members": [ { "type": "RENAME", "content": { "type": "SYMBOL", "name": "simple_variable_name" }, "value": "variable_name" }, { "type": "SYMBOL", "name": "special_variable_name" } ] } ] }, "expansion": { "type": "SEQ", "members": [ { "type": "STRING", "value": "${" }, { "type": "SYMBOL", "name": "_variable_name" }, { "type": "CHOICE", "members": [ { "type": "SEQ", "members": [ { "type": "CHOICE", "members": [ { "type": "STRING", "value": ":" }, { "type": "STRING", "value": ":?" }, { "type": "STRING", "value": "=" }, { "type": "STRING", "value": ":-" } ] }, { "type": "SYMBOL", "name": "_expression" } ] }, { "type": "BLANK" } ] }, { "type": "STRING", "value": "}" } ] }, "_variable_name": { "type": "CHOICE", "members": [ { "type": "RENAME", "content": { "type": "SYMBOL", "name": "leading_word" }, "value": "variable_name" }, { "type": "SYMBOL", "name": "special_variable_name" } ] }, "command_substitution": { "type": "CHOICE", "members": [ { "type": "SEQ", "members": [ { "type": "STRING", "value": "$(" }, { "type": "SYMBOL", "name": "command" }, { "type": "STRING", "value": ")" } ] }, { "type": "SEQ", "members": [ { "type": "STRING", "value": "`" }, { "type": "SYMBOL", "name": "command" }, { "type": "STRING", "value": "`" } ] } ] }, "process_substitution": { "type": "SEQ", "members": [ { "type": "CHOICE", "members": [ { "type": "STRING", "value": "<" }, { "type": "STRING", "value": ">" } ] }, { "type": "STRING", "value": "(" }, { "type": "SYMBOL", "name": "_statement" }, { "type": "STRING", "value": ")" } ] }, "leading_word": { "type": "PATTERN", "value": "[^`\"\\\\\\s#=|;:{}()]+" }, "word": { "type": "PATTERN", "value": "[^\"`#\\\\\\s$<>{}&;()]+" }, "comment": { "type": "PATTERN", "value": "#.*" }, "simple_variable_name": { "type": "PATTERN", "value": "\\w+" }, "special_variable_name": { "type": "CHOICE", "members": [ { "type": "STRING", "value": "*" }, { "type": "STRING", "value": "@" }, { "type": "STRING", "value": "#" }, { "type": "STRING", "value": "?" }, { "type": "STRING", "value": "-" }, { "type": "STRING", "value": "$" }, { "type": "STRING", "value": "!" }, { "type": "STRING", "value": "0" }, { "type": "STRING", "value": "_" } ] }, "_terminator": { "type": "CHOICE", "members": [ { "type": "STRING", "value": ";" }, { "type": "STRING", "value": ";;" }, { "type": "STRING", "value": "\n" }, { "type": "STRING", "value": "&" } ] } }, "extras": [ { "type": "SYMBOL", "name": "comment" }, { "type": "TOKEN", "content": { "type": "CHOICE", "members": [ { "type": "PATTERN", "value": "\\s" }, { "type": "STRING", "value": "\\\n" } ] } } ], "conflicts": [], "externals": [ { "type": "SYMBOL", "name": "_simple_heredoc" }, { "type": "SYMBOL", "name": "_heredoc_beginning" }, { "type": "SYMBOL", "name": "_heredoc_middle" }, { "type": "SYMBOL", "name": "_heredoc_end" }, { "type": "SYMBOL", "name": "file_descriptor" }, { "type": "SYMBOL", "name": "_empty_value" } ], "inline": [ "_statement", "_terminator", "_expression", "_variable_name" ] }