X-Git-Url: https://www.kengrimes.com/gitweb/?p=henge%2Fapc.git;a=blobdiff_plain;f=src%2Fparser.y;h=d7a02cded9f1c3214412ac47714736f5b1830dd8;hp=07cf5b825ed10c585dc4fcfbbd72bd2b6e9557f9;hb=7dae7dc73dfbabdc895a78738f550f56561da644;hpb=6035780f8e8c7ba47ae517ad6cf7e47515e847fd diff --git a/src/parser.y b/src/parser.y index 07cf5b8..d7a02cd 100644 --- a/src/parser.y +++ b/src/parser.y @@ -33,6 +33,7 @@ #define yyclassld(CS) (ir_classld_from_class(yyclass(CS))) } %define parse.error verbose +%define parse.lac full %define lr.type ielr %define api.pure full %define api.push-pull push @@ -128,6 +129,7 @@ frame_spec: NUM NUM { $$ = (struct frame_spec_t) {SFACE,$1,$2}; } | FACING { $$ = (struct frame_spec_t) {$1,0,0}; } | FACING NUM NUM { $$ = (struct frame_spec_t) {$1,$2,$3}; } +| %empty { $$ = (struct frame_spec_t) {SFACE,0,0}; } ; %% @@ -137,7 +139,12 @@ void yyerror ( yycstate* cs, char const *s ) -{ fprintf(stderr, "%s\n", s); } +{ ir_class* iter; + for (iter = cs->class_stack; iter < cs->csp; iter++) + fprintf(stderr, "%s/", ir_class_name(*iter)); + fprintf(stderr, "\n\t"); + fprintf(stderr, "%s\n", s); +} yycstate* yycstate_new ( void ) @@ -147,24 +154,24 @@ yycstate* yycstate_new { yyerror(class_state, "Memory allocation error."); return NULL; } - class_state->csp = &class_state->class_stack[0]; - yyclass_push(class_state, ir_class_root()); + class_state->csp = class_state->class_stack; + *(class_state->csp) = ir_class_root(); return class_state; } static inline ir_class yyclass_pop ( yycstate* cs ) -{ return *(cs->csp)--; } +{ cs->csp--; + return *(cs->csp + 1); +} static inline ir_class yyclass_push ( yycstate* cs, ir_class class ) -{ *++cs->csp = class; - return class; -} +{ return *++(cs->csp) = class; } void yycstate_delete ( yycstate* class_state )