%run_all Relation Any Any;run_all Relation;halt Relation;halt Relation;test Relation;test Relation;run_ws Relation Any Any;run_ws Relation;ws Relation Any Any Any Any;ws2 Relation Any Any Any Any;ws2 Relation;ws Relation;pr Relation Any;pr Relation;push_semicolon Relation Any Any;push_semicolon Relation;after_nl Relation Any Any;after_nl Relation;remove_cur_inds Relation Any Any Any;remove_cur_inds Relation;remove_prev_inds Relation Any Any Any;remove_prev_inds Relation;remove_from_start Relation Any Any Any;remove_from_start Relation;find_last_char Relation Any Any Any;find_last_char Relation;find_last_char2 Relation Any Any Any Any;find_last_char2 Relation;rest Relation Functor Any;rest Relation;iterate Relation Any Any Any Any;iterate Relation;debug Relation Any;debug Relation %Info Functor;Token Functor;Cons Functor;Info Functor;Token Functor;Cons Functor % module % run_all ws2_run_all(_s,_l3,_upvals):-_upvals=[_run_ws,_debug,_debug,_lexer,_debug],(call_cl(_debug,["lexer..."]),get_(_lexer,"run",T46),_T45 = T46,call_cl(_T45,[_s,_l2]),call_cl(_debug,[_l2]),!,writeln_("---"),call_cl(_debug,["whitespace..."]),call_cl(_run_ws,[_l2,_l3])). % halt ws2_halt(_upvals):-_upvals=[],(halt). % test ws2_test(_upvals):-_upvals=[],(_type_next = "EOF"). % run_ws ws2_run_ws(_l1,_l2,_upvals):-_upvals=[_ws],(((_l1 = [fc_Token(_,"whitespace",_)|_tks_tail])->(call(ws2_run_ws(_tks_tail,_l2),_upvals));(call_cl(_ws,[_l1,[],fc_Token("","SOF",_),_l2])))). % ws ws2_ws(_l,_ind,_tk_prev,_l2,_upvals):-_upvals=[_debug,_ws2,_debug],(_l = '[|]'(_h1,_t1),_h1 = fc_Token(_a,_type,_),((_l = '[|]'(fc_Token(_,"EOF",_),[]))->(((_ind = [],_l2 = _l);(dif(_ind,[]),_l2 = [fc_Token(";",";",_)|_l])));((dif(_type,"whitespace"))->(_l2 = [_h1|_t2],call(ws2_ws(_t1,_ind,_h1,_t2),_upvals));(_h1 = fc_Token(_a,_type,_),call_cl(_debug,["ws"]),((_t1 = '[|]'(fc_Token(_,"whitespace",_),_t2),call(ws2_ws(_t1,_ind,_tk_prev,_l2),_upvals));(dif(_t1,'[|]'(fc_Token(_,"whitespace",_),_t2)),(((call_cl(_ws2,[_l,_ind,_tk_prev,_l2])),(true);call_cl(_debug,["skip2"]),call(ws2_ws(_t1,_ind,_h1,_l2),_upvals))))))))). % ws2 ws2_ws2(_l,_ind,_tk_prev,_l2,_upvals):-_upvals=[_ws,_iterate,_push_semicolon,_debug,_debug,_ws,_debug,_ws,_debug,_ws,_iterate,_push_semicolon,_debug,_list,_list,_list,_debug,_iterate,_rest,_debug,_rest,_remove_cur_inds,_debug,_debug,_ws,_ws,_list,_list,_debug,_debug,_remove_prev_inds,_iterate,_push_semicolon,_list,_debug,_after_nl],(_l = '[|]'(_h1,_t1),_h1 = fc_Token(_a,_tk_type,_),call_cl(_after_nl,[_a,_a2]),_l = [_|[fc_Token(_,_type_next,_)|_]],call_cl(_debug,['[|]'(_a2,'[|]'(_ind,'[|]'(_snew,[])))]),(((_type_next = "EOF"),(get_(_list,"size",T34),_T33 = T34,call_cl(_T33,[_ind,_n]),call_cl(_iterate,[_push_semicolon,_n,_t1,_l2]));_neq = clos([_type_next,_iterate,_push_semicolon,_list,_debug,_after_nl],ws2_neq),(((call_cl(_remove_prev_inds,[_a2,_ind,_snew])),(call_cl(_debug,['[|]'("indent",'[|]'(_snew,[]))]),(((_snew = ""),(_ind2 = _ind,_tk_prev = fc_Token(_,_type_prev,_),_neq2 = clos([_type_prev,_debug,_remove_prev_inds,_iterate,_push_semicolon,_list,_debug,_after_nl],ws2_neq2),call_cl(_debug,['[|]'("same",'[|]'(_type_next,'[|]'(_type_prev,[])))]),get_(_list,"forall",T36),_T35 = T36,call_cl(_T35,['[|]'(";",'[|]'("connective",'[|]'("else",'[|]'("elseif",'[|]'("case",'[|]'("cond",[])))))),_neq]),get_(_list,"forall",T38),_T37 = T38,call_cl(_T37,['[|]'(";",'[|]'("{",'[|]'("connective",'[|]'("else",'[|]'("elseif",'[|]'("case",'[|]'("cond",[]))))))),_neq2]),call_cl(_ws,[_t1,_ind2,_h1,_t2]),_l2 = [fc_Token("and","connective",_info)|_t2]);dif(_snew,""),_ind2 = [_snew|_ind],call_cl(_ws,[_t1,_ind2,_h1,_t2]),_l2 = _t2)));call_cl(_debug,["unindent"]),call_cl(_debug,['[|]'("unindent",'[|]'(_ind,'[|]'(_a2,'[|]'(_n,[]))))]),call_cl(_remove_cur_inds,[_ind,_a2,_n]),call_cl(_debug,['[|]'("rem",'[|]'(_rest,'[|]'(_n,'[|]'(_ind,[]))))]),call_cl(_iterate,[_rest,_n,_ind,_ind2]),_tk_prev = fc_Token(_,_type_prev,_),call_cl(_debug,['[|]'("prev",'[|]'(_tk_prev,'[|]'(_n,[])))]),dif(_type_next,";"),dif(_type_next,"connective"),_neqprev = clos([_type_prev,_debug,_iterate,_rest,_debug,_rest,_remove_cur_inds,_debug,_debug,_ws,_ws,_list,_list,_debug,_debug,_remove_prev_inds,_iterate,_push_semicolon,_list,_debug,_after_nl],ws2_neqprev),get_(_list,"forall",T40),_T39 = T40,call_cl(_T39,['[|]'("connective",'[|]'("else",'[|]'("elseif",'[|]'("case",'[|]'("cond",[]))))),_neqprev]),get_(_list,"forall",T42),_T41 = T42,call_cl(_T41,['[|]'(";",'[|]'("connective",[])),_neq]),(((dif(_type_prev,";")),(get_(_list,"forall",T44),_T43 = T44,call_cl(_T43,['[|]'("}",'[|]'("else",'[|]'("elseif",'[|]'("case",'[|]'("cond",[]))))),_neq]),call_cl(_debug,[1]),call_cl(_iterate,[_push_semicolon,_n,[fc_Token("and","connective",_info)|_t2],_l2]),call_cl(_ws,[_t1,_ind2,_h1,_t2]));((_type_prev = "}"),(call_cl(_debug,[2]),_l2 = [fc_Token("and","connective",_info)|_t2],call_cl(_ws,[_t1,_ind2,_h1,_t2]));((_type_prev = ";"),(call_cl(_debug,[2]),_l2 = [fc_Token("and","connective",_info)|_t2],call_cl(_ws,[_t1,_ind2,_h1,_t2]));_n2 = _n-1,call_cl(_debug,["skip3"]),call_cl(_debug,['[|]'(3,'[|]'(_n2,[]))]),call_cl(_iterate,[_push_semicolon,_n2,_t2,_l2]),call_cl(_ws,[_t1,_ind2,_h1,_t2])))))))))). % neqprev ws2_neqprev(_x,_upvals):-_upvals=[_type_prev,_debug,_iterate,_rest,_debug,_rest,_remove_cur_inds,_debug,_debug,_ws,_ws,_list,_list,_debug,_debug,_remove_prev_inds,_iterate,_push_semicolon,_list,_debug,_after_nl],(dif(_type_prev,_x)). % neq2 ws2_neq2(_x,_upvals):-_upvals=[_type_prev,_debug,_remove_prev_inds,_iterate,_push_semicolon,_list,_debug,_after_nl],(dif(_type_prev,_x)). % neq ws2_neq(_x,_upvals):-_upvals=[_type_next,_iterate,_push_semicolon,_list,_debug,_after_nl],(dif(_type_next,_x)). % pr ws2_pr(_l,_upvals):-_upvals=[_io,_io,_io,_io],((((true),(_l = '[|]'(fc_Token(_a,_,_),_l2),get_(_io,"write",T30),_T29 = T30,call_cl(_T29,[_a]),get_(_io,"write",T32),_T31 = T32,call_cl(_T31,[" "]),call(ws2_pr(_l2),_upvals));_l = []))). % push_semicolon ws2_push_semicolon(_l,_l2,_upvals):-_upvals=[],(_l2 = [fc_Token(";",";",_)|_l]). % after_nl ws2_after_nl(_a,_a2,_upvals):-_upvals=[_string,_find_last_char,_string],(get_(_string,"size",T22),_T21 = T22,call_cl(_T21,[_a,_i]),call_cl(_find_last_char,[_a,"\n",_i2]),get_(_string,"slice",T24),_T23 = T24,call_cl(_T23,[_a,_i2+1,_i,_a2])). % remove_cur_inds ws2_remove_cur_inds(_ind,_sgoal,_n,_upvals):-_upvals=[_string,_list,_string,_list],((((true),(get_(_list,"fold",T19),_T18 = T19,get_(_string,"concat",T20),call_cl(_T18,[_ind,T20,"",_s]),str(_s,_s1),_s1 = _sgoal,_n = 0);_ind = [_h|_tail],call(ws2_remove_cur_inds(_tail,_sgoal,_i),_upvals),_n = _i+1))). % remove_prev_inds ws2_remove_prev_inds(_s1,_ind,_s2,_upvals):-_upvals=[_remove_from_start,_list],(get_(_list,"fold",T14),_T13 = T14,call_cl(_T13,[_ind,_remove_from_start,_s1,_s2])). % remove_from_start ws2_remove_from_start(_s1,_s2,_s3,_upvals):-_upvals=[_string,_string,_string,_string],(get_(_string,"find",T6),_T5 = T6,call_cl(_T5,[_s1,_s2,_pos]),!,get_(_string,"size",T8),_T7 = T8,call_cl(_T7,[_s2,_n]),get_(_string,"size",T10),_T9 = T10,call_cl(_T9,[_s1,_n2]),_k = _n+_pos,get_(_string,"slice",T12),_T11 = T12,call_cl(_T11,[_s1,_k,_n2,_s3])). % find_last_char ws2_find_last_char(_s,_c,_pos,_upvals):-_upvals=[_find_last_char2,_string],(dif(_s,""),get_(_string,"size",T4),_T3 = T4,call_cl(_T3,[_s,_n]),call_cl(_find_last_char2,[_s,_c,_n-1,_pos])). % find_last_char2 ws2_find_last_char2(_s,_c,_i,_pos,_upvals):-_upvals=[_string],(dif(_i,-1),(((get_(_string,"at",T2),_T1 = T2,call_cl(_T1,[_s,_i,_c])),(_pos = _i);int(_i-1,X2),call(ws2_find_last_char2(_s,_c,X2,_pos),_upvals)))). % rest ws2_rest(_l,_b,_upvals):-_upvals=[],(_l = [_|_b]). % iterate ws2_iterate(_p,_n,_x,_y,_upvals):-_upvals=[],((((int(_n,X1),X1 = 0),(_y = _x);call_cl(_p,[_x,_x2]),call(ws2_iterate(_p,_n-1,_x2,_y),_upvals)))). % debug ws2_debug(_s,_upvals):-_upvals=[],(true). % main ws2(X):-_debug = clos([],ws2_debug),_iterate = clos([],ws2_iterate),_rest = clos([],ws2_rest),creq("string",_string),creq("list",_list),creq("io",_io),_find_last_char2 = clos([_string],ws2_find_last_char2),_find_last_char = clos([_find_last_char2,_string],ws2_find_last_char),_remove_from_start = clos([_string,_string,_string,_string],ws2_remove_from_start),_remove_prev_inds = clos([_remove_from_start,_list],ws2_remove_prev_inds),_remove_cur_inds = clos([_string,_list,_string,_list],ws2_remove_cur_inds),_after_nl = clos([_string,_find_last_char,_string],ws2_after_nl),_push_semicolon = clos([],ws2_push_semicolon),_pr = clos([_io,_io,_io,_io],ws2_pr),_ws2 = clos([_ws,_iterate,_push_semicolon,_debug,_debug,_ws,_debug,_ws,_debug,_ws,_iterate,_push_semicolon,_debug,_list,_list,_list,_debug,_iterate,_rest,_debug,_rest,_remove_cur_inds,_debug,_debug,_ws,_ws,_list,_list,_debug,_debug,_remove_prev_inds,_iterate,_push_semicolon,_list,_debug,_after_nl],ws2_ws2),_ws = clos([_debug,_ws2,_debug],ws2_ws),_run_ws = clos([_ws],ws2_run_ws),_test = clos([],ws2_test),_halt = clos([],ws2_halt),creq("lexer",_lexer),_run_all = clos([_run_ws,_debug,_debug,_lexer,_debug],ws2_run_all),new(T47),set_(T47,"run",_run_ws,T49),set_(T49,"run2",_run_all,T48),_t = T48,X=_t.