SparrowOSTS_121127.ISO
This commit is contained in:
1 parent
0e9364ff4c
commit
e57428affb
1218 files changed
+247142
-165507
No files matched your search
@@ -0,0 +1,37 @@
|
||||
F64 glbl;
|
||||
|
||||
F64 CompileDemo(U8 *st)
|
||||
{
|
||||
I64 type;
|
||||
U8 *code;
|
||||
CLex *lx=LexNew(st,LF_DONT_FREE_BUF);
|
||||
F64 result=0;
|
||||
Lex(lx); //Gotta get it started
|
||||
"Compile \"%s\"\n",st;
|
||||
do {
|
||||
if (code=CmpExpression(lx,&type)) {
|
||||
if (type!=IT_F64)
|
||||
result=ToF64(Call(code));
|
||||
else
|
||||
result=Call(code)(F64);
|
||||
ExpressionDel(code);
|
||||
}
|
||||
"result=%9.4f\n",result;
|
||||
if (lx->token==';')
|
||||
Lex(lx);
|
||||
} while (lx->token!=TK_EOF); //end of file?
|
||||
LexDel(lx);
|
||||
return result;
|
||||
}
|
||||
|
||||
CompileDemo("2+Cos(ã)");
|
||||
CompileDemo("1;2+4");
|
||||
CompileDemo("glbl=1;glbl*2;glbl/3;Sin(glbl)");
|
||||
|
||||
//This is just like you typed-it on
|
||||
//the cmd line.
|
||||
ExePutS(
|
||||
"I64 i;"
|
||||
"for (i=0;i<10;i++) "
|
||||
" \"%d\n\",i;"
|
||||
);
|
||||
Reference in new issue
Block a user