Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: Operator Precedence Parser

by bart (Canon)
on Jun 11, 2006 at 16:28 UTC ( #554691=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my %function = (
      sumsq => sub  { my $sum = 0; foreach(@_) { $sum += $_*$_; } return $
    +sum; },  # sum of squares
      sqrt => sub { return sqrt shift; },
    );
    
  2. or download this
        if(/\G((?i:[a-z]\w*))\s*\(/gc) {  # function '('
            my $function = $1;
    ...
            trace(sprintf "function '$function' called with %d argument%s"
    +, scalar @arg, @arg==1 ? "" : "s");
            return $function{$function}->(@arg);
        }
    
  3. or download this
    Line 29 "·sumsq(3,2+2)*sqrt(36)"
    Line 29 "sumsq(·3,2+2)*sqrt(36)"
    ...
    Line 45 "sumsq(3,2+2)*sqrt(36)·" result = 150
    150
    Stack: This value is never affected
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://554691]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (12)
As of 2015-07-07 10:26 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 (88 votes), past polls