
PEG xlsexpr (Formula)
        Formula    <- Expr EOF ;

        MulOp   <- '<' / '>' / '=' / '*' / '/'          ;
        Expo    <- Value ('^' Value)?                   ;
        Prod    <- Expo WS (MulOp WS Expo)*                     ;
        AddOp   <- '^' / '+' / '-'                      ;
        Sum     <- Prod WS (AddOp WS Prod)*                     ;
        Expr    <- Sum                                  ;

 void:   WS      <- <space>*                             ;

        Value       <- UnOp? ( '(' Expr ')' / String / Func / Range / Cell / Number )   ;

        UnOp        <- '-' / '+'                        ;

        Func    <- FunName '(' WS FunArgs WS ')'                ;
        FunName <- <alpha><alnum>*                      ;
        FunArgs <- Expr WS (',' WS Expr)*                       ;

        Range      <- Sheet? RowCol ':' RowCol          ;
        Cell       <- Sheet? Cell_                      ;
        Sheet      <- "'"? Sheet_ "'"? '!'              ;
        Sheet_     <- [-A-Za-z0-9& ]+                   ;
        Cell_      <- <alpha>+<ddigit>+                 ;
        RowCol     <- Col_ Row_                         ;
        Col_       <- <alpha>+                          ;
        Row_       <- <ddigit>+                         ;

        String     <- '"' [A-Za-z0-9]* '"'                      ;

 leaf:   Number  <- Sign? ( <ddigit>+ Frac? ) / Frac?    ;
        Sign    <- '-' / '+'                            ;
        Frac    <- '.' <ddigit>*                        ;

        EOF        <- !.                                ;
 END;
