summaryrefslogtreecommitdiff
path: root/ext/ply/example/ansic
diff options
context:
space:
mode:
authorNathan Binkert <nate@binkert.org>2009-08-16 13:39:58 -0700
committerNathan Binkert <nate@binkert.org>2009-08-16 13:39:58 -0700
commite1270f81bdc81f5a575b34c2d2c294bdde3e6f4f (patch)
treeb54af3469a338609faf04e67603c5264e79d59a5 /ext/ply/example/ansic
parentbcaf93d182f43bf72d52104bb909324945904120 (diff)
downloadgem5-e1270f81bdc81f5a575b34c2d2c294bdde3e6f4f.tar.xz
ply: update PLY to version 3.2
Diffstat (limited to 'ext/ply/example/ansic')
-rw-r--r--ext/ply/example/ansic/clex.py20
-rw-r--r--ext/ply/example/ansic/cparse.py10
2 files changed, 15 insertions, 15 deletions
diff --git a/ext/ply/example/ansic/clex.py b/ext/ply/example/ansic/clex.py
index 12441a60b..37fdd8e66 100644
--- a/ext/ply/example/ansic/clex.py
+++ b/ext/ply/example/ansic/clex.py
@@ -26,7 +26,7 @@ tokens = reserved + (
'OR', 'AND', 'NOT', 'XOR', 'LSHIFT', 'RSHIFT',
'LOR', 'LAND', 'LNOT',
'LT', 'LE', 'GT', 'GE', 'EQ', 'NE',
-
+
# Assignment (=, *=, /=, %=, +=, -=, <<=, >>=, &=, ^=, |=)
'EQUALS', 'TIMESEQUAL', 'DIVEQUAL', 'MODEQUAL', 'PLUSEQUAL', 'MINUSEQUAL',
'LSHIFTEQUAL','RSHIFTEQUAL', 'ANDEQUAL', 'XOREQUAL', 'OREQUAL',
@@ -39,7 +39,7 @@ tokens = reserved + (
# Conditional operator (?)
'CONDOP',
-
+
# Delimeters ( ) [ ] { } , . ; :
'LPAREN', 'RPAREN',
'LBRACKET', 'RBRACKET',
@@ -57,7 +57,7 @@ t_ignore = ' \t\x0c'
def t_NEWLINE(t):
r'\n+'
t.lexer.lineno += t.value.count("\n")
-
+
# Operators
t_PLUS = r'\+'
t_MINUS = r'-'
@@ -142,23 +142,23 @@ t_CCONST = r'(L)?\'([^\\\n]|(\\.))*?\''
# Comments
def t_comment(t):
- r' /\*(.|\n)*?\*/'
- t.lineno += t.value.count('\n')
+ r'/\*(.|\n)*?\*/'
+ t.lexer.lineno += t.value.count('\n')
# Preprocessor directive (ignored)
def t_preprocessor(t):
r'\#(.)*?\n'
- t.lineno += 1
-
+ t.lexer.lineno += 1
+
def t_error(t):
- print "Illegal character %s" % repr(t.value[0])
+ print("Illegal character %s" % repr(t.value[0]))
t.lexer.skip(1)
-
+
lexer = lex.lex(optimize=1)
if __name__ == "__main__":
lex.runmain(lexer)
-
+
diff --git a/ext/ply/example/ansic/cparse.py b/ext/ply/example/ansic/cparse.py
index d474378c8..c9b916455 100644
--- a/ext/ply/example/ansic/cparse.py
+++ b/ext/ply/example/ansic/cparse.py
@@ -155,7 +155,7 @@ def p_struct_declaration_list_1(t):
pass
def p_struct_declaration_list_2(t):
- 'struct_declaration_list : struct_declarator_list struct_declaration'
+ 'struct_declaration_list : struct_declaration_list struct_declaration'
pass
# init-declarator-list:
@@ -778,12 +778,12 @@ def p_unary_expression_5(t):
def p_unary_expression_6(t):
'unary_expression : SIZEOF LPAREN type_name RPAREN'
pass
-
+
#unary-operator
def p_unary_operator(t):
'''unary_operator : AND
| TIMES
- | PLUS
+ | PLUS
| MINUS
| NOT
| LNOT '''
@@ -837,7 +837,7 @@ def p_argument_expression_list(t):
pass
# constant:
-def p_constant(t):
+def p_constant(t):
'''constant : ICONST
| FCONST
| CCONST'''
@@ -849,7 +849,7 @@ def p_empty(t):
pass
def p_error(t):
- print "Whoa. We're hosed"
+ print("Whoa. We're hosed")
import profile
# Build the grammar