Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 7563 → Rev 7562

/programs/cmm/lisp/lisp.c
6,11 → 6,8
 
#include "../lib/io.h"
#include "../lib/obj/console.h"
#include "../lib/array.h"
 
byte initConsole = 0;
Dictionary functions = {0};
Dictionary variables = {0};
 
#include "stdcall.h"
 
66,9 → 63,9
}
if (!args)
{
if(s!=' ') && (s!=')') // name function
if(s>='A') && (s<='z') // name function
{
while (s!=' ') && (s!=')')
while (s>='A') && (s<='z')
{
DSBYTE[pos] = s;
code++;
104,7 → 101,7
code++;
args++;
}
args--;
args -= 2;
ret = StdCall(args, name, dataArgs);
free(name);
free(dataArgs);
111,18 → 108,16
return ret;
}
 
 
void main()
{
dword brainFuckCode = 0;
word maxLoop = 1000;
dword txt = "(print (str 1) (str 2))";
buffer = malloc(bufferSize);
memory = malloc(memoryBrainfuck);
stack = malloc(stackBrainFuck);
Init();
IF(DSBYTE[I_Param])
{
IF(io.read(I_Param))
130,7 → 125,6
code = EAX;
loop()
{
while(DSBYTE[code] == ' ') code++;
if(DSBYTE[code]!='(') break;
else code++;
evalLisp();
139,19 → 133,17
}
}
}
else
ELSE
{
consoleInit();
con_printf stdcall ("Lisp interpreter v1.2");
con_printf stdcall ("Lisp interpreter v1.0");
WHILE(maxLoop)
{
con_printf stdcall ("\r\n\r\nEnter code: ");
con_gets stdcall(buffer, bufferSize);
code = EAX;
code = txt;
con_printf stdcall ("Output: ");
nextLispLine:
while(DSBYTE[code] == ' ') code++;
if(DSBYTE[code]!='(') continue;
else code++;
evalLisp();
/programs/cmm/lisp/stdcall.h
1,76 → 1,24
:dword std_print(dword count, args)
dword StdCall(dword count, name, args)
{
dword tmp = 0;
if(!strcmp(name, "print"))
{
consoleInit();
WHILE(count)
{
con_printf stdcall (DSDWORD[args]);
args+=4;
count--;
}
else if(!strcmp(name, "input"))
{
}
 
:dword std_str(dword count, args)
else if(!strcmp(name, "str"))
{
dword tmp = 0;
tmp = malloc(15);
itoa_(tmp,DSDWORD[args]);
RETURN tmp;
return tmp;
}
 
:dword std_add(dword count, args)
else if(!strcmp(name, "exit"))
{
dword ret = 0;
WHILE(count)
{
ret += DSDWORD[args];
args+=4;
count--;
ExitProcess();
}
RETURN ret;
}
 
:dword std_sub(dword count, args)
{
dword ret = 0;
IF(count)
{
ret = DSDWORD[args];
count--;
args+=4;
}
WHILE(count)
{
ret -= DSDWORD[args];
args+=4;
count--;
}
RETURN ret;
}
 
void Init()
{
functions.init(100);
/* Console functions */
functions.set("print", #std_print);
/* String functions */
functions.set("str", #std_str);
/* System functions */
functions.set("exit", #ExitProcess);
/* Math functions */
functions.set("+", #std_add);
functions.set("-", #std_sub);
variables.init(100);
}
 
dword StdCall(dword count, name, args)
{
dword tmp = 0;
functions.get(name);
IF(EAX)RETURN EAX(count, args);
RETURN 0;
return 0;
}