Commit ff152fe9 authored by Robert Bradshaw's avatar Robert Bradshaw

Better NULL parsing, touchup pure test

parent 88c3bd04
...@@ -518,11 +518,10 @@ def p_atom(s): ...@@ -518,11 +518,10 @@ def p_atom(s):
return ExprNodes.BoolNode(pos, value=True) return ExprNodes.BoolNode(pos, value=True)
elif name == "False": elif name == "False":
return ExprNodes.BoolNode(pos, value=False) return ExprNodes.BoolNode(pos, value=False)
elif name == "NULL":
return ExprNodes.NullNode(pos)
else: else:
return p_name(s, name) return p_name(s, name)
elif sy == 'NULL':
s.next()
return ExprNodes.NullNode(pos)
else: else:
s.error("Expected an identifier or literal") s.error("Expected an identifier or literal")
......
...@@ -145,7 +145,7 @@ reserved_words = [ ...@@ -145,7 +145,7 @@ reserved_words = [
"raise", "import", "exec", "try", "except", "finally", "raise", "import", "exec", "try", "except", "finally",
"while", "if", "elif", "else", "for", "in", "assert", "while", "if", "elif", "else", "for", "in", "assert",
"and", "or", "not", "is", "in", "lambda", "from", "and", "or", "not", "is", "in", "lambda", "from",
"NULL", "cimport", "by", "with", "cpdef", "DEF", "IF", "ELIF", "ELSE" "cimport", "by", "with", "cpdef", "DEF", "IF", "ELIF", "ELSE"
] ]
class Method: class Method:
......
import sys, os __doc__ = """
sys.path.insert(0, "..") >>> test_sizeof()
True
True
True
True
True
import cython >>> test_declare(100)
(100, 100)
>>> test_declare(100.5)
(100, 100)
>>> test_declare(None)
Traceback (most recent call last):
...
TypeError: an integer is required
>>> test_cast(1.5)
1
>>> test_cast(None)
Traceback (most recent call last):
...
TypeError: a float is required
>>> test_address(39)
39
>>> test_locals(5)
True
>>> test_struct(389, 1.64493)
(389, 1.64493)
>>> test_imports()
True
"""
import cython
def test_sizeof(): def test_sizeof():
x = cython.declare(cython.bint) x = cython.declare(cython.bint)
...@@ -52,15 +85,15 @@ def test_struct(n, x): ...@@ -52,15 +85,15 @@ def test_struct(n, x):
import cython as cy import cython as cy
from cython import declare, cast, locals, address, typedef, p_void, compiled from cython import declare, cast, locals, address, typedef, p_void, compiled
from cython import declare as my_declare, locals as my_locals, p_void as my_void_star, typedef as my_typedef, my_compiled from cython import declare as my_declare, locals as my_locals, p_void as my_void_star, typedef as my_typedef, compiled as my_compiled
@my_locals(a=cython.p_void) @my_locals(a=cython.p_void)
def test_imports(): def test_imports():
a = NULL a = cython.NULL
b = declare(p_void, NULL) b = declare(p_void, cython.NULL)
c = my_declare(my_void_star, NULL) c = my_declare(my_void_star, cython.NULL)
d = cy.declare(cy.p_void, NULL) d = cy.declare(cy.p_void, cython.NULL)
compiled and my_compiled return a == d and compiled and my_compiled
MyStruct3 = typedef(MyStruct[3]) MyStruct3 = typedef(MyStruct[3])
MyStruct4 = my_typedef(MyStruct[4]) MyStruct4 = my_typedef(MyStruct[4])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment