Affix-Infix2Postfix

 view release on metacpan or  search on metacpan

Infix2Postfix.pm  view on Meta::CPAN

  $inst=Affix::Infix2Postfix->new(
    'ops'=>[
	  {op=>'+'},
	  {op=>'-'},
	  {op=>'*'},
	  {op=>'/'},
	  {op=>'-',type=>'unary',trans=>'u-'},
	  {op=>'func',type=>'unary'},
	 ],
	  'grouping'=>[qw( \( \) )],
	  'func'=>[qw( sin cos exp log )],
	  'vars'=>[qw( x y z)]
	 );
  $rc=$inst->translate($str)
  || die "Error in '$str': ".$inst->{ERRSTR}."\n";


=head1 DESCRIPTION

Infix2Postfix as the name suggests converts from infix to postfix
notation. The reason why someone would like to do this is that postfix

test.pl  view on Meta::CPAN

					{op=>'>>'},
					{op=>'+'},
					{op=>'-'},
					{op=>'*'},
					{op=>'/'},
					{op=>'-',type=>'unary',trans=>'u-'},
					{op=>'**'},
					{op=>'func',type=>'unary'},
				       ],
				'grouping'=>[qw( \( \) )],
				'func'=>[qw( sin cos exp log )],
				'vars'=>[qw( x y z)]
				);
@res=$inst->translate($str); 
@res || die "Error in '$str': ".$inst->{ERRSTR}."\n";

#print Dumper($inst);
print "\#$str\n";
print "\#",join(" ",@res),"\n";




( run in 0.484 second using v1.01-cache-2.11-cpan-49f99fa48dc )