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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
63eabf72
Commit
63eabf72
authored
May 19, 2008
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make imported names behave like identifiers, too
parent
c5da19ce
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
11 deletions
+8
-11
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+5
-8
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+3
-3
No files found.
Cython/Compiler/Parsing.py
View file @
63eabf72
...
@@ -284,7 +284,7 @@ def p_call(s, function):
...
@@ -284,7 +284,7 @@ def p_call(s, function):
s
.
error
(
"Expected an identifier before '='"
,
s
.
error
(
"Expected an identifier before '='"
,
pos
=
arg
.
pos
)
pos
=
arg
.
pos
)
encoded_name
=
Utils
.
EncodedString
(
arg
.
name
)
encoded_name
=
Utils
.
EncodedString
(
arg
.
name
)
keyword
=
ExprNodes
.
KeywordName
Node
(
arg
.
pos
,
keyword
=
ExprNodes
.
IdentifierString
Node
(
arg
.
pos
,
value
=
encoded_name
)
value
=
encoded_name
)
arg
=
p_simple_expr
(
s
)
arg
=
p_simple_expr
(
s
)
keyword_args
.
append
((
keyword
,
arg
))
keyword_args
.
append
((
keyword
,
arg
))
...
@@ -926,8 +926,8 @@ def p_import_statement(s):
...
@@ -926,8 +926,8 @@ def p_import_statement(s):
lhs
=
ExprNodes
.
NameNode
(
pos
,
lhs
=
ExprNodes
.
NameNode
(
pos
,
name
=
as_name
or
target_name
),
name
=
as_name
or
target_name
),
rhs
=
ExprNodes
.
ImportNode
(
pos
,
rhs
=
ExprNodes
.
ImportNode
(
pos
,
module_name
=
ExprNodes
.
StringNode
(
pos
,
module_name
=
ExprNodes
.
IdentifierStringNode
(
value
=
dotted_name
),
pos
,
value
=
dotted_name
),
name_list
=
name_list
))
name_list
=
name_list
))
stats
.
append
(
stat
)
stats
.
append
(
stat
)
return
Nodes
.
StatListNode
(
pos
,
stats
=
stats
)
return
Nodes
.
StatListNode
(
pos
,
stats
=
stats
)
...
@@ -974,9 +974,8 @@ def p_from_import_statement(s, first_statement = 0):
...
@@ -974,9 +974,8 @@ def p_from_import_statement(s, first_statement = 0):
items
=
[]
items
=
[]
for
(
name_pos
,
name
,
as_name
)
in
imported_names
:
for
(
name_pos
,
name
,
as_name
)
in
imported_names
:
encoded_name
=
Utils
.
EncodedString
(
name
)
encoded_name
=
Utils
.
EncodedString
(
name
)
encoded_name
.
encoding
=
s
.
source_encoding
imported_name_strings
.
append
(
imported_name_strings
.
append
(
ExprNodes
.
StringNode
(
name_pos
,
value
=
encoded_name
))
ExprNodes
.
Identifier
StringNode
(
name_pos
,
value
=
encoded_name
))
items
.
append
(
items
.
append
(
(
name
,
(
name
,
ExprNodes
.
NameNode
(
name_pos
,
ExprNodes
.
NameNode
(
name_pos
,
...
@@ -984,11 +983,9 @@ def p_from_import_statement(s, first_statement = 0):
...
@@ -984,11 +983,9 @@ def p_from_import_statement(s, first_statement = 0):
import_list
=
ExprNodes
.
ListNode
(
import_list
=
ExprNodes
.
ListNode
(
imported_names
[
0
][
0
],
args
=
imported_name_strings
)
imported_names
[
0
][
0
],
args
=
imported_name_strings
)
dotted_name
=
Utils
.
EncodedString
(
dotted_name
)
dotted_name
=
Utils
.
EncodedString
(
dotted_name
)
dotted_name
.
encoding
=
s
.
source_encoding
return
Nodes
.
FromImportStatNode
(
pos
,
return
Nodes
.
FromImportStatNode
(
pos
,
module
=
ExprNodes
.
ImportNode
(
dotted_name_pos
,
module
=
ExprNodes
.
ImportNode
(
dotted_name_pos
,
module_name
=
ExprNodes
.
StringNode
(
dotted_name_pos
,
module_name
=
ExprNodes
.
IdentifierStringNode
(
pos
,
value
=
dotted_name
),
value
=
dotted_name
),
name_list
=
import_list
),
name_list
=
import_list
),
items
=
items
)
items
=
items
)
...
...
Cython/Compiler/Symtab.py
View file @
63eabf72
...
@@ -464,7 +464,7 @@ class Scope:
...
@@ -464,7 +464,7 @@ class Scope:
string_map[value] = entry
string_map[value] = entry
return entry
return entry
def add_py_string(self, entry):
def add_py_string(self, entry
, identifier = None
):
# If not already done, allocate a C name for a Python version of
# If not already done, allocate a C name for a Python version of
# a string literal, and add it to the list of Python strings to
# a string literal, and add it to the list of Python strings to
# be created at module init time. If the string resembles a
# be created at module init time. If the string resembles a
...
@@ -475,7 +475,7 @@ class Scope:
...
@@ -475,7 +475,7 @@ class Scope:
entry.pystring_cname = entry.cname + "
p
"
entry.pystring_cname = entry.cname + "
p
"
self.pystring_entries.append(entry)
self.pystring_entries.append(entry)
self.global_scope().all_pystring_entries.append(entry)
self.global_scope().all_pystring_entries.append(entry)
if
possible_identifier(value
):
if
identifier or (identifier is None and possible_identifier(value)
):
entry.is_interned = 1
entry.is_interned = 1
self.global_scope().new_interned_string_entries.append(entry)
self.global_scope().new_interned_string_entries.append(entry)
...
@@ -751,7 +751,7 @@ class ModuleScope(Scope):
...
@@ -751,7 +751,7 @@ class ModuleScope(Scope):
def intern_identifier(self, name):
def intern_identifier(self, name):
string_entry = self.get_string_const(name, identifier = True)
string_entry = self.get_string_const(name, identifier = True)
self.add_py_string(string_entry)
self.add_py_string(string_entry
, identifier = 1
)
return string_entry.pystring_cname
return string_entry.pystring_cname
def find_module(self, module_name, pos):
def find_module(self, module_name, pos):
...
...
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