gokernel
(usa Linux Mint)
Enviado em 17/02/2013 - 06:55h
Pronto a primeira Release Stable esta disponivel:
http://code.google.com/p/microasm/downloads/list
WORDS:
function, if, include, info, int, pvoid
Exemplos na pasta ( script ).
Varios bugs foram revistos ...
E para nao complicar tanto fiz o "interpreter" basicamente assim:
[code]
//-------------------------------------------------------------------
//
// THANKS TO:
// 01 - The only GOD, creator of heaven and earth, in the name of JESUS CHRIST.
//
// CS: Compiled Script
//
// This use the library MA (Micro Assembler) by gokernel.
//
// WORDS:
// function, if, include, info, int, pvoid
//
// START DATE: 16/02/2013 - 16:30
//
// BY: gokernel - gokernel@hotmail.com
//-------------------------------------------------------------------
#include "cs.h"
int main (int argc, char *argv[])
{
char string [1024];
cs_Init ();
cs_LibInit (); // init the standard library
//---------------------------------------------------------------
//
// Add a C native Function
//
//---------------------------------------------------------------
// cs_FuncAdd ( "func_name", 0, "", (void*)Cfunction, NATIVEC );
if (argc >= 2) {
FILE *fp;
if ((fp = fopen (argv[1], "rb")) != NULL) {
char str [10000];
int i = 0, c;
while ((c=getc(fp))!=EOF) str [i++] = c;
fclose (fp);
// if not erro then execute the compiled function
//
if ( !cs_Parse (Glang, str) )
{
((void(*)()) Glang->func->code )();
}
} else printf ("File Not Found: '%s'\n", argv[1]);
return 0;
}
printf (
"_____________________________________________________________________\n\n"
" Glory and honor to the only God, creator of heaven and earth\n"
" in the name of JESUS CHRIST !\n\n"
" For list the functions type: 'func();'\n"
" For 'quit' type: q, quit\n\n"
" WORDS: function, for, if, include, info, int, pvoid\n"
"_____________________________________________________________________\n"
);
// interative mode
for (;;)
{
printf ("cs > ");
gets (string);
if (strlen(string) >= 1)
{
if ( (!strcmp(string, "q")) || (!strcmp(string, "quit")) )
break;
// if not erro then execute the compiled function
//
if ( !cs_Parse (Glang, string) )
{
((void(*)()) Glang->func->code )();
}
}
}
printf ("Exiting With Sucess !!!\n");
return 0;
}
[code]