Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Operator Precedence Parser

by bart (Canon)
on Jun 09, 2006 at 15:39 UTC ( [id://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
Domain Nodelet?
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?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (6)
As of 2024-03-29 09:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found