slightly more telling error message on generic syntax errors
authorStefan Behnel <scoder@users.berlios.de>
Fri, 5 Nov 2010 07:19:34 +0000 (08:19 +0100)
committerStefan Behnel <scoder@users.berlios.de>
Fri, 5 Nov 2010 07:19:34 +0000 (08:19 +0100)
Cython/Compiler/Scanning.py
tests/errors/cdef_syntax.pyx
tests/errors/cpdef_syntax.pyx
tests/errors/e2_packedstruct_T290.pyx

index 1f60f703464fd55c5f9499e5ab07fc0d67f264aa..535333abaf2c11c4268bfd70765afa3345c9ed55 100644 (file)
@@ -419,7 +419,11 @@ class PyrexScanner(Scanner):
         if message:
             self.error(message)
         else:
-            self.error("Expected '%s'" % what)
+            if self.sy == IDENT:
+                found = self.systring
+            else:
+                found = self.sy
+            self.error("Expected '%s', found '%s'" % (what, found))
         
     def expect_indent(self):
         self.expect('INDENT',
index aad39b30b1dd82e24139696c85e5350efd95841b..0af661015cb0300aa4be8175a585401009796f30 100644 (file)
@@ -6,5 +6,5 @@ cdef nogil class test: pass
 _ERRORS = u"""
  2: 5: Expected an identifier, found 'pass'
  3: 9: Empty declarator
- 4:11: Expected ':'
+ 4:11: Expected ':', found 'class'
 """
index f67cd1c4f273f4293a41cb32e0f5c1fe76601883..654a1fe09db92b8fb3d51f725f21d40e74be7907 100644 (file)
@@ -5,5 +5,5 @@ cpdef nogil class test: pass
 _ERRORS = u"""
  2: 6: cdef blocks cannot be declared cpdef
  3: 6: cdef blocks cannot be declared cpdef
- 3:12: Expected ':'
+ 3:12: Expected ':', found 'class'
 """
index ee053ee29c98730dfecdfa94cae01f9e11e539da..d5628772c209054d756546217a4df5dfdb8c1869 100644 (file)
@@ -2,5 +2,5 @@ cdef packed foo:
     pass
 
 _ERRORS = u"""
-1:12: Expected 'struct'
+1:12: Expected 'struct', found 'foo'
 """