Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Operator Precedence Parser

by bart (Canon)
on Jun 09, 2006 at 15:39 UTC ( #554516=perlmeditation: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    expr := value ( op value )*
    
  2. or download this
    sub parse_expr {
        my($value, @stack);
    ...
        $value = process(\@stack, $value);  # final processing
        return $value;
    }
    
  3. or download this
    value := '(' expr ')'
    
  4. or download this
    #!perl -w
    use strict;
    ...
    $_ = "20+3*a+10*-b-5*(3 +2)*5";
    $\ = "\n";
    print evaluate($_);
    
  5. or download this
    #!perl -w
    use strict;
    ...
    $_ = "20+3*a+10*-b-5*(3 +2)*5";
    $\ = "\n";
    print evaluate($_);
    
  6. or download this
    value := name '(' ( expr ( ',' expr ) * )? ')'
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://554516]
Approved by Limbic~Region
Front-paged by liverpole
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2017-11-22 04:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (315 votes). Check out past polls.

    Notices?