From: John Machin on
On Jan 15, 3:41 pm, Paul McGuire <pt...(a)austin.rr.com> wrote:
> I never represented that this parser would handle any and all Excel
> formulas!
>  But I should hope the basic structure of a pyparsing
> solution might help the OP add some of the other features you cited,
> if necessary. It's actually pretty common to take an incremental
> approach in making such a parser, and so here are some of the changes
> that you would need to make based on the deficiencies you pointed out:
>
> functions can have a variable number of arguments, of any kind of
> expression
> - statFunc = lambda name : CaselessKeyword(name) + LPAR + delimitedList
> (expr) + RPAR
>
> sheet name could also be a quoted string
> - sheetRef = Word(alphas, alphanums) | QuotedString("'",escQuote="''")
>
> add boolean literal support
> - boolLiteral = oneOf("TRUE FALSE")
> - operand = numericLiteral | funcCall | boolLiteral | cellRange |
> cellRef

or a string literal ... you seem to have ignored the significant point
that the binary operators don't have narrow type requirements of their
args ("""2.3 & 4.5 produces text "2.34.5", while "2.3" + "4.5"
produces number 6.8"""); your attempt to enforce particular types for
args at compile-time is erroneous OVER-engineering.