summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Beazley <dave@dabeaz.com>2017-01-31 12:25:58 -0600
committerDavid Beazley <dave@dabeaz.com>2017-01-31 12:25:58 -0600
commit2ba2f31e3890abae5af884d3df60eb0b506b1ec7 (patch)
tree0ee24fe75cb3aebf71329940dd9a5ea9a39e7e47
parent3335be2931e42803ddc64ce2df61f7b0aad1f30c (diff)
parent11eb4cf0a3b5bd7a627384afc2ff00e867f9eb45 (diff)
downloadply-2ba2f31e3890abae5af884d3df60eb0b506b1ec7.tar.gz
Merge branch 'master' of https://github.com/dabeaz/ply
-rw-r--r--example/yply/ylex.py4
-rw-r--r--example/yply/yparse.py32
-rwxr-xr-xexample/yply/yply.py8
3 files changed, 22 insertions, 22 deletions
diff --git a/example/yply/ylex.py b/example/yply/ylex.py
index a3efe8e..16410e2 100644
--- a/example/yply/ylex.py
+++ b/example/yply/ylex.py
@@ -109,8 +109,8 @@ def t_code_error(t):
def t_error(t):
- print "%d: Illegal character '%s'" % (t.lexer.lineno, t.value[0])
- print t.value
+ print("%d: Illegal character '%s'" % (t.lexer.lineno, t.value[0]))
+ print(t.value)
t.lexer.skip(1)
lex.lex()
diff --git a/example/yply/yparse.py b/example/yply/yparse.py
index fff887a..1f2e8d0 100644
--- a/example/yply/yparse.py
+++ b/example/yply/yparse.py
@@ -22,18 +22,18 @@ def p_defsection(p):
'''defsection : definitions SECTION
| SECTION'''
p.lexer.lastsection = 1
- print "tokens = ", repr(tokenlist)
- print
- print "precedence = ", repr(preclist)
- print
- print "# -------------- RULES ----------------"
- print
+ print("tokens = ", repr(tokenlist))
+ print()
+ print("precedence = ", repr(preclist))
+ print()
+ print("# -------------- RULES ----------------")
+ print()
def p_rulesection(p):
'''rulesection : rules SECTION'''
- print "# -------------- RULES END ----------------"
+ print("# -------------- RULES END ----------------")
print_code(p[2], 0)
@@ -49,7 +49,7 @@ def p_definition_literal(p):
def p_definition_start(p):
'''definition : START ID'''
- print "start = '%s'" % p[2]
+ print("start = '%s'" % p[2])
def p_definition_token(p):
@@ -138,7 +138,7 @@ def p_rules(p):
rulecount = 1
for r in rule[1]:
# r contains one of the rule possibilities
- print "def p_%s_%d(p):" % (rulename, rulecount)
+ print("def p_%s_%d(p):" % (rulename, rulecount))
prod = []
prodcode = ""
for i in range(len(r)):
@@ -155,17 +155,17 @@ def p_rules(p):
embed_count += 1
else:
prod.append(item)
- print " '''%s : %s'''" % (rulename, " ".join(prod))
+ print(" '''%s : %s'''" % (rulename, " ".join(prod)))
# Emit code
print_code(prodcode, 4)
- print
+ print()
rulecount += 1
for e, code in embedded:
- print "def p_%s(p):" % e
- print " '''%s : '''" % e
+ print("def p_%s(p):" % e)
+ print(" '''%s : '''" % e)
print_code(code, 4)
- print
+ print()
def p_rule(p):
@@ -204,7 +204,7 @@ def p_morerules(p):
p[0] = p[1]
p[0].append(p[3])
-# print "morerules", len(p), p[0]
+# print("morerules", len(p), p[0])
def p_rulelist(p):
@@ -241,4 +241,4 @@ def print_code(code, indent):
return
codelines = code.splitlines()
for c in codelines:
- print "%s# %s" % (" " * indent, c)
+ print("%s# %s" % (" " * indent, c))
diff --git a/example/yply/yply.py b/example/yply/yply.py
index 1aa24c3..e24616c 100755
--- a/example/yply/yply.py
+++ b/example/yply/yply.py
@@ -29,14 +29,14 @@ import yparse
from ply import *
if len(sys.argv) == 1:
- print "usage : yply.py [-nocode] inputfile"
+ print("usage : yply.py [-nocode] inputfile")
raise SystemExit
if len(sys.argv) == 3:
if sys.argv[1] == '-nocode':
yparse.emit_code = 0
else:
- print "Unknown option '%s'" % sys.argv[1]
+ print("Unknown option '%s'" % sys.argv[1])
raise SystemExit
filename = sys.argv[2]
else:
@@ -44,8 +44,8 @@ else:
yacc.parse(open(filename).read())
-print """
+print("""
if __name__ == '__main__':
from ply import *
yacc.yacc()
-"""
+""")