summaryrefslogtreecommitdiff
path: root/examples/rosettacode.py
diff options
context:
space:
mode:
authorPaul McGuire <ptmcg@austin.rr.com>2019-08-05 22:07:15 -0500
committerPaul McGuire <ptmcg@austin.rr.com>2019-08-05 22:07:15 -0500
commit9ca5931db90a487085851fd9f847066fd48ae55b (patch)
tree9dcdb6fb3bd842120b666c470b9206be237574a1 /examples/rosettacode.py
parent10b5e96bda409e6ecd895fe41f65cc9bd943b824 (diff)
downloadpyparsing-git-9ca5931db90a487085851fd9f847066fd48ae55b.tar.gz
Code style updates; remove deprecated methods
Diffstat (limited to 'examples/rosettacode.py')
-rw-r--r--examples/rosettacode.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/examples/rosettacode.py b/examples/rosettacode.py
index 07ed7fa..8a8d5c9 100644
--- a/examples/rosettacode.py
+++ b/examples/rosettacode.py
@@ -41,7 +41,8 @@ LBRACE, RBRACE, LPAR, RPAR, SEMI = map(pp.Suppress, "{}();")
EQ = pp.Literal('=')
keywords = (WHILE, IF, PRINT, PUTC, ELSE) = map(pp.Keyword, "while if print putc else".split())
-identifier = ~(pp.MatchFirst(keywords)) + pp.pyparsing_common.identifier
+any_keyword = pp.MatchFirst(keywords)
+identifier = ~any_keyword + pp.pyparsing_common.identifier
integer = pp.pyparsing_common.integer
string = pp.QuotedString('"', convertWhitespaceEscapes=False).setName("quoted string")
char = pp.Regex(r"'\\?.'")
@@ -66,7 +67,7 @@ while_stmt = pp.Group(WHILE - paren_expr + stmt)
if_stmt = pp.Group(IF - paren_expr + stmt + pp.Optional(ELSE + stmt))
print_stmt = pp.Group(PRINT - pp.Group(LPAR + prt_list + RPAR) + SEMI)
putc_stmt = pp.Group(PUTC - paren_expr + SEMI)
-stmt_list = pp.Group(LBRACE + pp.ZeroOrMore(stmt) + RBRACE)
+stmt_list = pp.Group(LBRACE + stmt[...] + RBRACE)
stmt <<= (pp.Group(SEMI)
| assignment_stmt
| while_stmt
@@ -76,7 +77,7 @@ stmt <<= (pp.Group(SEMI)
| stmt_list
).setName("statement")
-code = pp.ZeroOrMore(stmt)
+code = stmt[...]
code.ignore(pp.cppStyleComment)