61 pos_start, pos_end = t.lexspan(2)
62 print("Syntax error at %d:%d to %d:%d" % (line_start,pos_start, line_end, pos_end))
63 t[0] = 0
64 65def p_expression_number(t):
66 'expression : NUMBER'
67 t[0] = t[1]
185 result = sys.stderr.getvalue()
186 self.assert_(check_expected(result,
187 "'p_error' defined, but is not a function or method\n"))
188 189 def test_yacc_error4(self):
190 self.assertRaises(ply.yacc.YaccError,run_import,"yacc_error4")
191 result = sys.stderr.getvalue()
132 "Generating LALR tables\n"
133
134 ))
135 136 def test_yacc_badrule(self):
137 self.assertRaises(ply.yacc.YaccError,run_import,"yacc_badrule")
138 result = sys.stderr.getvalue()
86 pymodule_out_remove("parsetab.pyc")
87 except OSError:
88 pass
89 90 if sys.hexversion >= 0x3020000:
91 warnings.filterwarnings('ignore', category=ResourceWarning)
92 warnings.filterwarnings('ignore', category=DeprecationWarning)
75 code = "import "+module
76 exec(code)
77 del sys.modules[module]
78 79# Tests related to errors and warnings when building parsers
80class YaccErrorWarningTests(unittest.TestCase):
81 def setUp(self):
Blank lines should not contain any tabs or spaces.