' F U N C T I O N A N D S U B R O U T I N E S T A T E M E N T A N D B O D Y
main,-s .fun <fun .i "\r\n" .i
.sub <sub .i "\r\n" .i
sub .idf ..=f."" =fun +.fun2 'nothing to return - nothing to recognize
fun .idf ..=f."" ..~f.token +.fun2
.fun2 "function $ ".=header : 'somewhere between this and header
'\n output; cannot find this;
'have to use variable header;
'-------------------------------
'initiating first function round
'- - - - - - - - - - - - - - - -
=round1,fun,header :
..=gloVars.variables :
..=variables.f : '$variables will accomulate local vars. and is unchanged
'during second round;
..=header_pos.pos : 'assumed that pos is pointed to (, :, or line end separator;
'during second round parsing will resume from this position;
.+fb : function body stream
'-------------------------------
>header
'* _c_ extension has been added;
'it can be changed here;
header ( ( >we 'f( f(x, f(x,y, - case I; this syntax:
.t () =body + 'to allow to ignore param. list
'sin(x)(y) must be eliminated;
header,we ) ) <body 'f(); f(s,);
, , 'f(,x);
header,e , , =we 'case I
) ) <body 'f(x);
body .t { =-s,ws .i :
"$global " .i
round1,fun,-s .endfun "global \$$global ".=global."\n".", \$" : 'replace \n with comma and "$";
"$global \n".=global.", \$\n".";" : 'remove trailing comma and "$";
"$global ".=global."global \$\n"."" : 'delete empty list of globals;
..=pos.header_pos <2,fun,header .-fb .i :
"$header "
fun,-s .endfun ..=variables.gloVars ..=gloVars."" ..=global."" :
< +.return .i } .i =main,-s,ws .i
ws .exitfun < +.return +.tfull
- .return "\$$f ;".=x."\$;"."" : 'add $ and ; to non-empty only
"$x ".=x."\n;"."" : 'remove \n and ";";
"return $x ;" .i 'print with ";";