Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cython
Commits
17fabe5a
Commit
17fabe5a
authored
Nov 11, 2008
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make raising a KeyError not the default for parsing names.
parent
82245e93
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
20 deletions
+23
-20
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+15
-19
Cython/Compiler/Scanning.pxd
Cython/Compiler/Scanning.pxd
+4
-0
Cython/Compiler/Scanning.py
Cython/Compiler/Scanning.py
+4
-1
No files found.
Cython/Compiler/Parsing.py
View file @
17fabe5a
...
...
@@ -532,26 +532,22 @@ def p_atom(s):
def
p_name
(
s
,
name
):
pos
=
s
.
position
()
if
not
s
.
compile_time_expr
:
try
:
value
=
s
.
compile_time_env
.
lookup_here
(
name
)
except
KeyError
:
pass
if
not
s
.
compile_time_expr
and
name
in
s
.
compile_time_env
:
value
=
s
.
compile_time_env
.
lookup_here
(
name
)
rep
=
repr
(
value
)
if
isinstance
(
value
,
bool
):
return
ExprNodes
.
BoolNode
(
pos
,
value
=
value
)
elif
isinstance
(
value
,
int
):
return
ExprNodes
.
IntNode
(
pos
,
value
=
rep
)
elif
isinstance
(
value
,
long
):
return
ExprNodes
.
IntNode
(
pos
,
value
=
rep
,
longness
=
"L"
)
elif
isinstance
(
value
,
float
):
return
ExprNodes
.
FloatNode
(
pos
,
value
=
rep
)
elif
isinstance
(
value
,
(
str
,
unicode
)):
return
ExprNodes
.
StringNode
(
pos
,
value
=
value
)
else
:
rep
=
repr
(
value
)
if
isinstance
(
value
,
bool
):
return
ExprNodes
.
BoolNode
(
pos
,
value
=
value
)
elif
isinstance
(
value
,
int
):
return
ExprNodes
.
IntNode
(
pos
,
value
=
rep
)
elif
isinstance
(
value
,
long
):
return
ExprNodes
.
IntNode
(
pos
,
value
=
rep
,
longness
=
"L"
)
elif
isinstance
(
value
,
float
):
return
ExprNodes
.
FloatNode
(
pos
,
value
=
rep
)
elif
isinstance
(
value
,
(
str
,
unicode
)):
return
ExprNodes
.
StringNode
(
pos
,
value
=
value
)
else
:
error
(
pos
,
"Invalid type for compile-time constant: %s"
%
value
.
__class__
.
__name__
)
error
(
pos
,
"Invalid type for compile-time constant: %s"
%
value
.
__class__
.
__name__
)
return
ExprNodes
.
NameNode
(
pos
,
name
=
name
)
def
p_cat_string_literal
(
s
):
...
...
Cython/Compiler/Scanning.pxd
View file @
17fabe5a
from
Cython.Plex.Scanners
cimport
Scanner
cdef
class
CompileTimeScope
:
cdef
public
entries
cdef
public
outer
cdef
class
PyrexScanner
(
Scanner
):
cdef
public
context
cdef
public
list
included_files
...
...
Cython/Compiler/Scanning.py
View file @
17fabe5a
...
...
@@ -176,7 +176,7 @@ resword_dict = build_resword_dict()
#------------------------------------------------------------------
class
CompileTimeScope
(
object
)
:
class
CompileTimeScope
:
def
__init__
(
self
,
outer
=
None
):
self
.
entries
=
{}
...
...
@@ -187,6 +187,9 @@ class CompileTimeScope(object):
def
lookup_here
(
self
,
name
):
return
self
.
entries
[
name
]
def
__contains__
(
self
,
name
):
return
name
in
self
.
entries
def
lookup
(
self
,
name
):
try
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment