Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Breaking The Rules II

by Limbic~Region (Chancellor)
on Jul 02, 2007 at 13:48 UTC ( #624445=perlmeditation: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    package Math::Expression::Evaluator;
    @ISA    = qw(Exporter);
    ...
        return;
    }
    'This statement is false';
    
  2. or download this
    #!/usr/bin/perl
    use strict;
    ...
    my $parser = new Parse::RecDescent $grammar;
    print Dumper $parser->evaluate('42 - 5 + 1');
    # Sees the result as 42 - (5 + 1)
    
  3. or download this
    #!/usr/bin/perl
    use strict;
    ...
    };
    my $parser = new Parse::RecDescent $grammar;
    print Dumper $parser->evaluate('42 - 5 + 1');
    
  4. or download this
    #!/usr/bin/perl
    use strict;
    ...
    my $parser = Parse::RecDescent->new($grammar) or die("Bad grammar\n");
    my $answer = $parser->evaluate('11 - (4 + 4)^3 * sqrt(5 * (6 - 1)) + a
    +bs(-3)');
    print defined $answer ? $answer : 'Invalid expression';
    
  5. or download this
    #!/usr/bin/perl
    use strict;
    ...
    my $tree = $parser->build('11 - 6 + 4');
    my $eval = eval_node($tree);
    print "$eval\n";
    
  6. or download this
    #!/usr/bin/perl
    use strict;
    ...
        my $self = shift @_;
        $self->YYData->{INPUT} = $_[0];
    }
    
  7. or download this
    #!/usr/bin/perl
    use strict;
    ...
    $parser->advance($str) for 1..6;
    my ($tree) = $parser->matches_all($str, 'input');
    print Dumper($tree);
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://624445]
Approved by Old_Gray_Bear
Front-paged by Old_Gray_Bear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (9)
As of 2015-07-03 12:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (53 votes), past polls