diff options
Diffstat (limited to 'ext/ply/example/yply')
-rw-r--r-- | ext/ply/example/yply/ylex.py | 12 | ||||
-rw-r--r-- | ext/ply/example/yply/yparse.py | 14 | ||||
-rwxr-xr-x[-rw-r--r--] | ext/ply/example/yply/yply.py | 0 |
3 files changed, 13 insertions, 13 deletions
diff --git a/ext/ply/example/yply/ylex.py b/ext/ply/example/yply/ylex.py index 61bc0c7ef..84f2f7a73 100644 --- a/ext/ply/example/yply/ylex.py +++ b/ext/ply/example/yply/ylex.py @@ -42,7 +42,7 @@ def t_SECTION(t): # Comments def t_ccomment(t): r'/\*(.|\n)*?\*/' - t.lineno += t.value.count('\n') + t.lexer.lineno += t.value.count('\n') t_ignore_cppcomment = r'//.*' @@ -95,7 +95,7 @@ def t_code_error(t): raise RuntimeError def t_error(t): - print "%d: Illegal character '%s'" % (t.lineno, t.value[0]) + print "%d: Illegal character '%s'" % (t.lexer.lineno, t.value[0]) print t.value t.lexer.skip(1) @@ -104,9 +104,9 @@ lex.lex() if __name__ == '__main__': lex.runmain() + + + - - - - + diff --git a/ext/ply/example/yply/yparse.py b/ext/ply/example/yply/yparse.py index a4e46bef7..ab5b88451 100644 --- a/ext/ply/example/yply/yparse.py +++ b/ext/ply/example/yply/yparse.py @@ -25,7 +25,7 @@ def p_defsection(p): print "precedence = ", repr(preclist) print print "# -------------- RULES ----------------" - print + print def p_rulesection(p): '''rulesection : rules SECTION''' @@ -78,12 +78,12 @@ def p_idlist(p): p[1].append(p[3]) def p_tokenid(p): - '''tokenid : ID + '''tokenid : ID | ID NUMBER | QLITERAL | QLITERAL NUMBER''' p[0] = p[1] - + def p_optsemi(p): '''optsemi : ';' | empty''' @@ -165,7 +165,7 @@ def p_rule_empty(p): def p_rule_empty2(p): '''rule : ID ':' morerules ';' ''' - + p[3].insert(0,[]) p[0] = (p[1],p[3]) @@ -173,10 +173,10 @@ def p_morerules(p): '''morerules : morerules '|' rulelist | '|' rulelist | '|' ''' - - if len(p) == 2: + + if len(p) == 2: p[0] = [[]] - elif len(p) == 3: + elif len(p) == 3: p[0] = [p[2]] else: p[0] = p[1] diff --git a/ext/ply/example/yply/yply.py b/ext/ply/example/yply/yply.py index a4398171e..a4398171e 100644..100755 --- a/ext/ply/example/yply/yply.py +++ b/ext/ply/example/yply/yply.py |