summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorptmcg <ptmcg@9bf210a0-9d2d-494c-87cf-cfb32e7dff7b>2016-08-19 14:34:24 +0000
committerptmcg <ptmcg@9bf210a0-9d2d-494c-87cf-cfb32e7dff7b>2016-08-19 14:34:24 +0000
commit260d2bd117abab2f141184bc7a7f5b4df3f2f672 (patch)
tree4cd51487ecad0652e5b451a61c219a4973accb7f
parentc9e2a078029d2aa17ef7f6cd85c54bf297a403c4 (diff)
downloadpyparsing-260d2bd117abab2f141184bc7a7f5b4df3f2f672.tar.gz
Upgrade to use pyparsing_common for numbers
git-svn-id: svn://svn.code.sf.net/p/pyparsing/code/trunk@427 9bf210a0-9d2d-494c-87cf-cfb32e7dff7b
-rw-r--r--src/examples/excelExpr.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/examples/excelExpr.py b/src/examples/excelExpr.py
index b98115e..7ce8db2 100644
--- a/src/examples/excelExpr.py
+++ b/src/examples/excelExpr.py
@@ -7,10 +7,10 @@
from pyparsing import (CaselessKeyword, Suppress, Word, alphas,
alphanums, nums, Optional, Group, oneOf, Forward, Regex,
infixNotation, opAssoc, dblQuotedString, delimitedList,
- Combine, Literal, QuotedString, ParserElement)
+ Combine, Literal, QuotedString, ParserElement, pyparsing_common)
ParserElement.enablePackrat()
-EQ,EXCL,LPAR,RPAR,COLON,COMMA = map(Suppress, '=!():,')
+EQ,LPAR,RPAR,COLON,COMMA = map(Suppress, '=():,')
EXCL, DOLLAR = map(Literal,"!$")
sheetRef = Word(alphas, alphanums) | QuotedString("'",escQuote="''")
colRef = Optional(DOLLAR) + Word(alphas,max=2)
@@ -26,7 +26,7 @@ expr = Forward()
COMPARISON_OP = oneOf("< = > >= <= != <>")
condExpr = expr + COMPARISON_OP + expr
-ifFunc = (CaselessKeyword("if") +
+ifFunc = (CaselessKeyword("if") -
LPAR +
Group(condExpr)("condition") +
COMMA + Group(expr)("if_true") +
@@ -41,7 +41,7 @@ funcCall = ifFunc | sumFunc | minFunc | maxFunc | aveFunc
multOp = oneOf("* /")
addOp = oneOf("+ -")
-numericLiteral = Regex(r"\-?\d+(\.\d+)?")
+numericLiteral = pyparsing_common.number
operand = numericLiteral | funcCall | cellRange | cellRef
arithExpr = infixNotation(operand,
[
@@ -65,4 +65,5 @@ expr << (arithExpr | textExpr)
=3*'O''Reilly''s sheet'!$A$7+5
=if(Sum(A1:A25)>42,Min(B1:B25),if(Sum(C1:C25)>3.14, (Min(C1:C25)+3)*18,Max(B1:B25)))
=sum(a1:a25,10,min(b1,c2,d3))
+ =if("T"&a2="TTime", "Ready", "Not ready")
""") \ No newline at end of file