cirilisp/cirilisp.c

66 lines
1.8 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include "internals.h"
#include "read.h"
#include "eval.h"
#include "print.h"
extern int eofStatus;
int load(char *pathname)
{
FILE *stream;
if ((stream = fopen(pathname, "r")) == NULL)
{
return 0;
}
while (TYPE(eval(read("", stream), globalEnv)) != EOFObject)
;
eofStatus = 0;
fclose(stream);
return 1;
}
void init()
{
if (setlocale(LC_ALL, "sr_RS.utf8") == NULL)
{
fprintf(stderr, "lokal programa se nije mogao podesiti na\
\"sr_RS.utf8\", proverite da li ste ga osposobili na vasem sistemu\n");
exit(0);
}
/* Омогућава библиотекама коришћеним у интерпретеру да протумаче српску
* ћирилицу */
globalEnv = createEnvironment(NULL);
addSymbolInternal("+", &addInt, 0);
addSymbolInternal("-", &subtractInt, 0);
addSymbolInternal("*", &multiplyInt, 0);
addSymbolInternal("/", &divideInt, 0);
addSymbolInternal("навод", &quoteInt, 1);
addSymbolInternal("дефиниши", &defineInt, 1);
addSymbolInternal("тачно->нетачно", &exactToInexactInt, 0);
addSymbolInternal("нетачно->тачно", &inexactToExactInt, 0);
addSymbolInternal("ламбда", &lambdaInt, 1);
addSymbolInternal("<", &lessInt, 0);
addSymbolInternal(">", &greaterInt, 0);
addSymbolInternal("ако", &ifInt, 1);
if (!load("/usr/local/lib/cirilisp/инит.ћ"))
{
fprintf(stderr, "Није пронађена стандардна ЋИРЛИСП библиотека\
\nПрограм се није могао правилно покренути\n");
exit(0);
}
}
int main(int argc, char **argv)
{
init();
while (print(eval(read("ШКЉ> ", stdin), globalEnv)));
printf("\nДостигнут крај улазног тока.\nЗбогом и дођите нам опет!\n");
return 0;
}