From 5194a9082e60f47549aeecbec23d62a99200c998 Mon Sep 17 00:00:00 2001 From: cozis Date: Sat, 21 May 2022 22:52:24 +0200 Subject: [PATCH] minor formatting changes --- examples/bug.noja | 6 ++++++ examples/json.noja | 3 +-- examples/return2.noja | 19 +++++++++++++++++-- src/builtins/basic.c | 9 ++++----- src/compiler/compile.c | 4 +++- src/compiler/parse.c | 15 ++++++++++++--- 6 files changed, 43 insertions(+), 13 deletions(-) create mode 100644 examples/bug.noja diff --git a/examples/bug.noja b/examples/bug.noja new file mode 100644 index 0000000..b08d68d --- /dev/null +++ b/examples/bug.noja @@ -0,0 +1,6 @@ +a = []; +i = 0; +while(i<100000000):{ + a[i]= "ciao mondo mmododooddododododododododododdodododododd"; + i = i+1; +} \ No newline at end of file diff --git a/examples/json.noja b/examples/json.noja index 1846e9c..9793bf7 100644 --- a/examples/json.noja +++ b/examples/json.noja @@ -241,7 +241,6 @@ fun parseAny(ctx) { return res, err; } - tests = [ '', '1', @@ -269,7 +268,7 @@ while i < count(tests): { i = i + 1; } -#file = files.openFile('examples/large-file.json', #files.READ); +#file = files.openFile('examples/large-file.json', files.READ); #if file == none: # error("Failed to open file"); # diff --git a/examples/return2.noja b/examples/return2.noja index 47fc57f..1c85e07 100644 --- a/examples/return2.noja +++ b/examples/return2.noja @@ -6,7 +6,8 @@ fun duplica_forse(a) { } fun duplica_forse2(a) { - return all duplica_forse(a); + res, err = duplica_forse(a); + return res, err; } num = 5; @@ -15,4 +16,18 @@ num2, err = duplica_forse2(num); if num2 == none: print('ERRORE!!! ', err, '\n'); else - print(num2, '\n'); \ No newline at end of file + print(num2, '\n'); + +a, a, a, +a, a, a, +a, a, a, +a, a, a, +a, a, a, +a, a, a, +a, a, a, +a, a, a, +a, a, a, +a, a, a, +a, a, a, +a, a, a, +a, a, a = print(); \ No newline at end of file diff --git a/src/builtins/basic.c b/src/builtins/basic.c index 3434f29..a6b23ff 100644 --- a/src/builtins/basic.c +++ b/src/builtins/basic.c @@ -61,7 +61,6 @@ static int bin_type(Runtime *runtime, Object **argv, unsigned int argc, Object * return 1; } - static int bin_unicode(Runtime *runtime, Object **argv, unsigned int argc, Object **rets, unsigned int maxretc, Error *error) { (void) runtime; @@ -111,10 +110,10 @@ static int bin_chr(Runtime *runtime, Object **argv, unsigned int argc, Object ** if(!Object_IsInt(argv[0])) - { - Error_Report(error, 0, "Argument #%d is not an integer", 1); - return -1; - } + { + Error_Report(error, 0, "Argument #%d is not an integer", 1); + return -1; + } char buff[32]; diff --git a/src/compiler/compile.c b/src/compiler/compile.c index 83f2d80..7b11c18 100644 --- a/src/compiler/compile.c +++ b/src/compiler/compile.c @@ -77,7 +77,9 @@ static Opcode exprkind_to_opcode(ExprKind kind) } } -static _Bool emit_instr_for_funccall(ExeBuilder *exeb, CallExprNode *expr, Promise *break_dest, int returns, Error *error) +static _Bool +emit_instr_for_funccall(ExeBuilder *exeb, CallExprNode *expr, + Promise *break_dest, int returns, Error *error) { Node *arg = expr->argv; diff --git a/src/compiler/parse.c b/src/compiler/parse.c index ef5f67b..25538ec 100644 --- a/src/compiler/parse.c +++ b/src/compiler/parse.c @@ -968,13 +968,19 @@ static Node *parse_map_primary_expression(Context *ctx) if(done(ctx)) { - Error_Report(ctx->error, 0, "Source ended where a map key-value separator ':' was expected"); + Error_Report(ctx->error, 0, + "Source ended where a map key-value " + "separator ':' was expected"); return NULL; } if(current(ctx) != ':') { - Error_Report(ctx->error, 0, "Got token \"%.*s\" where a map key-value separator ':' was expected", ctx->token->length, ctx->src + ctx->token->offset); + Error_Report(ctx->error, 0, + "Got token \"%.*s\" where a map key-value " + "separator ':' was expected", + ctx->token->length, + ctx->src + ctx->token->offset); return NULL; } @@ -1012,7 +1018,10 @@ static Node *parse_map_primary_expression(Context *ctx) if(current(ctx) == TDONE) Error_Report(ctx->error, 0, "Source ended inside a map literal"); else - Error_Report(ctx->error, 0, "Got unexpected token \"%.*s\" inside map literal, where ',' or '}' were expected", ctx->token->length, ctx->src + ctx->token->offset); + Error_Report(ctx->error, 0, + "Got unexpected token \"%.*s\" inside " + "map literal, where ',' or '}' were expected", + ctx->token->length, ctx->src + ctx->token->offset); return NULL; }