# "Lex and Yacc", p. 63.
# -----------------------------------------------------------------------------
+import sys
+sys.path.insert(0,"../..")
+
tokens = (
'NAME','NUMBER',
'PLUS','MINUS','TIMES','DIVIDE','EQUALS',
def t_newline(t):
r'\n+'
- t.lineno += t.value.count("\n")
+ t.lexer.lineno += t.value.count("\n")
def t_error(t):
print "Illegal character '%s'" % t.value[0]
- t.skip(1)
+ t.lexer.skip(1)
# Build the lexer
-import lex
+import ply.lex as lex
lex.lex(optimize=1)
# Parsing rules
def p_error(t):
print "Syntax error at '%s'" % t.value
-import yacc
+import ply.yacc as yacc
yacc.yacc(optimize=1)
while 1: