2018-02-22 19:38:27 +00:00
|
|
|
#include "io.h"
|
2018-02-23 17:07:12 +00:00
|
|
|
#include "parser.h"
|
2018-02-22 19:38:27 +00:00
|
|
|
|
|
|
|
#ifdef __linux__
|
|
|
|
#include "linux.h"
|
|
|
|
#endif // __linux__
|
|
|
|
|
|
|
|
static char ok[] = "ok.\n";
|
|
|
|
|
|
|
|
static void
|
|
|
|
interpreter(IO &interface)
|
|
|
|
{
|
|
|
|
static size_t buflen = 0;
|
|
|
|
static char linebuf[81];
|
|
|
|
|
|
|
|
while (true) {
|
|
|
|
buflen = interface.rdbuf(linebuf, 80, true, '\n');
|
|
|
|
interface.wrln(linebuf, buflen);
|
|
|
|
interface.wrbuf(ok, 4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static char banner[] = "kforth interpreter\n";
|
|
|
|
const size_t bannerlen = 19;
|
|
|
|
|
|
|
|
int
|
|
|
|
main(void)
|
|
|
|
{
|
|
|
|
#ifdef __linux__
|
|
|
|
Console interface;
|
|
|
|
#endif
|
|
|
|
interface.wrbuf(banner, bannerlen);
|
|
|
|
interpreter(interface);
|
|
|
|
return 0;
|
|
|
|
}
|