summaryrefslogtreecommitdiff
path: root/examples/romanNumerals.py
diff options
context:
space:
mode:
authorPaul McGuire <ptmcg@users.noreply.github.com>2018-12-23 21:30:40 -0600
committerGitHub <noreply@github.com>2018-12-23 21:30:40 -0600
commit4fba64a079016e6ea62d041f19b7eadd081341e8 (patch)
tree6c5fdae41cf8b335ff1c64f37856786523e4fd0d /examples/romanNumerals.py
parent59dfd314c23fd653271bdad37631f0497e8ad748 (diff)
parentde8326d00dffdb500c02839a98330b869c2457f3 (diff)
downloadpyparsing-git-4fba64a079016e6ea62d041f19b7eadd081341e8.tar.gz
Merge pull request #55 from jdufresne/ws
Trim trailing white space throughout the project
Diffstat (limited to 'examples/romanNumerals.py')
-rw-r--r--examples/romanNumerals.py14
1 files changed, 4 insertions, 10 deletions
diff --git a/examples/romanNumerals.py b/examples/romanNumerals.py
index 27361f0..536fbb0 100644
--- a/examples/romanNumerals.py
+++ b/examples/romanNumerals.py
@@ -7,7 +7,7 @@ from pyparsing import *
def romanNumeralLiteral(numeralString, value):
return Literal(numeralString).setParseAction(replaceWith(value))
-
+
one = romanNumeralLiteral("I",1)
four = romanNumeralLiteral("IV",4)
five = romanNumeralLiteral("V",5)
@@ -22,8 +22,8 @@ fivehundred = romanNumeralLiteral("D",500)
ninehundred = romanNumeralLiteral("CM",900)
onethousand = romanNumeralLiteral("M",1000)
-numeral = ( onethousand | ninehundred | fivehundred | fourhundred |
- onehundred | ninety | fifty | forty | ten | nine | five |
+numeral = ( onethousand | ninehundred | fivehundred | fourhundred |
+ onehundred | ninety | fifty | forty | ten | nine | five |
four | one ).leaveWhitespace()
romanNumeral = OneOrMore(numeral).setParseAction( lambda s,l,t : sum(t) )
@@ -34,7 +34,7 @@ def makeRomanNumeral(n):
n -= limit
s += c
return n,s
-
+
ret = ""
while n >= 1000: n,ret = addDigit(n,1000,"M",ret)
while n >= 900: n,ret = addDigit(n, 900,"CM",ret)
@@ -66,9 +66,3 @@ test("XIV")
test("XIX")
test("MCMLXXX")
test("MMVI")
-
-
-
-
-
-