package morbig
Module Morbig.CSTSource
The type for concrete syntax trees of POSIX shell scripts. These trees are produced by the Morbig parser.
These type definitions refer directly to the grammar production rules of the POSIX standard. We use the following convention to name data constructors: given a rule A -> P1 ... PN of the grammar, the constructor for this rule starts with the name of the non terminal A and continues with the names of producers Pi appearing in the right-hand-side of the production rule. We do not need types for operators and reserved words.
These concrete syntax trees are actually richer than the production trees defined by the grammar. Indeed, they also embed concrete syntax trees for WORDs while the grammar sees WORDs are mere tokens. For instance, echo `cat bar` is interpreted by the grammar as a simple command with two WORDs echo and `cat bar`. Morbig does not stop its work here: it also parses `cat bar` and the resulting concrete syntax tree is attached to the WORD `cat bar`. See the type definition for word below for more details.
The PPX syntax extension package "visitors", written by François Pottier, is used to macro-generate many traversal functions over this concrete syntax tree. Note that we expose the .ml file of this module because the types generated by visitors are too complex to be displayed.
include sig ... end
include sig ... end
include sig ... end
include sig ... end
include sig ... end
include sig ... end
include sig ... end
val lexing_position_of_yojson :
Yojson.Safe.t ->
lexing_position Ppx_deriving_yojson_runtime.error_orval located_of_yojson :
'a. (Yojson.Safe.t -> 'a Ppx_deriving_yojson_runtime.error_or) ->
Yojson.Safe.t ->
'a located Ppx_deriving_yojson_runtime.error_ortype program = | Program_LineBreak_CompleteCommands_LineBreak of linebreak' * complete_commands' * linebreak'| Program_LineBreak of linebreak'
and complete_commands = | CompleteCommands_CompleteCommands_NewlineList_CompleteCommand of complete_commands' * newline_list' * complete_command'| CompleteCommands_CompleteCommand of complete_command'
and complete_command = | CompleteCommand_CList_SeparatorOp of clist' * separator_op'| CompleteCommand_CList of clist'
and clist = | CList_CList_SeparatorOp_AndOr of clist' * separator_op' * and_or'| CList_AndOr of and_or'
and and_or = | AndOr_Pipeline of pipeline'| AndOr_AndOr_AndIf_LineBreak_Pipeline of and_or' * linebreak' * pipeline'| AndOr_AndOr_OrIf_LineBreak_Pipeline of and_or' * linebreak' * pipeline'
and pipeline = | Pipeline_PipeSequence of pipe_sequence'| Pipeline_Bang_PipeSequence of pipe_sequence'
and pipe_sequence = | PipeSequence_Command of command'| PipeSequence_PipeSequence_Pipe_LineBreak_Command of pipe_sequence' * linebreak' * command'
and command = | Command_SimpleCommand of simple_command'| Command_CompoundCommand of compound_command'| Command_CompoundCommand_RedirectList of compound_command' * redirect_list'| Command_FunctionDefinition of function_definition'
and compound_command = | CompoundCommand_BraceGroup of brace_group'| CompoundCommand_Subshell of subshell'| CompoundCommand_ForClause of for_clause'| CompoundCommand_CaseClause of case_clause'| CompoundCommand_IfClause of if_clause'| CompoundCommand_WhileClause of while_clause'| CompoundCommand_UntilClause of until_clause'
and compound_list = | CompoundList_LineBreak_Term of linebreak' * term'| CompoundList_LineBreak_Term_Separator of linebreak' * term' * separator'
and for_clause = | ForClause_For_Name_DoGroup of name' * do_group'| ForClause_For_Name_SequentialSep_DoGroup of name' * sequential_sep' * do_group'| ForClause_For_Name_LineBreak_In_SequentialSep_DoGroup of name' * linebreak' * sequential_sep' * do_group'| ForClause_For_Name_LineBreak_In_WordList_SequentialSep_DoGroup of name' * linebreak' * wordlist' * sequential_sep' * do_group'
and case_clause = | CaseClause_Case_Word_LineBreak_In_LineBreak_CaseList_Esac of word' * linebreak' * linebreak' * case_list'| CaseClause_Case_Word_LineBreak_In_LineBreak_CaseListNS_Esac of word' * linebreak' * linebreak' * case_list_ns'| CaseClause_Case_Word_LineBreak_In_LineBreak_Esac of word' * linebreak' * linebreak'
and case_list_ns = | CaseListNS_CaseList_CaseItemNS of case_list' * case_item_ns'| CaseListNS_CaseItemNS of case_item_ns'
and case_list = | CaseList_CaseList_CaseItem of case_list' * case_item'| CaseList_CaseItem of case_item'
and case_item_ns = | CaseItemNS_Pattern_Rparen_LineBreak of pattern' * linebreak'| CaseItemNS_Pattern_Rparen_CompoundList of pattern' * compound_list'| CaseItemNS_Lparen_Pattern_Rparen_LineBreak of pattern' * linebreak'| CaseItemNS_Lparen_Pattern_Rparen_CompoundList of pattern' * compound_list'
and case_item = | CaseItem_Pattern_Rparen_LineBreak_Dsemi_LineBreak of pattern' * linebreak' * linebreak'| CaseItem_Pattern_Rparen_CompoundList_Dsemi_LineBreak of pattern' * compound_list' * linebreak'| CaseItem_Lparen_Pattern_Rparen_LineBreak_Dsemi_LineBreak of pattern' * linebreak' * linebreak'| CaseItem_Lparen_Pattern_Rparen_CompoundList_Dsemi_LineBreak of pattern' * compound_list' * linebreak'
and if_clause = | IfClause_If_CompoundList_Then_CompoundList_ElsePart_Fi of compound_list' * compound_list' * else_part'| IfClause_If_CompoundList_Then_CompoundList_Fi of compound_list' * compound_list'
and else_part = | ElsePart_Elif_CompoundList_Then_CompoundList of compound_list' * compound_list'| ElsePart_Elif_CompoundList_Then_CompoundList_ElsePart of compound_list' * compound_list' * else_part'| ElsePart_Else_CompoundList of compound_list'
and function_definition = | FunctionDefinition_Fname_Lparen_Rparen_LineBreak_FunctionBody of fname' * linebreak' * function_body'
and function_body = | FunctionBody_CompoundCommand of compound_command'| FunctionBody_CompoundCommand_RedirectList of compound_command' * redirect_list'
and simple_command = | SimpleCommand_CmdPrefix_CmdWord_CmdSuffix of cmd_prefix' * cmd_word' * cmd_suffix'| SimpleCommand_CmdPrefix_CmdWord of cmd_prefix' * cmd_word'| SimpleCommand_CmdPrefix of cmd_prefix'| SimpleCommand_CmdName_CmdSuffix of cmd_name' * cmd_suffix'| SimpleCommand_CmdName of cmd_name'
and cmd_prefix = | CmdPrefix_IoRedirect of io_redirect'| CmdPrefix_CmdPrefix_IoRedirect of cmd_prefix' * io_redirect'| CmdPrefix_AssignmentWord of assignment_word'| CmdPrefix_CmdPrefix_AssignmentWord of cmd_prefix' * assignment_word'
and cmd_suffix = | CmdSuffix_IoRedirect of io_redirect'| CmdSuffix_CmdSuffix_IoRedirect of cmd_suffix' * io_redirect'| CmdSuffix_Word of word'| CmdSuffix_CmdSuffix_Word of cmd_suffix' * word'
and redirect_list = | RedirectList_IoRedirect of io_redirect'| RedirectList_RedirectList_IoRedirect of redirect_list' * io_redirect'
The two IoHere constructors have two arguments. The second argument is the word holding the contents of the here document, which does not figure in the grammar.
and separator = | Separator_SeparatorOp_LineBreak of separator_op' * linebreak'| Separator_NewLineList of newline_list'
and sequential_sep = | SequentialSep_Semicolon_LineBreak of linebreak'| SequentialSep_NewLineList of newline_list'
and word_component = | WordSubshell of subshell_kind * program located| WordName of string| WordAssignmentWord of assignment_word| WordDoubleQuoted of word| WordSingleQuoted of word| WordLiteral of string| WordVariable of variable| WordGlobAll| WordGlobAny| WordReBracketExpression of bracket_expression| WordEmpty
and bracket_expression = | BracketExpression_LBRACKET_MatchingList_RBRACKET of matching_list| BracketExpression_LBRACKET_NonMatchingList_RBRACKET of nonmatching_list
and bracket_list = | BracketList_FollowList of follow_list| BracketList_FollowList_MINUS of follow_list
and follow_list = | FollowList_ExpressionTerm of expression_term| FollowList_FollowList_ExpressionTerm of follow_list * expression_term
and expression_term = | ExpressionTerm_SingleExpression of single_expression| ExpressionTerm_RangeExpression of range_expression
and single_expression = | SingleExpression_EndRange of end_range| SingleExpression_CharacterClass of character_class| SingleExpression_EquivalenceClass of equivalence_class
and range_expression = | RangeExpression_StartRange_EndRange of start_range * end_range| RangeExpression_StartRange_MINUS of start_range
and end_range = | EndRange_COLLELEMSINGLE of char| EndRangeCollatingSymbol of collating_symbol
and variable_attribute = | NoAttribute| ParameterLength of word| UseDefaultValues of string * word| AssignDefaultValues of string * word| IndicateErrorifNullorUnset of string * word| UseAlternativeValue of string * word| RemoveSmallestSuffixPattern of word| RemoveLargestSuffixPattern of word| RemoveSmallestPrefixPattern of word| RemoveLargestPrefixPattern of word
val complete_commands_of_yojson :
Yojson.Safe.t ->
complete_commands Ppx_deriving_yojson_runtime.error_orval complete_command_of_yojson :
Yojson.Safe.t ->
complete_command Ppx_deriving_yojson_runtime.error_orval pipe_sequence_of_yojson :
Yojson.Safe.t ->
pipe_sequence Ppx_deriving_yojson_runtime.error_orval compound_command_of_yojson :
Yojson.Safe.t ->
compound_command Ppx_deriving_yojson_runtime.error_orval compound_list_of_yojson :
Yojson.Safe.t ->
compound_list Ppx_deriving_yojson_runtime.error_orval case_list_ns_of_yojson :
Yojson.Safe.t ->
case_list_ns Ppx_deriving_yojson_runtime.error_orval case_item_ns_of_yojson :
Yojson.Safe.t ->
case_item_ns Ppx_deriving_yojson_runtime.error_orval while_clause_of_yojson :
Yojson.Safe.t ->
while_clause Ppx_deriving_yojson_runtime.error_orval until_clause_of_yojson :
Yojson.Safe.t ->
until_clause Ppx_deriving_yojson_runtime.error_orval function_definition_of_yojson :
Yojson.Safe.t ->
function_definition Ppx_deriving_yojson_runtime.error_orval function_body_of_yojson :
Yojson.Safe.t ->
function_body Ppx_deriving_yojson_runtime.error_orval simple_command_of_yojson :
Yojson.Safe.t ->
simple_command Ppx_deriving_yojson_runtime.error_orval redirect_list_of_yojson :
Yojson.Safe.t ->
redirect_list Ppx_deriving_yojson_runtime.error_orval newline_list_of_yojson :
Yojson.Safe.t ->
newline_list Ppx_deriving_yojson_runtime.error_orval separator_op_of_yojson :
Yojson.Safe.t ->
separator_op Ppx_deriving_yojson_runtime.error_orval sequential_sep_of_yojson :
Yojson.Safe.t ->
sequential_sep Ppx_deriving_yojson_runtime.error_orval word_component_of_yojson :
Yojson.Safe.t ->
word_component Ppx_deriving_yojson_runtime.error_orval bracket_expression_of_yojson :
Yojson.Safe.t ->
bracket_expression Ppx_deriving_yojson_runtime.error_orval matching_list_of_yojson :
Yojson.Safe.t ->
matching_list Ppx_deriving_yojson_runtime.error_orval nonmatching_list_of_yojson :
Yojson.Safe.t ->
nonmatching_list Ppx_deriving_yojson_runtime.error_orval bracket_list_of_yojson :
Yojson.Safe.t ->
bracket_list Ppx_deriving_yojson_runtime.error_orval expression_term_of_yojson :
Yojson.Safe.t ->
expression_term Ppx_deriving_yojson_runtime.error_orval single_expression_of_yojson :
Yojson.Safe.t ->
single_expression Ppx_deriving_yojson_runtime.error_orval range_expression_of_yojson :
Yojson.Safe.t ->
range_expression Ppx_deriving_yojson_runtime.error_orval collating_symbol_of_yojson :
Yojson.Safe.t ->
collating_symbol Ppx_deriving_yojson_runtime.error_orval equivalence_class_of_yojson :
Yojson.Safe.t ->
equivalence_class Ppx_deriving_yojson_runtime.error_orval character_class_of_yojson :
Yojson.Safe.t ->
character_class Ppx_deriving_yojson_runtime.error_orval character_range_of_yojson :
Yojson.Safe.t ->
character_range Ppx_deriving_yojson_runtime.error_orval variable_attribute_of_yojson :
Yojson.Safe.t ->
variable_attribute Ppx_deriving_yojson_runtime.error_orval subshell_kind_of_yojson :
Yojson.Safe.t ->
subshell_kind Ppx_deriving_yojson_runtime.error_orval assignment_word_of_yojson :
Yojson.Safe.t ->
assignment_word Ppx_deriving_yojson_runtime.error_orval complete_commands'_of_yojson :
Yojson.Safe.t ->
complete_commands' Ppx_deriving_yojson_runtime.error_orval complete_command'_of_yojson :
Yojson.Safe.t ->
complete_command' Ppx_deriving_yojson_runtime.error_orval pipe_sequence'_of_yojson :
Yojson.Safe.t ->
pipe_sequence' Ppx_deriving_yojson_runtime.error_orval compound_command'_of_yojson :
Yojson.Safe.t ->
compound_command' Ppx_deriving_yojson_runtime.error_orval compound_list'_of_yojson :
Yojson.Safe.t ->
compound_list' Ppx_deriving_yojson_runtime.error_orval case_clause'_of_yojson :
Yojson.Safe.t ->
case_clause' Ppx_deriving_yojson_runtime.error_orval case_list_ns'_of_yojson :
Yojson.Safe.t ->
case_list_ns' Ppx_deriving_yojson_runtime.error_orval case_item_ns'_of_yojson :
Yojson.Safe.t ->
case_item_ns' Ppx_deriving_yojson_runtime.error_orval while_clause'_of_yojson :
Yojson.Safe.t ->
while_clause' Ppx_deriving_yojson_runtime.error_orval until_clause'_of_yojson :
Yojson.Safe.t ->
until_clause' Ppx_deriving_yojson_runtime.error_orval function_definition'_of_yojson :
Yojson.Safe.t ->
function_definition' Ppx_deriving_yojson_runtime.error_orval function_body'_of_yojson :
Yojson.Safe.t ->
function_body' Ppx_deriving_yojson_runtime.error_orval brace_group'_of_yojson :
Yojson.Safe.t ->
brace_group' Ppx_deriving_yojson_runtime.error_orval simple_command'_of_yojson :
Yojson.Safe.t ->
simple_command' Ppx_deriving_yojson_runtime.error_orval redirect_list'_of_yojson :
Yojson.Safe.t ->
redirect_list' Ppx_deriving_yojson_runtime.error_orval io_redirect'_of_yojson :
Yojson.Safe.t ->
io_redirect' Ppx_deriving_yojson_runtime.error_orval newline_list'_of_yojson :
Yojson.Safe.t ->
newline_list' Ppx_deriving_yojson_runtime.error_orval separator_op'_of_yojson :
Yojson.Safe.t ->
separator_op' Ppx_deriving_yojson_runtime.error_orval sequential_sep'_of_yojson :
Yojson.Safe.t ->
sequential_sep' Ppx_deriving_yojson_runtime.error_orval assignment_word'_of_yojson :
Yojson.Safe.t ->
assignment_word' Ppx_deriving_yojson_runtime.error_or