'//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ' C O N T R O L S T R U C T U R E S '============================================================================================================================ ' FOR AND ITS BLOCK '---------------------------------------------------------------------------------------------------------------------------- ws for.k for( =for 'transforms state ws into for for .idv .=a =for1 'mandatory print .idd and storing idd in variable a; .idf "\$$token ".=a =for1 'if variable is declared after it is met here, let this event to pass; '---------------------------------------------------------------------------------------------------------------------------- ' "for each" section '---------------------------------------------------------------------------------------------------------------------------- each.k ")" =foreach,we "//!! ""for each"" needs manual correction " foreach,e in.k <foreach2,we foreach2,e .t <for,-s .i { '============================================================================================================================ for1 = "$a =" =for2,we for2,e to.k "; " <too 'part for moo=foo(goo); is completed; set state too expecting 'following event; too . .*b =to,we + 'some event come when in too; set states to we; pass event, 'start to collect input into ..b; to,e step.k .-b <step1 'stop collecting input into ..b; to expression now is in ..b; 'now we need to collect expression after step; .t .-b : "$a <=$b ; $a +=1){" <for,-s 'assume for ... to ... is completed; recurse nest to -s,ws; 'stop collecting ..b; make nice indent; step1 . .*c =step,we + 'somthing came when we were waiting in state step1; 'start to collect it into ..c; pass this event into .d; step,e .t .-c : "$a <=$b ; $a +=$c ){" : <for,-s +"! may check conditions for counter; no way for translator to do this ... ".r for,-s .next <ws .i } .i +.tfull 'completing "for"; restoring nest to "...s, ws" or " ..., ws"; ws .exitfor "break; " < +.tfull '============================================================================================================================ '============================================================================================================================ ' IF AND ITS BLOCKS '---------------------------------------------------------------------------------------------------------------------------- ws if.k if( =if,we if,e then.k ){ <-s,if_fresh,ws '.i '!+ unremming this .i makes "if text" less 'compact, but maybe nicer. if_fresh .tfull =if_b .tempty =if_empty if_empty .r10 .i <if_b,-s,ws 'switch to multiblock, only line feed switches 'to multiblock; .else =if_b +.else 'reduce to one-line case .elseif =if_b +.elseif .: =if_b +.: .endif =if_b +.endif 'added for fun; "if x then end if" is uncommon 'basic if-block-multiline state (A) if_b,-s .else < .i "}else { " >-s,ws 'reopen if block .endif <2 .i } +.tfull .elseif +.else =elseif_flag,ws +if.k 'flag replaces ws; new block if immideately 'inserts into "else-block" .: " " >ws 'if-block-on-one-line state (B) -s,if_b .else <2 .i "}else { " >-s,if_b,ws 'simply reopens if_b block .r10 <if_b,-s +.endif +.r10 'reduces to "m-line close"; 'r10 in post-string causes '"chain reaction for one-line nests" .elseif +.else =elseif_flag,ws +if.k .endif <if_b,-s +.endif .: " " >ws elseif_flag .tfull < +.endif 'causes "chain reaction" until all 'elseif_flags cancelled '---------------------------------------------------------------------------------------------------------------------------- ' ef IF '============================================================================================================================ '============================================================================================================================ ' DO BLOCK '---------------------------------------------------------------------------------------------------------------------------- ws .do "do { " =do,-s,ws .i .dowhile "while ( (" =while,we .dountil "while (!(" =while,we while,e .t " )){" =-s,ws .i do,-s,ws .loop <3 .i } " while(TRUE);" .i +.tfull 'exclude "while(TRUE)" if redundant; .loopwhile <2,loopwhile,we .i } " while( ( " .loopuntil <2,loopwhile,we .i } " while( !( " while,-s,ws .loop <3 .i } .i +.tfull loopwhile,e .t <2 " )); " .i +.tfull '============================================================================================================================ '============================================================================================================================ ' SELECT CASE AND ITS BLOCKS '---------------------------------------------------------------------------------------------------------------------------- ws .selectcase "switch ( " =selectcase,we selectcase,e .t " ) { " <-s,w_case .i 'the only effect of "-s" is longer indent; w_case .case "case " =case,we .caseelse "default: " =case,-s,ws .endselect <2 .i } .i +.tfull .r10 .i case,e .t ": " =-s .i 'no need for -s,ws becase this .t must be 'followed by .r10 from ":" or .r10; , ": " .i "case " =we 'convert ASP-multicase to PHP-multicase; case,-s .case .i "break; " +.w_case + 'PHP requires "break;"; change for other C-syntax; .caseelse .i "break; " +.w_case + .endselect <w_case + .w_case <w_case .i '============================================================================================================================ ' C O N T R O L S T R U C T U R E S E N D '////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////