MIRROR: javascript for ๐Ÿœ's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

parser fixes

+19 -10
+1 -1
meson.build
··· 74 74 build_date = run_command('date', '+%Y-%m-%d', check: true).stdout().strip() 75 75 76 76 version_conf = configuration_data() 77 - version_conf.set('ANT_VERSION', '0.0.8.14') 77 + version_conf.set('ANT_VERSION', '0.0.8.15') 78 78 version_conf.set('ANT_GIT_HASH', git_hash) 79 79 version_conf.set('ANT_BUILD_DATE', build_date) 80 80
+18 -9
src/ant.c
··· 2391 2391 jsval_t res = js_mkundef(); 2392 2392 if (create_scope) mkscope(js); 2393 2393 js->consumed = 1; 2394 - while (next(js) != TOK_EOF && next(js) != TOK_RBRACE && !is_err(res)) { 2394 + uint8_t peek; 2395 + while ((peek = next(js)) != TOK_EOF && peek != TOK_RBRACE && !is_err(res)) { 2395 2396 uint8_t t = js->tok; 2396 2397 res = js_stmt(js); 2397 2398 if (!is_err(res) && t != TOK_LBRACE && t != TOK_IF && t != TOK_WHILE && 2398 2399 t != TOK_DO && t != TOK_FUNC && t != TOK_FOR && t != TOK_IMPORT && 2399 - t != TOK_EXPORT && js->tok != TOK_SEMICOLON) { 2400 + t != TOK_EXPORT && t != TOK_SEMICOLON && 2401 + js->tok != TOK_SEMICOLON && js->tok != TOK_RBRACE && js->tok != TOK_EOF) { 2400 2402 res = js_mkerr(js, "; expected"); 2401 2403 break; 2402 2404 } 2403 2405 if (js->flags & (F_RETURN | F_THROW)) break; 2404 2406 } 2407 + if (js->tok == TOK_RBRACE) js->consumed = 1; 2405 2408 if (create_scope) delscope(js); 2406 2409 return res; 2407 2410 } ··· 5181 5184 } 5182 5185 } 5183 5186 5184 - if (next(js) == TOK_SEMICOLON || next(js) == TOK_EOF) break; 5187 + uint8_t decl_next = next(js); 5188 + if (decl_next == TOK_SEMICOLON || decl_next == TOK_EOF || decl_next == TOK_RBRACE) break; 5185 5189 EXPECT(TOK_COMMA, ); 5186 5190 } 5187 5191 return js_mkundef(); ··· 6126 6130 if (exe && !(js->flags & F_CALL)) return js_mkerr(js, "not in func"); 6127 6131 jsval_t res = js_mkundef(); 6128 6132 6129 - if (next(js) != TOK_SEMICOLON) { 6133 + uint8_t nxt = next(js); 6134 + if (nxt != TOK_SEMICOLON && nxt != TOK_RBRACE && nxt != TOK_EOF) { 6130 6135 res = resolveprop(js, js_expr(js)); 6131 6136 } 6132 6137 ··· 6424 6429 MethodInfo methods[32]; 6425 6430 int method_count = 0; 6426 6431 6427 - while (next(js) != TOK_RBRACE && next(js) != TOK_EOF && method_count < 32) { 6432 + uint8_t class_tok; 6433 + while ((class_tok = next(js)) != TOK_RBRACE && class_tok != TOK_EOF && method_count < 32) { 6428 6434 bool is_async_method = false; 6429 6435 bool is_static_member = false; 6430 6436 ··· 6562 6568 6563 6569 EXPECT(TOK_RBRACE, js->flags = save_flags); 6564 6570 js->flags = save_flags; 6565 - js->consumed = 0; 6566 6571 6567 6572 if (exe) { 6568 6573 jsval_t super_constructor = js_mkundef(); ··· 6867 6872 } 6868 6873 } 6869 6874 6870 - if (next(js) == TOK_SEMICOLON || next(js) == TOK_EOF) break; 6875 + uint8_t var_next = next(js); 6876 + if (var_next == TOK_SEMICOLON || var_next == TOK_EOF || var_next == TOK_RBRACE) break; 6871 6877 EXPECT(TOK_COMMA, ); 6872 6878 } 6873 6879 return js_mkundef(); ··· 6897 6903 uint8_t stmt_tok = next(js); 6898 6904 6899 6905 switch (stmt_tok) { 6906 + case TOK_SEMICOLON: 6907 + res = js_mkundef(); 6908 + break; 6900 6909 case TOK_CASE: case TOK_CATCH: 6901 6910 case TOK_DEFAULT: case TOK_FINALLY: 6902 6911 res = js_mkerr(js, "SyntaxError '%.*s'", (int) js->tlen, js->code + js->toff); ··· 6939 6948 stmt_tok == TOK_IF || stmt_tok == TOK_WHILE || 6940 6949 stmt_tok == TOK_DO || stmt_tok == TOK_FOR || 6941 6950 stmt_tok == TOK_SWITCH || stmt_tok == TOK_TRY || 6942 - stmt_tok == TOK_LBRACE 6951 + stmt_tok == TOK_LBRACE || stmt_tok == TOK_ASYNC 6943 6952 ); 6944 6953 6945 6954 if (!is_block_statement) { 6946 6955 int next_tok = next(js); 6947 6956 bool missing_semicolon = next_tok != TOK_SEMICOLON && next_tok != TOK_EOF && next_tok != TOK_RBRACE; 6948 6957 if (missing_semicolon) return js_mkerr(js, "; expected"); 6958 + if (next_tok == TOK_SEMICOLON) js->consumed = 1; 6949 6959 } 6950 6960 6951 - js->consumed = 1; 6952 6961 return res; 6953 6962 } 6954 6963