From de8326d00dffdb500c02839a98330b869c2457f3 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Sat, 22 Dec 2018 09:28:48 -0800 Subject: Trim trailing white space throughout the project Many editors clean up trailing white space on save. By removing it all in one go, it helps keep future diffs cleaner by avoiding spurious white space changes on unrelated lines. --- examples/excelExpr.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'examples/excelExpr.py') diff --git a/examples/excelExpr.py b/examples/excelExpr.py index 7ce8db2..913d65b 100644 --- a/examples/excelExpr.py +++ b/examples/excelExpr.py @@ -1,12 +1,12 @@ # excelExpr.py # # Copyright 2010, Paul McGuire -# +# # A partial implementation of a parser of Excel formula expressions. # -from pyparsing import (CaselessKeyword, Suppress, Word, alphas, - alphanums, nums, Optional, Group, oneOf, Forward, Regex, - infixNotation, opAssoc, dblQuotedString, delimitedList, +from pyparsing import (CaselessKeyword, Suppress, Word, alphas, + alphanums, nums, Optional, Group, oneOf, Forward, Regex, + infixNotation, opAssoc, dblQuotedString, delimitedList, Combine, Literal, QuotedString, ParserElement, pyparsing_common) ParserElement.enablePackrat() @@ -15,10 +15,10 @@ EXCL, DOLLAR = map(Literal,"!$") sheetRef = Word(alphas, alphanums) | QuotedString("'",escQuote="''") colRef = Optional(DOLLAR) + Word(alphas,max=2) rowRef = Optional(DOLLAR) + Word(nums) -cellRef = Combine(Group(Optional(sheetRef + EXCL)("sheet") + colRef("col") + +cellRef = Combine(Group(Optional(sheetRef + EXCL)("sheet") + colRef("col") + rowRef("row"))) -cellRange = (Group(cellRef("start") + COLON + cellRef("end"))("range") +cellRange = (Group(cellRef("start") + COLON + cellRef("end"))("range") | cellRef | Word(alphas,alphanums)) expr = Forward() @@ -26,10 +26,10 @@ expr = Forward() COMPARISON_OP = oneOf("< = > >= <= != <>") condExpr = expr + COMPARISON_OP + expr -ifFunc = (CaselessKeyword("if") - - LPAR + - Group(condExpr)("condition") + - COMMA + Group(expr)("if_true") + +ifFunc = (CaselessKeyword("if") - + LPAR + + Group(condExpr)("condition") + + COMMA + Group(expr)("if_true") + COMMA + Group(expr)("if_false") + RPAR) statFunc = lambda name : Group(CaselessKeyword(name) + Group(LPAR + delimitedList(expr) + RPAR)) @@ -42,7 +42,7 @@ funcCall = ifFunc | sumFunc | minFunc | maxFunc | aveFunc multOp = oneOf("* /") addOp = oneOf("+ -") numericLiteral = pyparsing_common.number -operand = numericLiteral | funcCall | cellRange | cellRef +operand = numericLiteral | funcCall | cellRange | cellRef arithExpr = infixNotation(operand, [ (multOp, 2, opAssoc.LEFT), @@ -66,4 +66,4 @@ expr << (arithExpr | textExpr) =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 +""") -- cgit v1.2.1