blob: 6c7801c6022497fc607631ee0c6a064f166cf4dd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#!/usr/bin/env node
"use strict";
const lua = require('../../src/lua.js');
const lapi = require('../../src/lapi.js');
const lauxlib = require('../../src/lauxlib.js');
const linit = require('../../src/linit.js');
const fs = require('fs');
const readlineSync = require('readline-sync');
readlineSync.setDefaultOptions({
prompt: '> '
});
const L = lauxlib.luaL_newstate();
linit.luaL_openlibs(L);
console.log(lua.FENGARI_COPYRIGHT);
for (;;) {
let input = readlineSync.prompt();
if (input.length === 0)
continue;
let buffer = lua.to_luastring(input);
if (lauxlib.luaL_loadbuffer(L, buffer, buffer.length, lua.to_luastring("=stdin"))
|| lapi.lua_pcall(L, 0, 0, 0)) {
lauxlib.lua_writestringerror(`${lapi.lua_tojsstring(L, -1)}\n`);
}
lapi.lua_settop(L, 0); /* remove eventual returns */
}
|