On Mar-11, Leopold Toetsch wrote: > Jens Rieks <[EMAIL PROTECTED]> wrote: > > > attached is a patch to t/pmc/object-meths.t that adds a test that is > > currently failing because IMCC rejects code like self."blah"() > > Yep. It produces reduce/reduce conflicts. Something's wrong with > precedence. I'd be glad if someone can fix it.
The attached patch should remove all of the conflicts, and replace them with a single shift/reduce conflict that appears to be a bug in the actual grammar, namely: x = x . x can be parsed as x = x . x VAR '=' VAR '.' VAR target '=' var '.' var assignment or x = x . x VAR '=' VAR '.' VAR target '=' target ptr target target '=' the_sub target '=' sub_call assignment Personally, I'd probably also rename 'target' to 'lhs', and 'var' (and its variants) to 'rhs'. But maybe that's just me. Oh, and 'lhs' is available because this patch eliminates it. I didn't try the test mentioned, though.
Index: imcc/imcc.y =================================================================== RCS file: /cvs/public/parrot/imcc/imcc.y,v retrieving revision 1.125 diff -u -r1.125 imcc.y --- imcc/imcc.y 11 Mar 2004 16:37:56 -0000 1.125 +++ imcc/imcc.y 12 Mar 2004 08:33:49 -0000 @@ -272,7 +272,7 @@ %type <sr> key keylist _keylist %type <sr> vars _vars var_or_i _var_or_i label_op %type <i> pasmcode pasmline pasm_inst -%type <sr> pasm_args lhs +%type <sr> pasm_args %type <symlist> targetlist arglist %token <sr> VAR %token <t> LINECOMMENT @@ -784,7 +784,7 @@ { $$ = MK_I(interp, cur_unit, "bxor", 3, $1, $3, $5); } | target '=' var '[' keylist ']' { $$ = iINDEXFETCH(interp, cur_unit, $1, $3, $5); } - | var '[' keylist ']' '=' var + | target '[' keylist ']' '=' var { $$ = iINDEXSET(interp, cur_unit, $1, $3, $6); } | target '=' NEW classname COMMA var { $$ = iNEW(interp, cur_unit, $1, $4, $6, 1); } @@ -850,9 +850,9 @@ if ($1->set != 'P') fataly(1, sourcefile, line, "Sub isn't a PMC"); } - | lhs ptr IDENTIFIER { cur_obj = $1; $$ = mk_sub_address($3); } - | lhs ptr STRINGC { cur_obj = $1; $$ = mk_const($3, 'S'); } - | lhs ptr target { cur_obj = $1; $$ = $3; } + | target ptr IDENTIFIER { cur_obj = $1; $$ = mk_sub_address($3); } + | target ptr STRINGC { cur_obj = $1; $$ = mk_const($3, 'S'); } + | target ptr target { cur_obj = $1; $$ = $3; } ; ptr: POINTY { $$=0; } @@ -916,11 +916,6 @@ | reg ; -lhs: - VAR /* duplicated because of reduce conflict */ - | reg - ; - vars: /* empty */ { $$ = NULL; } | _vars { $$ = $1; } @@ -933,7 +928,7 @@ _var_or_i: var_or_i { regs[nargs++] = $1; } - | lhs '[' keylist ']' + | target '[' keylist ']' { regs[nargs++] = $1; keyvec |= KEY_BIT(nargs); @@ -952,8 +947,7 @@ ; var: - VAR - | reg + target | const ;