{ "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": "command" }, { "type": "SYMBOL", "name": "while_statement" }, { "type": "SYMBOL", "name": "if_statement" }, { "type": "SYMBOL", "name": "case_statement" }, { "type": "SYMBOL", "name": "pipeline" }, { "type": "SYMBOL", "name": "list" } ] }, "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": "RENAME", "content": { "type": "SYMBOL", "name": "word" }, "value": "argument" }, { "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": "RENAME", "content": { "type": "SYMBOL", "name": "word" }, "value": "argument" }, { "type": "STRING", "value": ")" }, { "type": "REPEAT", "content": { "type": "SYMBOL", "name": "_terminated_statement" } }, { "type": "CHOICE", "members": [ { "type": "STRING", "value": ";;" }, { "type": "BLANK" } ] } ] }, "command": { "type": "SEQ", "members": [ { "type": "REPEAT", "content": { "type": "CHOICE", "members": [ { "type": "SYMBOL", "name": "environment_variable_assignment" }, { "type": "SYMBOL", "name": "file_redirect" } ] } }, { "type": "RENAME", "content": { "type": "SYMBOL", "name": "leading_word" }, "value": "command_name" }, { "type": "CHOICE", "members": [ { "type": "SEQ", "members": [ { "type": "PATTERN", "value": "\\s+" }, { "type": "REPEAT", "content": { "type": "CHOICE", "members": [ { "type": "RENAME", "content": { "type": "SYMBOL", "name": "word" }, "value": "argument" }, { "type": "SYMBOL", "name": "expansion" }, { "type": "SYMBOL", "name": "operator_expansion" } ] } } ] }, { "type": "BLANK" } ] }, { "type": "REPEAT", "content": { "type": "CHOICE", "members": [ { "type": "SYMBOL", "name": "file_redirect" }, { "type": "SYMBOL", "name": "heredoc_redirect" } ] } } ] }, "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" } ] } }, "environment_variable_assignment": { "type": "SEQ", "members": [ { "type": "RENAME", "content": { "type": "SYMBOL", "name": "leading_word" }, "value": "variable_name" }, { "type": "STRING", "value": "=" }, { "type": "RENAME", "content": { "type": "SYMBOL", "name": "word" }, "value": "argument" } ] }, "expansion": { "type": "SEQ", "members": [ { "type": "STRING", "value": "$" }, { "type": "RENAME", "content": { "type": "SYMBOL", "name": "word" }, "value": "variable_name" } ] }, "operator_expansion": { "type": "SEQ", "members": [ { "type": "STRING", "value": "${" }, { "type": "RENAME", "content": { "type": "SYMBOL", "name": "leading_word" }, "value": "variable_name" }, { "type": "CHOICE", "members": [ { "type": "SEQ", "members": [ { "type": "CHOICE", "members": [ { "type": "STRING", "value": ":" }, { "type": "STRING", "value": ":?" }, { "type": "STRING", "value": "=" } ] }, { "type": "RENAME", "content": { "type": "SYMBOL", "name": "word" }, "value": "argument" } ] }, { "type": "BLANK" } ] }, { "type": "STRING", "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": "CHOICE", "members": [ { "type": "SYMBOL", "name": "file_descriptor" }, { "type": "RENAME", "content": { "type": "SYMBOL", "name": "word" }, "value": "file_name" } ] } ] }, "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": "operator_expansion" }, { "type": "SYMBOL", "name": "_heredoc_middle" } ] } }, { "type": "SYMBOL", "name": "_heredoc_end" } ] } ] }, "file_descriptor": { "type": "TOKEN", "content": { "type": "PREC", "value": 1, "content": { "type": "PATTERN", "value": "\\d+" } } }, "leading_word": { "type": "PATTERN", "value": "[^\\\\\\s#=|;:{}]+" }, "word": { "type": "PATTERN", "value": "[^#\\\\\\s$<>{}&;)]+" }, "comment": { "type": "PATTERN", "value": "#.*" }, "terminator": { "type": "CHOICE", "members": [ { "type": "STRING", "value": ";" }, { "type": "STRING", "value": ";;" }, { "type": "STRING", "value": "\n" } ] } }, "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" } ], "inline": [ "statement", "terminator" ] }