Random changes with varying usefulness #9
@@ -30,7 +30,9 @@
|
|||||||
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡘⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡘⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
||||||
|
|
||||||
typedef struct noomC_LocalInfo {
|
typedef struct noomC_LocalInfo {
|
||||||
enum { NOOMC_GLOBAL, NOOMC_LOCAL, NOOMC_UPVAL } type;
|
enum { NOOMC_GLOBAL,
|
||||||
|
NOOMC_LOCAL,
|
||||||
|
NOOMC_UPVAL } type;
|
||||||
unsigned int idx;
|
unsigned int idx;
|
||||||
} noomC_LocalInfo;
|
} noomC_LocalInfo;
|
||||||
|
|
||||||
@@ -165,8 +167,7 @@ static noom_Exit noomC_compile_expr(
|
|||||||
noomV_Function* func,
|
noomV_Function* func,
|
||||||
const noomP_Node* node,
|
const noomP_Node* node,
|
||||||
// retc of -1 means all values!!!!!!!!!!!
|
// retc of -1 means all values!!!!!!!!!!!
|
||||||
int retc
|
int retc) {
|
||||||
) {
|
|
||||||
noom_Exit result;
|
noom_Exit result;
|
||||||
if (node->type == NOOMP_NODE_NILLITERAL) {
|
if (node->type == NOOMP_NODE_NILLITERAL) {
|
||||||
compiler->curstack++;
|
compiler->curstack++;
|
||||||
|
|||||||
@@ -82,8 +82,7 @@ noom_uint_t noom_format_error(const noomP_Parser* parser, const char* program_na
|
|||||||
if (parser->code[i] == '\n') {
|
if (parser->code[i] == '\n') {
|
||||||
row++;
|
row++;
|
||||||
column = 1;
|
column = 1;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
column++;
|
column++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -127,8 +126,7 @@ noom_uint_t noom_format_error(const noomP_Parser* parser, const char* program_na
|
|||||||
|
|
||||||
if (row == 0) {
|
if (row == 0) {
|
||||||
num_buf[num_len++] = '0';
|
num_buf[num_len++] = '0';
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
noom_uint_t temp = row;
|
noom_uint_t temp = row;
|
||||||
noom_uint_t divisor = 1;
|
noom_uint_t divisor = 1;
|
||||||
while (temp / divisor >= 10) divisor *= 10;
|
while (temp / divisor >= 10) divisor *= 10;
|
||||||
|
|||||||
@@ -47,8 +47,7 @@ double noom_strtod(const char* s, const char** endptr, int* error) {
|
|||||||
|
|
||||||
num *= noom_pow(2.0, exponent_negative ? -exponent : exponent);
|
num *= noom_pow(2.0, exponent_negative ? -exponent : exponent);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
noom_bool_t are_we_cooked = 1;
|
noom_bool_t are_we_cooked = 1;
|
||||||
while (noomL_isnumber(*s)) {
|
while (noomL_isnumber(*s)) {
|
||||||
num = num * 10.0 + (*s - '0');
|
num = num * 10.0 + (*s - '0');
|
||||||
|
|||||||
23
src/main.c
23
src/main.c
@@ -84,8 +84,7 @@ int execute(const char* code, noom_LuaVersion version, const char* program_name,
|
|||||||
puts("\x1b[0m");
|
puts("\x1b[0m");
|
||||||
puts("PARSE OUTPUT:");
|
puts("PARSE OUTPUT:");
|
||||||
print_node(program, 0);
|
print_node(program, 0);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
noom_uint_t bleh = noom_format_error(&parser, program_name, NULL, 0);
|
noom_uint_t bleh = noom_format_error(&parser, program_name, NULL, 0);
|
||||||
char* buf = noom_alloc(bleh);
|
char* buf = noom_alloc(bleh);
|
||||||
noom_format_error(&parser, program_name, buf, bleh);
|
noom_format_error(&parser, program_name, buf, bleh);
|
||||||
@@ -269,8 +268,7 @@ int main(int argc, char** argv) {
|
|||||||
const char* version_string = 0;
|
const char* version_string = 0;
|
||||||
if (argv[i][2] != '\0') {
|
if (argv[i][2] != '\0') {
|
||||||
version_string = argv[i] + 2;
|
version_string = argv[i] + 2;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (++i >= argc) {
|
if (++i >= argc) {
|
||||||
err = "-l needs an argument";
|
err = "-l needs an argument";
|
||||||
goto die;
|
goto die;
|
||||||
@@ -314,7 +312,8 @@ int main(int argc, char** argv) {
|
|||||||
char* code = read_file(params.script_path);
|
char* code = read_file(params.script_path);
|
||||||
if (code == 0) return 1;
|
if (code == 0) return 1;
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
if (code[0] == '#' && code[1] == '!') for (offset = 2; code[offset] && code[offset] != '\n'; offset++);
|
if (code[0] == '#' && code[1] == '!')
|
||||||
|
for (offset = 2; code[offset] && code[offset] != '\n'; offset++);
|
||||||
const int e = execute(code + offset, params.lua_version, argv[0], params.script_path);
|
const int e = execute(code + offset, params.lua_version, argv[0], params.script_path);
|
||||||
noom_free(code);
|
noom_free(code);
|
||||||
return e;
|
return e;
|
||||||
@@ -336,12 +335,12 @@ int main(int argc, char** argv) {
|
|||||||
}
|
}
|
||||||
die:
|
die:
|
||||||
fprintf(stderr, "%s: %s\n"
|
fprintf(stderr, "%s: %s\n"
|
||||||
"usage: %s [options] [script [args]]\n"
|
"usage: %s [options] [script [args]]\n"
|
||||||
"Available options are:\n"
|
"Available options are:\n"
|
||||||
" - execute stdin\n"
|
" - execute stdin\n"
|
||||||
" -e stat execute string 'stat'\n"
|
" -e stat execute string 'stat'\n"
|
||||||
" -v show version\n"
|
" -v show version\n"
|
||||||
" -l [51|52|53|54] select lua version\n",
|
" -l [51|52|53|54] select lua version\n",
|
||||||
argv[0], err, argv[0]);
|
argv[0], err, argv[0]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user