Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (10)
As of 2015-07-04 11:36 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 (59 votes), past polls