diff --git a/.gitignore b/.gitignore index 0ac9ad8..ec152bb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ build +tests +specs js diff --git a/jsdump.c b/jsdump.c index c6ef6ad..abfa4c5 100644 --- a/jsdump.c +++ b/jsdump.c @@ -441,7 +441,7 @@ static void pstm(int d, js_Ast *stm) case STM_WITH: ps("with ("); pexp(d, stm->a); ps(")\n"); - pblock(d, stm->b); + pstm(d, stm->b); break; case STM_SWITCH: diff --git a/jsload.c b/jsload.c index d5153f9..3752f45 100644 --- a/jsload.c +++ b/jsload.c @@ -6,7 +6,7 @@ static int jsP_loadstring(js_State *J, const char *filename, const char *source) js_Ast *prog = jsP_parse(J, filename, source); if (prog) { jsP_optimize(J, prog); - jsP_dumpsyntax(J, prog); +// jsP_dumpsyntax(J, prog); jsP_dumplist(J, prog); jsP_freeparse(J); return 0; diff --git a/jsparse.c b/jsparse.c index 935f706..afc6569 100644 --- a/jsparse.c +++ b/jsparse.c @@ -170,26 +170,26 @@ static js_Ast *propassign(js_State *J) { js_Ast *name, *value, *arg, *body; - if (J->lookahead == TK_IDENTIFIER && !strcmp(J->text, "get")) { - next(J); - name = propname(J); - expect(J, '('); - expect(J, ')'); - body = funcbody(J); - return EXP2(PROP_GET, name, body); - } - - if (J->lookahead == TK_IDENTIFIER && !strcmp(J->text, "set")) { - next(J); - name = propname(J); - expect(J, '('); - arg = identifier(J); - expect(J, ')'); - body = funcbody(J); - return EXP3(PROP_SET, name, arg, body); - } - name = propname(J); + + if (J->lookahead != ':' && name->type == AST_IDENTIFIER) { + if (!strcmp(name->string, "get")) { + name = propname(J); + expect(J, '('); + expect(J, ')'); + body = funcbody(J); + return EXP2(PROP_GET, name, body); + } + if (!strcmp(name->string, "set")) { + name = propname(J); + expect(J, '('); + arg = identifier(J); + expect(J, ')'); + body = funcbody(J); + return EXP3(PROP_SET, name, arg, body); + } + } + expect(J, ':'); value = assignment(J, 0); return EXP2(PROP_VAL, name, value); @@ -574,9 +574,10 @@ static js_Ast *forstatement(js_State *J) return NULL; } - if (J->lookahead != ';') { + if (J->lookahead != ';') a = expression(J, 1); - } + else + a = NULL; if (accept(J, ';')) { b = forexpression(J, ';'); c = forexpression(J, ')');