Subject: | Recdescent - Production Unit Fails Becoz of Empty Function |
Date: | Fri, 12 Mar 2010 15:24:11 +0530 |
To: | "bug-Parse-RecDescent [...] rt.cpan.org" <bug-Parse-RecDescent [...] rt.cpan.org> |
From: | "Anand Venkatesan, ERS, HCLTech" <anand.vn [...] hcl.in> |
Hi,
I have a query regarding the return item and the function call inside the actions block of a production unit.
If nothing is returned from a production unit, the value of the last component of the production unit will be returned. But in my below program the production unit (declare_statement) got failed if nothing is returned, where a function call alone placed inside the action block and that function has nothing to execute (empty function).
But if I add any code in the empty function, the production unit got passed. Is it a bug or the normal behavior of the Rec-descent package?
Recdescent version : Parse-RecDescent-1.964
Perl Version : v5.8.8 built for MSWin32-x86-multi-thread
####### Program Starts ##########
use strict;
use warnings;
use Data::Dumper;
use Parse::RecDescent;
my $Parser = q{
statement : declare_statement
| return_statment
| <error: $text>
declare_statement : data_type var_name ';'
{
::process_declaration(@item);
}
return_statment : 'return' var_name ';'
var_name : /[_a-zA-Z0-9]+/
data_type : ('int' | 'char') {$return = $item[1];}
};
my $Data = join '', <DATA>;
my $C_Parser_Obj = Parse::RecDescent->new($Parser);
$C_Parser_Obj->statement($Data);
sub process_declaration
{
#Empty Function causes the Production Unit "declare_statement" To Fail!
#my (@Data) = @_; #uncomment this line to pass the production unit
}
__DATA__
int myvar;
return myvar;
####### Program Ends ##########
Thanks & Regards,
Anand V
DISCLAIMER:
-----------------------------------------------------------------------------------------------------------------------
The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only.
It shall not attach any liability on the originator or HCL or its affiliates. Any views or opinions presented in
this email are solely those of the author and may not necessarily reflect the opinions of HCL or its affiliates.
Any form of reproduction, dissemination, copying, disclosure, modification, distribution and / or publication of
this message without the prior written consent of the author of this e-mail is strictly prohibited. If you have
received this email in error please delete it and notify the sender immediately. Before opening any mail and
attachments please check them for viruses and defect.
-----------------------------------------------------------------------------------------------------------------------
Message body is not shown because it is too large.