Skip Menu |

This queue is for tickets about the Parse-Eyapp CPAN distribution.

Report information
The Basics
Id: 56640
Status: resolved
Priority: 0/
Queue: Parse-Eyapp

People
Owner: Nobody in particular
Requestors: PSCUST [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.158
Fixed in: (no value)



Subject: YYExpect() dies when parser is generated with -v option
In one particular program, YYExpect() dies when the parser is generated with the -v option, but works OK when the parser is generated without that option. The error seams related to the empty rule 'sos' below: if the rule is removed, the exception does not occur. I have stripped down the program to the minimum: -------- START bug_YYExpect.eyp -------- %{ my $stmt; %} %% prg: stmt * ; sos: { $stmt++ } ; stmt: '\n' | sos 'nop' '\n' ; %% my @input = ("nop", "\n", "org", "\n"); sub my_lexer { my $t = shift(@input); ($t, $t); } sub my_error { my($self) = @_; my $t = $self->YYCurval || "eof"; my @expected = $self->YYExpect(); die("Statement $stmt: Syntax error at $t. Expected @expected.\n"); } sub test_main { bug_YYExpect->new->YYParse( yylex => \&my_lexer, yyerror => \&my_error ); } -------- END bug_YYExpect.eyp -------- When the parser is generated whith -v, and called as below: Show quoted text
> eyapp -v bug_YYExpect.eyp > perl -Mbug_YYExpect -e "bug_YYExpect->test_main"
the result is: Modification of non-creatable array value attempted, subscript -1 at C:/Perl/site/lib/Parse/Eyapp/Driver.pm line 1015 When the parser is generated whithout -v, and called as below: Show quoted text
> eyapp bug_YYExpect.eyp > perl -Mbug_YYExpect -e "bug_YYExpect->test_main"
the result is as expected: Statement 2: Syntax error at org. Expected nop. The state description for State 1 is different when generated with and without -v (in the generated .pm file): -------- bug_YYExpect.pm generated without -v -------- ... {#State 1 ACTIONS => { '' => -3, "\n" => 5 }, DEFAULT => -4, GOTOS => { 'stmt' => 3, 'sos' => 4 } }, ... -------- bug_YYExpect.pm generated with -v -------- ... {#State 1 ACTIONS => { '' => -3, "nop" => -4, "\n" => 5 }, GOTOS => { 'stmt' => 3, 'sos' => 4 } }, ... -------- I do not know if this is the cause of the problem, but when tracing into Parse::Eyapp::Driver.pm, function YYSymbolicSim(), there are two strange things: line 1012: "if (@STACK > length)" --> shouldn't it be $length? line 1013: splice @STACK, -$length;" --> when $length is 0, the whole @STACK is emptied; is this intended? I've tried to replace line 1012 by "if ($length < 0 && @STACK > $length)", and YYExpect() no longer dies, but returns a list with ("\n"), which is not expected; it should return ("nop"). I hope this lengthy description helps pin-point the bug. For now I will stop using -v, unless there is a conflict in the grammar. Best regards, Paulo P.S.: Show quoted text
> perl -v
This is perl, v5.10.1 built for MSWin32-x86-multi-thread (with 2 registered patches, see perl -V for more detail) Copyright 1987-2009, Larry Wall Binary build 1006 [291086] provided by ActiveState http://www.ActiveState.com Built Aug 24 2009 13:48:26
Subject: Re: [rt.cpan.org #56640] YYExpect() dies when parser is generated with -v option
Date: Sat, 17 Apr 2010 10:07:17 +0100
To: bug-Parse-Eyapp [...] rt.cpan.org
From: Casiano Rodriguez-Leon <casiano [...] ull.es>
Many, Many Thanks Paulo for pointing the bug and for your help. I have uploaded version 1.159 of Parse::Eyapp that, hopefully, fixes the bug. Show quoted text
> In one particular program, YYExpect() dies when the parser is generated > with the -v option, but works OK when the parser is generated without > that option.
The bug was related with an undocumented feature of Parse::Eyapp: The fact that the LALR action tables aren't compacted when using '-v'. Here is a slightly modified version of your example (you can find it in the distribution): ~/LEyapp$ cat -n t/minusvoption/paulocustodio.eyp 1 %{ 2 my $stmt; 3 %} 4 %% 5 prg: stmt * 6 ; 7 8 sos: 9 /* empty */ { $stmt++ } 10 ; 11 12 stmt: 13 '\n' 14 | sos 'nop' '\n' 15 ; 16 17 %% 18 19 my @input = ("nop", "\n", "org", "\n"); 20 sub my_lexer { 21 my $t = shift(@input); 22 ($t, $t); 23 } 24 25 sub my_error { 26 my($self) = @_; 27 my $t = $self->YYCurval || "eof"; 28 my @expected = map { $_ eq "\n"? q{'\\n'} : qq{'$_'} } $self->YYExpect(); 29 local $" = ', '; 30 die("Statement $stmt: Syntax error at $t. Expected (@expected).\n"); 31 } 32 33 sub main { 34 __PACKAGE__->new->YYParse( yylex => \&my_lexer, yyerror => \&my_error); 35 } 36 37 main(); When I compile it with '-v' this is the new behavior: ~/LEyapp$ eyapp -v -b '' t/minusvoption/paulocustodio.eyp ~/LEyapp$ t/minusvoption/paulocustodio.pm Statement 1: Syntax error at org. Expected ('nop', '\n'). ~/LEyapp$ If I supress the '-v' option we have: ~/LEyapp$ eyapp -b '' t/minusvoption/paulocustodio.eyp ~/LEyapp$ t/minusvoption/paulocustodio.pm Statement 2: Syntax error at org. Expected ('nop'). Which is less accurate than the former '-v' expected set (notice the absence of '\n' in this output). This is due to the compaction of the LALR table. The error is caught later after the automata has moved to a new state. Show quoted text
> > The state description for State 1 is different when generated with and > without -v (in the generated .pm file):
The State 1 with -v is a more detailed description of the same state. The memory optimization stage projects several common actions onto the 'DEFAULT' action. This is the difference. I have checked the behavior with your example on several Unixes. Let me know if this fix is satisfactory for you Many thanks for your help Best wishes Casiano
Subject: Re: [rt.cpan.org #56640] YYExpect() dies when parser is generated with -v option
Date: Sun, 18 Apr 2010 20:37:25 +0100
To: bug-Parse-Eyapp [...] rt.cpan.org
From: Paulo Custodio <pauloscustodio [...] gmail.com>
Thank you for the quick response. This solves the problem. Keep up with the excelent module. Best regards, Paulo On Sat, Apr 17, 2010 at 10:07 AM, casiano@ull.es via RT <bug-Parse-Eyapp@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=56640 > > > Many, Many Thanks Paulo for pointing the bug and for your help. > > I have uploaded version 1.159 of Parse::Eyapp that, hopefully, fixes the bug. >
>> In one particular program, YYExpect() dies when the parser is generated >> with the -v option, but works OK when the parser is generated without >> that option.
> > The bug was related with an undocumented feature of Parse::Eyapp: > >               The fact that the LALR action tables aren't compacted > when using  '-v'. > > Here is a slightly modified version of your example (you can find it > in the distribution): > > ~/LEyapp$ cat -n t/minusvoption/paulocustodio.eyp >     1  %{ >     2    my $stmt; >     3  %} >     4  %% >     5  prg: stmt * >     6  ; >     7 >     8         sos: >     9              /* empty */ { $stmt++ } >    10       ; >    11 >    12  stmt: >    13      '\n' >    14    | sos 'nop' '\n' >    15  ; >    16 >    17  %% >    18 >    19  my @input = ("nop", "\n", "org", "\n"); >    20  sub my_lexer { >    21    my $t = shift(@input); >    22    ($t, $t); >    23  } >    24 >    25  sub my_error { >    26    my($self) = @_; >    27    my $t = $self->YYCurval || "eof"; >    28    my @expected = map { $_ eq "\n"? q{'\\n'} : qq{'$_'} } > $self->YYExpect(); >    29    local $" = ', '; >    30    die("Statement $stmt: Syntax error at $t. Expected (@expected).\n"); >    31  } >    32 >    33  sub main { >    34    __PACKAGE__->new->YYParse( yylex => \&my_lexer, yyerror => \&my_error); >    35  } >    36 >    37  main(); > > When I compile it with '-v'  this is the new behavior: > > ~/LEyapp$ eyapp -v -b '' t/minusvoption/paulocustodio.eyp > ~/LEyapp$ t/minusvoption/paulocustodio.pm > Statement 1: Syntax error at org. Expected ('nop', '\n'). > ~/LEyapp$ > > If I supress the '-v' option we have: > > ~/LEyapp$ eyapp -b '' t/minusvoption/paulocustodio.eyp > ~/LEyapp$ t/minusvoption/paulocustodio.pm > Statement 2: Syntax error at org. Expected ('nop'). > > Which is less accurate than the former '-v' expected set (notice the > absence of '\n' in this output). > This is due to the compaction of the LALR table. > The error is caught later after the automata has moved to a new state. >
>> >> The state description for State 1 is different when generated with and >> without -v (in the generated .pm file):
> > The State 1 with -v is a more detailed description of the same state. > The memory optimization stage projects several common actions onto the > 'DEFAULT' > action. This is the difference. > > I have checked the behavior with your example on several Unixes. Let > me know if this fix is satisfactory for you > > Many thanks for your help > > Best wishes > > Casiano > >
"YYExpect() dies when parser is generated with -v option" solved
"YYExpect() dies when parser is generated with -v option" solved