#!/bin/bash # If this file has already been sourced, just return test $(VARIABLES_ARRAYLIST_SH+true)TODO && return declare -g VARIABLES_ARRAYLIST_SH = 'true' source ${BASH_SOURCE%/*}/common.sh source ${BASH_SOURCE%/*}/logger.sh source ${BASH_SOURCE%/*}/variables.sh source ${BASH_SOURCE%/*}/variables.atom.sh variable::type::define ArrayList # == LIST == # # Lists are represented as just a list of tokens to variables # proc variable::ArrayList::new { variable::new ArrayList $(@) } proc variable::ArrayList::append { if [[ ${VARIABLES_DEBUG} == 1 ]] { stderr "variable::ArrayList::append $(@)" ; }TODO declare list_token = $1TODO declare value_token = $2 variable::type::instanceOfOrExit $(list_token) ArrayListTODO declare -a list_value = '('${VARIABLES_VALUES[$list_token]}) global list_value := '('${value_token}) VARIABLES_VALUES[$list_token]=$(list_value[@]) global RESULT := $(#list_value[@]) } proc variable::ArrayList::prepend { if [[ ${VARIABLES_DEBUG} == 1 ]] { stderr "variable::ArrayList::prepend $(@)" ; }TODO declare list_token = $1TODO declare value_token = $2 variable::type::instanceOfOrExit $(list_token) ArrayListTODO declare -a list_value = '('TODO ${VARIABLES_VALUES[$list_token]}) declare -a new_value = '("'${value_token}" "${list_value[@]:+${list_value[@]}}") VARIABLES_VALUES[$list_token]=$(new_value[@]) global RESULT := $(#list_value[@]) } proc variable::ArrayList::length { if [[ ${VARIABLES_DEBUG} == 1 ]] { stderr "variable::ArrayList::length $(@)" ; }TODO declare list_token = $1 variable::type::instanceOfOrExit $(list_token) ArrayList variable::value $(list_token)TODO ; declare -a value = '("'${RESULT}") global RESULT := $(#value[@]) } proc variable::ArrayList::index { if [[ ${VARIABLES_DEBUG} == 1 ]] { stderr "variables_list::index $(@)" ; }TODO declare list_token = $1 variable::type::instanceOfOrExit $(list_token) ArrayListTODO declare index = $2 variable::value $(list_token)TODO ; declare -a value = '('${RESULT}) global RESULT := $(value[$index]) } proc _variable::ArrayList::index_p { variable::ArrayList::index $(@) echo $RESULT } proc variable::ArrayList::first { if [[ ${VARIABLES_DEBUG} == 1 ]] { stderr "variable::ArrayList::first $(@)" ; }TODO declare list_token = $1 variable::type::instanceOfOrExit $(list_token) ArrayList variable::ArrayList::index $(list_token) 0 } proc _variable::ArrayList::first_p { variable::ArrayList::first $(@) echo $(RESULT) } proc variable::ArrayList::rest { if [[ ${VARIABLES_DEBUG} == 1 ]] { stderr "variable::ArrayList::rest $(@)" ; }TODO declare list_token = $1 variable::type::instanceOfOrExit $(list_token) ArrayList variable::value $(list_token)TODO ; declare -a values = '('$RESULT) global RESULT := $(values[@]:1) } proc _variable::ArrayList::rest_p { variable::ArrayList::rest $(@) echo $(RESULT) } # # Returns code 0 if the list is empty, 1 if not # proc variable::ArrayList::isEmpty_c { if [[ ${VARIABLES_DEBUG} == 1 ]] { stderr "variable::ArrayList::isEmpty_c $(@)" ; }TODO declare token = $(1) variable::type::instanceOfOrExit $(token) ArrayList variable::value $(token)TODO ; declare -a value = '('${RESULT}) [[ ${#value[@]} -eq 0 ]] return $? } # ====================================================== if test $0 != $BASH_SOURCE { return } # == LIST TESTS == # create a new list # test its size is 0 # add an atom to list # test its size is 1 # retrieve value of first item (atom) in list variable::ArrayList::new ; global vCode := $(RESULT) variable::new Identifier "+" ; variable::ArrayList::append $(vCode) $(RESULT) variable::new Integer 5 ; variable::ArrayList::append $(vCode) $(RESULT) variable::new Integer 2 ; variable::ArrayList::append $(vCode) $(RESULT) variable::type $vCode ; \ assert::equals ArrayList $RESULT "List type" variable::ArrayList::index $vCode 0 ; variable::type $(RESULT) ; \ assert::equals Identifier $RESULT "List first item type" variable::ArrayList::index $vCode 1 ; variable::type $(RESULT) ; \ assert::equals Integer $(RESULT) "List first item type" variable::ArrayList::index $vCode 2 ; variable::type $(RESULT) ; \ assert::equals Integer $(RESULT) "List first item type" variable::ArrayList::new ; global vCode := $(RESULT) variable::new String "a" ; global A := $(RESULT) ; variable::ArrayList::append $(vCode) $A variable::new String "b" ; global B := $(RESULT) ; variable::ArrayList::append $(vCode) $B variable::new String "c" ; global C := $(RESULT) ; variable::ArrayList::append $(vCode) $C variable::ArrayList::index $vCode 1 ; \ assert::equals $B $RESULT "index_p" variable::ArrayList::first $vCode ; \ assert::equals $A $RESULT "first_p" variable::ArrayList::rest $vCode 0 ; \ assert::equals "$(B) $(C)" $RESULT "rest_p" variable::new -name "EVAL_RESULT" Integer 4TODO ; declare varname = $(RESULT) assert::equals "EVAL_RESULT" $(varname) "Non-auto variable name" variable::type $(varname) ; \ assert::equals Integer $(RESULT) "Non-auto type" variable::value $(varname) ; \ assert::equals 4 $(RESULT) "Non-auto value" variable::ArrayList::new ; global vCode := $(RESULT) variable::ArrayList::isEmpty_c $(vCode) assert::equals 0 $Status "Return code true (0)" variable::new Identifier "+" ; variable::ArrayList::append $(vCode) $(RESULT) variable::ArrayList::isEmpty_c $(vCode) assert::equals 1 $Status "Return code false (1)" # append variable::ArrayList::new ; global vCode := $(RESULT) variable::new Integer 5 ; variable::ArrayList::append $(vCode) $(RESULT) variable::new Integer 2 ; variable::ArrayList::append $(vCode) $(RESULT) variable::ArrayList::index $vCode 0 ; variable::value $(RESULT) ; \ assert::equals 5 $RESULT "append / 0" variable::ArrayList::index $vCode 1 ; variable::value $RESULT ; \ assert::equals 2 $RESULT "append / 1" assert::report if test $(1+isset) && test $1 == "debug" { variable::printMetadata } (CommandList children: [ (AndOr children: [ (C {(Lit_Other "[")} { (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_Plus arg_word:{(true)}) spids: [9 13] ) } {(Lit_Other "]")} ) (ControlFlow token:) ] op_id: Op_DAmp ) (Assignment keyword: Assign_Declare flags: ["'-g'"] pairs: [ (assign_pair lhs: (LhsName name:VARIABLES_ARRAYLIST_SH) op: Equal rhs: {(true)} spids: [25] ) ] spids: [21] ) (C {(.)} { (BracedVarSub token: suffix_op: (StringUnary op_id:VOp1_Percent arg_word:{(Lit_Slash /) ("*")}) spids: [31 36] ) (/common.sh) } ) (C {(.)} { (BracedVarSub token: suffix_op: (StringUnary op_id:VOp1_Percent arg_word:{(Lit_Slash /) ("*")}) spids: [41 46] ) (/logger.sh) } ) (C {(.)} { (BracedVarSub token: suffix_op: (StringUnary op_id:VOp1_Percent arg_word:{(Lit_Slash /) ("*")}) spids: [51 56] ) (/variables.sh) } ) (C {(.)} { (BracedVarSub token: suffix_op: (StringUnary op_id:VOp1_Percent arg_word:{(Lit_Slash /) ("*")}) spids: [61 66] ) (/variables.atom.sh) } ) (C {(variable) (Lit_Other ":") (Lit_Other ":") (type) (Lit_Other ":") (Lit_Other ":") (define)} {(ArrayList)} ) (FuncDef name: "variable::ArrayList::new" body: (BraceGroup children: [ (C {(variable) (Lit_Other ":") (Lit_Other ":") (new)} {(ArrayList)} {(DQ (${ VSub_At "@"))}) ] spids: [106] ) spids: [94 105] ) (FuncDef name: "variable::ArrayList::append" body: (BraceGroup children: [ (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(${ VSub_Name VARIABLES_DEBUG)} right: {(1)} ) ) terminator: ) ] action: [ (Sentence child: (C {(stderr)} {(DQ ("variable::ArrayList::append ") (${ VSub_At "@"))}) terminator: ) ] spids: [-1 155] ) ] spids: [-1 168] ) (Assignment keyword: Assign_Declare pairs: [ (assign_pair lhs: (LhsName name:list_token) op: Equal rhs: {($ VSub_Number "$1")} spids: [173] ) ] spids: [171] ) (Assignment keyword: Assign_Declare pairs: [ (assign_pair lhs: (LhsName name:value_token) op: Equal rhs: {($ VSub_Number "$2")} spids: [179] ) ] spids: [177] ) (C {(variable) (Lit_Other ":") (Lit_Other ":") (type) (Lit_Other ":") (Lit_Other ":") (instanceOfOrExit) } {(DQ (${ VSub_Name list_token))} {(ArrayList)} ) (Assignment keyword: Assign_Declare flags: ["'-a'"] pairs: [ (assign_pair lhs: (LhsName name:list_value) op: Equal rhs: { (ArrayLiteralPart words: [ { (BracedVarSub token: bracket_op: (ArrayIndex expr:(ArithWord w:{($ VSub_Name "$list_token")})) spids: [208 213] ) } ] ) } spids: [206] ) ] spids: [202] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:list_value) op: PlusEqual rhs: {(ArrayLiteralPart words:[{(${ VSub_Name value_token)}])} spids: [217] ) ] spids: [217] ) (C {(VARIABLES_VALUES) (Lit_Other "[") ($ VSub_Name "$list_token") (Lit_Other "]") (Lit_Other "=") (BracedVarSub token: bracket_op:(WholeArray op_id:Lit_At) spids:[230235]) } ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:RESULT) op: Equal rhs: { (BracedVarSub token: prefix_op: VSub_Pound bracket_op: (WholeArray op_id:Lit_At) spids: [240 246] ) } spids: [239] ) ] spids: [239] ) ] spids: [137] ) spids: [125 136] ) (FuncDef name: "variable::ArrayList::prepend" body: (BraceGroup children: [ (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(${ VSub_Name VARIABLES_DEBUG)} right: {(1)} ) ) terminator: ) ] action: [ (Sentence child: (C {(stderr)} {(DQ ("variable::ArrayList::prepend ") (${ VSub_At "@"))}) terminator: ) ] spids: [-1 281] ) ] spids: [-1 294] ) (Assignment keyword: Assign_Declare pairs: [ (assign_pair lhs: (LhsName name:list_token) op: Equal rhs: {($ VSub_Number "$1")} spids: [299] ) ] spids: [297] ) (Assignment keyword: Assign_Declare pairs: [ (assign_pair lhs: (LhsName name:value_token) op: Equal rhs: {($ VSub_Number "$2")} spids: [305] ) ] spids: [303] ) (C {(variable) (Lit_Other ":") (Lit_Other ":") (type) (Lit_Other ":") (Lit_Other ":") (instanceOfOrExit) } {(DQ (${ VSub_Name list_token))} {(ArrayList)} ) (Assignment keyword: Assign_Declare flags: ["'-a'"] pairs: [ (assign_pair lhs: (LhsName name:list_value) op: Equal rhs: { (ArrayLiteralPart words: [ { (BracedVarSub token: bracket_op: (ArrayIndex expr:(ArithWord w:{($ VSub_Name "$list_token")})) spids: [334 339] ) } ] ) } spids: [332] ) ] spids: [328] ) (Assignment keyword: Assign_Declare flags: ["'-a'"] pairs: [ (assign_pair lhs: (LhsName name:new_value) op: Equal rhs: { (ArrayLiteralPart words: [ {(DQ (${ VSub_Name value_token))} { (DQ (BracedVarSub token: bracket_op: (WholeArray op_id:Lit_At) suffix_op: (StringUnary op_id: VTest_ColonPlus arg_word: { (BracedVarSub token: bracket_op: (WholeArray op_id:Lit_At) spids: [362 367] ) } ) spids: [356 368] ) ) } ] ) } spids: [347] ) ] spids: [343] ) (C {(VARIABLES_VALUES) (Lit_Other "[") ($ VSub_Name "$list_token") (Lit_Other "]") (Lit_Other "=") (BracedVarSub token: bracket_op:(WholeArray op_id:Lit_At) spids:[378383]) } ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:RESULT) op: Equal rhs: { (BracedVarSub token: prefix_op: VSub_Pound bracket_op: (WholeArray op_id:Lit_At) spids: [388 394] ) } spids: [387] ) ] spids: [387] ) ] spids: [263] ) spids: [251 262] ) (FuncDef name: "variable::ArrayList::length" body: (BraceGroup children: [ (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(${ VSub_Name VARIABLES_DEBUG)} right: {(1)} ) ) terminator: ) ] action: [ (Sentence child: (C {(stderr)} {(DQ ("variable::ArrayList::length ") (${ VSub_At "@"))}) terminator: ) ] spids: [-1 429] ) ] spids: [-1 442] ) (Assignment keyword: Assign_Declare pairs: [ (assign_pair lhs: (LhsName name:list_token) op: Equal rhs: {($ VSub_Number "$1")} spids: [447] ) ] spids: [445] ) (C {(variable) (Lit_Other ":") (Lit_Other ":") (type) (Lit_Other ":") (Lit_Other ":") (instanceOfOrExit) } {(DQ (${ VSub_Name list_token))} {(ArrayList)} ) (Sentence child: (C {(variable) (Lit_Other ":") (Lit_Other ":") (value)} {(DQ (${ VSub_Name list_token))}) terminator: ) (Assignment keyword: Assign_Declare flags: ["'-a'"] pairs: [ (assign_pair lhs: (LhsName name:value) op: Equal rhs: {(ArrayLiteralPart words:[{(DQ (${ VSub_Name RESULT))}])} spids: [487] ) ] spids: [483] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:RESULT) op: Equal rhs: { (DQ (BracedVarSub token: prefix_op: VSub_Pound bracket_op: (WholeArray op_id:Lit_At) spids: [499 505] ) ) } spids: [497] ) ] spids: [497] ) ] spids: [411] ) spids: [399 410] ) (FuncDef name: "variable::ArrayList::index" body: (BraceGroup children: [ (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(${ VSub_Name VARIABLES_DEBUG)} right: {(1)} ) ) terminator: ) ] action: [ (Sentence child: (C {(stderr)} {(DQ ("variables_list::index ") (${ VSub_At "@"))}) terminator: ) ] spids: [-1 541] ) ] spids: [-1 554] ) (Assignment keyword: Assign_Declare pairs: [ (assign_pair lhs: (LhsName name:list_token) op: Equal rhs: {($ VSub_Number "$1")} spids: [559] ) ] spids: [557] ) (C {(variable) (Lit_Other ":") (Lit_Other ":") (type) (Lit_Other ":") (Lit_Other ":") (instanceOfOrExit) } {(DQ (${ VSub_Name list_token))} {(ArrayList)} ) (Assignment keyword: Assign_Declare pairs: [ (assign_pair lhs: (LhsName name:index) op: Equal rhs: {($ VSub_Number "$2")} spids: [584] ) ] spids: [582] ) (Sentence child: (C {(variable) (Lit_Other ":") (Lit_Other ":") (value)} {(DQ (${ VSub_Name list_token))}) terminator: ) (Assignment keyword: Assign_Declare flags: ["'-a'"] pairs: [ (assign_pair lhs: (LhsName name:value) op: Equal rhs: {(ArrayLiteralPart words:[{(${ VSub_Name RESULT)}])} spids: [605] ) ] spids: [601] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:RESULT) op: Equal rhs: { (BracedVarSub token: bracket_op: (ArrayIndex expr:(ArithWord w:{($ VSub_Name "$index")})) spids: [614 619] ) } spids: [613] ) ] spids: [613] ) ] spids: [523] ) spids: [511 522] ) (FuncDef name: "_variable::ArrayList::index_p" body: (BraceGroup children: [ (C {(variable) (Lit_Other ":") (Lit_Other ":") (ArrayList) (Lit_Other ":") (Lit_Other ":") (index) } {(DQ (${ VSub_At "@"))} ) (C {(echo)} {(DQ ($ VSub_Name "$RESULT"))}) ] spids: [636] ) spids: [624 635] ) (FuncDef name: "variable::ArrayList::first" body: (BraceGroup children: [ (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(${ VSub_Name VARIABLES_DEBUG)} right: {(1)} ) ) terminator: ) ] action: [ (Sentence child: (C {(stderr)} {(DQ ("variable::ArrayList::first ") (${ VSub_At "@"))}) terminator: ) ] spids: [-1 693] ) ] spids: [-1 706] ) (Assignment keyword: Assign_Declare pairs: [ (assign_pair lhs: (LhsName name:list_token) op: Equal rhs: {($ VSub_Number "$1")} spids: [711] ) ] spids: [709] ) (C {(variable) (Lit_Other ":") (Lit_Other ":") (type) (Lit_Other ":") (Lit_Other ":") (instanceOfOrExit) } {(DQ (${ VSub_Name list_token))} {(ArrayList)} ) (C {(variable) (Lit_Other ":") (Lit_Other ":") (ArrayList) (Lit_Other ":") (Lit_Other ":") (index) } {(${ VSub_Name list_token)} {(0)} ) ] spids: [675] ) spids: [663 674] ) (FuncDef name: "_variable::ArrayList::first_p" body: (BraceGroup children: [ (C {(variable) (Lit_Other ":") (Lit_Other ":") (ArrayList) (Lit_Other ":") (Lit_Other ":") (first) } {(DQ (${ VSub_At "@"))} ) (C {(echo)} {(DQ (${ VSub_Name RESULT))}) ] spids: [763] ) spids: [751 762] ) (FuncDef name: "variable::ArrayList::rest" body: (BraceGroup children: [ (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(${ VSub_Name VARIABLES_DEBUG)} right: {(1)} ) ) terminator: ) ] action: [ (Sentence child: (C {(stderr)} {(DQ ("variable::ArrayList::rest ") (${ VSub_At "@"))}) terminator: ) ] spids: [-1 822] ) ] spids: [-1 835] ) (Assignment keyword: Assign_Declare pairs: [ (assign_pair lhs: (LhsName name:list_token) op: Equal rhs: {($ VSub_Number "$1")} spids: [840] ) ] spids: [838] ) (C {(variable) (Lit_Other ":") (Lit_Other ":") (type) (Lit_Other ":") (Lit_Other ":") (instanceOfOrExit) } {(DQ (${ VSub_Name list_token))} {(ArrayList)} ) (Sentence child: (C {(variable) (Lit_Other ":") (Lit_Other ":") (value)} {(DQ (${ VSub_Name list_token))}) terminator: ) (Assignment keyword: Assign_Declare flags: ["'-a'"] pairs: [ (assign_pair lhs: (LhsName name:values) op: Equal rhs: {(ArrayLiteralPart words:[{($ VSub_Name "$RESULT")}])} spids: [880] ) ] spids: [876] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:RESULT) op: Equal rhs: { (DQ (BracedVarSub token: bracket_op: (WholeArray op_id:Lit_At) suffix_op: (Slice begin:(ArithWord w:{(Lit_Digits 1)})) spids: [888 895] ) ) } spids: [886] ) ] spids: [886] ) ] spids: [804] ) spids: [792 803] ) (FuncDef name: "_variable::ArrayList::rest_p" body: (BraceGroup children: [ (C {(variable) (Lit_Other ":") (Lit_Other ":") (ArrayList) (Lit_Other ":") (Lit_Other ":") (rest) } {(DQ (${ VSub_At "@"))} ) (C {(echo)} {(DQ (${ VSub_Name RESULT))}) ] spids: [913] ) spids: [901 912] ) (FuncDef name: "variable::ArrayList::isEmpty_c" body: (BraceGroup children: [ (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(${ VSub_Name VARIABLES_DEBUG)} right: {(1)} ) ) terminator: ) ] action: [ (Sentence child: (C {(stderr)} {(DQ ("variable::ArrayList::isEmpty_c ") (${ VSub_At "@"))}) terminator: ) ] spids: [-1 981] ) ] spids: [-1 994] ) (Assignment keyword: Assign_Declare pairs: [ (assign_pair lhs: (LhsName name:token) op: Equal rhs: {(DQ (${ VSub_Number 1))} spids: [999] ) ] spids: [997] ) (C {(variable) (Lit_Other ":") (Lit_Other ":") (type) (Lit_Other ":") (Lit_Other ":") (instanceOfOrExit) } {(DQ (${ VSub_Name token))} {(ArrayList)} ) (Sentence child: (C {(variable) (Lit_Other ":") (Lit_Other ":") (value)} {(DQ (${ VSub_Name token))}) terminator: ) (Assignment keyword: Assign_Declare flags: ["'-a'"] pairs: [ (assign_pair lhs: (LhsName name:value) op: Equal rhs: {(ArrayLiteralPart words:[{(${ VSub_Name RESULT)}])} spids: [1043] ) ] spids: [1039] ) (DBracket expr: (BoolBinary op_id: BoolBinary_eq left: { (BracedVarSub token: prefix_op: VSub_Pound bracket_op: (WholeArray op_id:Lit_At) spids: [1053 1059] ) } right: {(0)} ) ) (ControlFlow token: arg_word:{($ VSub_QMark "$?")}) ] spids: [963] ) spids: [951 962] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {($ VSub_Number "$0")} {(KW_Bang "!") (Lit_Other "=")} {($ VSub_Name "$BASH_SOURCE")} {(Lit_Other "]")} ) terminator: ) ] action: [(ControlFlow token:)] spids: [-1 1093] ) ] spids: [-1 1098] ) (Sentence child: (C {(variable) (Lit_Other ":") (Lit_Other ":") (ArrayList) (Lit_Other ":") (Lit_Other ":") (new)} ) terminator: ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:vCode) op: Equal rhs: {(${ VSub_Name RESULT)} spids: [1130] ) ] spids: [1130] ) (Sentence child: (C {(variable) (Lit_Other ":") (Lit_Other ":") (new)} {(Identifier)} {(DQ ("+"))}) terminator: ) (C {(variable) (Lit_Other ":") (Lit_Other ":") (ArrayList) (Lit_Other ":") (Lit_Other ":") (append)} {(${ VSub_Name vCode)} {(${ VSub_Name RESULT)} ) (Sentence child: (C {(variable) (Lit_Other ":") (Lit_Other ":") (new)} {(Integer)} {(5)}) terminator: ) (C {(variable) (Lit_Other ":") (Lit_Other ":") (ArrayList) (Lit_Other ":") (Lit_Other ":") (append)} {(${ VSub_Name vCode)} {(${ VSub_Name RESULT)} ) (Sentence child: (C {(variable) (Lit_Other ":") (Lit_Other ":") (new)} {(Integer)} {(2)}) terminator: ) (C {(variable) (Lit_Other ":") (Lit_Other ":") (ArrayList) (Lit_Other ":") (Lit_Other ":") (append)} {(${ VSub_Name vCode)} {(${ VSub_Name RESULT)} ) (Sentence child: (C {(variable) (Lit_Other ":") (Lit_Other ":") (type)} {($ VSub_Name "$vCode")}) terminator: ) (C {(assert) (Lit_Other ":") (Lit_Other ":") (equals)} {(ArrayList)} {(DQ ($ VSub_Name "$RESULT"))} {(DQ ("List type"))} ) (Sentence child: (C {(variable) (Lit_Other ":") (Lit_Other ":") (ArrayList) (Lit_Other ":") (Lit_Other ":") (index)} {($ VSub_Name "$vCode")} {(0)} ) terminator: ) (Sentence child: (C {(variable) (Lit_Other ":") (Lit_Other ":") (type)} {(DQ (${ VSub_Name RESULT))}) terminator: ) (C {(assert) (Lit_Other ":") (Lit_Other ":") (equals)} {(Identifier)} {(DQ ($ VSub_Name "$RESULT"))} {(DQ ("List first item type"))} ) (Sentence child: (C {(variable) (Lit_Other ":") (Lit_Other ":") (ArrayList) (Lit_Other ":") (Lit_Other ":") (index)} {($ VSub_Name "$vCode")} {(1)} ) terminator: ) (Sentence child: (C {(variable) (Lit_Other ":") (Lit_Other ":") (type)} {(DQ (${ VSub_Name RESULT))}) terminator: ) (C {(assert) (Lit_Other ":") (Lit_Other ":") (equals)} {(Integer)} {(DQ (${ VSub_Name RESULT))} {(DQ ("List first item type"))} ) (Sentence child: (C {(variable) (Lit_Other ":") (Lit_Other ":") (ArrayList) (Lit_Other ":") (Lit_Other ":") (index)} {($ VSub_Name "$vCode")} {(2)} ) terminator: ) (Sentence child: (C {(variable) (Lit_Other ":") (Lit_Other ":") (type)} {(DQ (${ VSub_Name RESULT))}) terminator: ) (C {(assert) (Lit_Other ":") (Lit_Other ":") (equals)} {(Integer)} {(DQ (${ VSub_Name RESULT))} {(DQ ("List first item type"))} ) (Sentence child: (C {(variable) (Lit_Other ":") (Lit_Other ":") (ArrayList) (Lit_Other ":") (Lit_Other ":") (new)} ) terminator: ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:vCode) op: Equal rhs: {(${ VSub_Name RESULT)} spids: [1392] ) ] spids: [1392] ) (Sentence child: (C {(variable) (Lit_Other ":") (Lit_Other ":") (new)} {(String)} {(DQ (a))}) terminator: ) (Sentence child: (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:A) op: Equal rhs: {(${ VSub_Name RESULT)} spids: [1410] ) ] spids: [1410] ) terminator: ) (C {(variable) (Lit_Other ":") (Lit_Other ":") (ArrayList) (Lit_Other ":") (Lit_Other ":") (append)} {(${ VSub_Name vCode)} {($ VSub_Name "$A")} ) (Sentence child: (C {(variable) (Lit_Other ":") (Lit_Other ":") (new)} {(String)} {(DQ (b))}) terminator: ) (Sentence child: (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:B) op: Equal rhs: {(${ VSub_Name RESULT)} spids: [1444] ) ] spids: [1444] ) terminator: ) (C {(variable) (Lit_Other ":") (Lit_Other ":") (ArrayList) (Lit_Other ":") (Lit_Other ":") (append)} {(${ VSub_Name vCode)} {($ VSub_Name "$B")} ) (Sentence child: (C {(variable) (Lit_Other ":") (Lit_Other ":") (new)} {(String)} {(DQ (c))}) terminator: ) (Sentence child: (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:C) op: Equal rhs: {(${ VSub_Name RESULT)} spids: [1478] ) ] spids: [1478] ) terminator: ) (C {(variable) (Lit_Other ":") (Lit_Other ":") (ArrayList) (Lit_Other ":") (Lit_Other ":") (append)} {(${ VSub_Name vCode)} {($ VSub_Name "$C")} ) (Sentence child: (C {(variable) (Lit_Other ":") (Lit_Other ":") (ArrayList) (Lit_Other ":") (Lit_Other ":") (index)} {($ VSub_Name "$vCode")} {(1)} ) terminator: ) (C {(assert) (Lit_Other ":") (Lit_Other ":") (equals)} {(DQ ($ VSub_Name "$B"))} {(DQ ($ VSub_Name "$RESULT"))} {(DQ (index_p))} ) (Sentence child: (C {(variable) (Lit_Other ":") (Lit_Other ":") (ArrayList) (Lit_Other ":") (Lit_Other ":") (first)} {($ VSub_Name "$vCode")} ) terminator: ) (C {(assert) (Lit_Other ":") (Lit_Other ":") (equals)} {(DQ ($ VSub_Name "$A"))} {(DQ ($ VSub_Name "$RESULT"))} {(DQ (first_p))} ) (Sentence child: (C {(variable) (Lit_Other ":") (Lit_Other ":") (ArrayList) (Lit_Other ":") (Lit_Other ":") (rest)} {($ VSub_Name "$vCode")} {(0)} ) terminator: ) (C {(assert) (Lit_Other ":") (Lit_Other ":") (equals)} {(DQ (${ VSub_Name B) (" ") (${ VSub_Name C))} {(DQ ($ VSub_Name "$RESULT"))} {(DQ (rest_p))} ) (Sentence child: (C {(variable) (Lit_Other ":") (Lit_Other ":") (new)} {(-name)} {(DQ (EVAL_RESULT))} {(Integer)} {(4)} ) terminator: ) (Assignment keyword: Assign_Declare pairs: [ (assign_pair lhs: (LhsName name:varname) op: Equal rhs: {(DQ (${ VSub_Name RESULT))} spids: [1623] ) ] spids: [1621] ) (C {(assert) (Lit_Other ":") (Lit_Other ":") (equals)} {(DQ (EVAL_RESULT))} {(DQ (${ VSub_Name varname))} {(DQ ("Non-auto variable name"))} ) (Sentence child: (C {(variable) (Lit_Other ":") (Lit_Other ":") (type)} {(DQ (${ VSub_Name varname))}) terminator: ) (C {(assert) (Lit_Other ":") (Lit_Other ":") (equals)} {(Integer)} {(DQ (${ VSub_Name RESULT))} {(DQ ("Non-auto type"))} ) (Sentence child: (C {(variable) (Lit_Other ":") (Lit_Other ":") (value)} {(DQ (${ VSub_Name varname))}) terminator: ) (C {(assert) (Lit_Other ":") (Lit_Other ":") (equals)} {(4)} {(DQ (${ VSub_Name RESULT))} {(DQ ("Non-auto value"))} ) (Sentence child: (C {(variable) (Lit_Other ":") (Lit_Other ":") (ArrayList) (Lit_Other ":") (Lit_Other ":") (new)} ) terminator: ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:vCode) op: Equal rhs: {(${ VSub_Name RESULT)} spids: [1725] ) ] spids: [1725] ) (C {(variable) (Lit_Other ":") (Lit_Other ":") (ArrayList) (Lit_Other ":") (Lit_Other ":") (isEmpty_c)} {(${ VSub_Name vCode)} ) (C {(assert) (Lit_Other ":") (Lit_Other ":") (equals)} {(0)} {($ VSub_QMark "$?")} {(DQ ("Return code true (0)"))} ) (Sentence child: (C {(variable) (Lit_Other ":") (Lit_Other ":") (new)} {(Identifier)} {(DQ ("+"))}) terminator: ) (C {(variable) (Lit_Other ":") (Lit_Other ":") (ArrayList) (Lit_Other ":") (Lit_Other ":") (append)} {(${ VSub_Name vCode)} {(${ VSub_Name RESULT)} ) (C {(variable) (Lit_Other ":") (Lit_Other ":") (ArrayList) (Lit_Other ":") (Lit_Other ":") (isEmpty_c)} {(${ VSub_Name vCode)} ) (C {(assert) (Lit_Other ":") (Lit_Other ":") (equals)} {(1)} {($ VSub_QMark "$?")} {(DQ ("Return code false (1)"))} ) (Sentence child: (C {(variable) (Lit_Other ":") (Lit_Other ":") (ArrayList) (Lit_Other ":") (Lit_Other ":") (new)} ) terminator: ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:vCode) op: Equal rhs: {(${ VSub_Name RESULT)} spids: [1823] ) ] spids: [1823] ) (Sentence child: (C {(variable) (Lit_Other ":") (Lit_Other ":") (new)} {(Integer)} {(5)}) terminator: ) (C {(variable) (Lit_Other ":") (Lit_Other ":") (ArrayList) (Lit_Other ":") (Lit_Other ":") (append)} {(${ VSub_Name vCode)} {(${ VSub_Name RESULT)} ) (Sentence child: (C {(variable) (Lit_Other ":") (Lit_Other ":") (new)} {(Integer)} {(2)}) terminator: ) (C {(variable) (Lit_Other ":") (Lit_Other ":") (ArrayList) (Lit_Other ":") (Lit_Other ":") (append)} {(${ VSub_Name vCode)} {(${ VSub_Name RESULT)} ) (Sentence child: (C {(variable) (Lit_Other ":") (Lit_Other ":") (ArrayList) (Lit_Other ":") (Lit_Other ":") (index)} {($ VSub_Name "$vCode")} {(0)} ) terminator: ) (Sentence child: (C {(variable) (Lit_Other ":") (Lit_Other ":") (value)} {(DQ (${ VSub_Name RESULT))}) terminator: ) (C {(assert) (Lit_Other ":") (Lit_Other ":") (equals)} {(5)} {(DQ ($ VSub_Name "$RESULT"))} {(DQ ("append / 0"))} ) (Sentence child: (C {(variable) (Lit_Other ":") (Lit_Other ":") (ArrayList) (Lit_Other ":") (Lit_Other ":") (index)} {($ VSub_Name "$vCode")} {(1)} ) terminator: ) (Sentence child: (C {(variable) (Lit_Other ":") (Lit_Other ":") (value)} {(DQ ($ VSub_Name "$RESULT"))}) terminator: ) (C {(assert) (Lit_Other ":") (Lit_Other ":") (equals)} {(2)} {(DQ ($ VSub_Name "$RESULT"))} {(DQ ("append / 1"))} ) (C {(assert) (Lit_Other ":") (Lit_Other ":") (report)}) (If arms: [ (if_arm cond: [ (Sentence child: (AndOr children: [ (C {(Lit_Other "[")} { (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_Plus arg_word:{(isset)}) spids: [1979 1983] ) } {(Lit_Other "]")} ) (C {(Lit_Other "[")} {(DQ ($ VSub_Number "$1"))} {(Lit_Other "=") (Lit_Other "=")} {(DQ (debug))} {(Lit_Other "]")} ) ] op_id: Op_DAmp ) terminator: ) ] action: [(C {(variable) (Lit_Other ":") (Lit_Other ":") (printMetadata)})] spids: [-1 2005] ) ] spids: [-1 2014] ) ] )