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
Boxiang Sun
cython
Commits
d3e1ddfc
Commit
d3e1ddfc
authored
May 28, 2008
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Accept new for-from syntax.
parent
2eb59542
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
11 deletions
+21
-11
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+16
-11
tests/compile/forfromelse.pyx
tests/compile/forfromelse.pyx
+5
-0
No files found.
Cython/Compiler/Parsing.py
View file @
d3e1ddfc
...
@@ -1080,9 +1080,13 @@ def p_for_bounds(s):
...
@@ -1080,9 +1080,13 @@ def p_for_bounds(s):
s
.
next
()
s
.
next
()
iterator
=
p_for_iterator
(
s
)
iterator
=
p_for_iterator
(
s
)
return
{
'target'
:
target
,
'iterator'
:
iterator
}
return
{
'target'
:
target
,
'iterator'
:
iterator
}
elif
s
.
sy
==
'from'
:
else
:
if
s
.
sy
==
'from'
:
s
.
next
()
s
.
next
()
bound1
=
p_bit_expr
(
s
)
bound1
=
p_bit_expr
(
s
)
else
:
# Support shorter "for a <= x < b" syntax
bound1
,
target
=
target
,
None
rel1
=
p_for_from_relation
(
s
)
rel1
=
p_for_from_relation
(
s
)
name2_pos
=
s
.
position
()
name2_pos
=
s
.
position
()
name2
=
p_ident
(
s
)
name2
=
p_ident
(
s
)
...
@@ -1090,6 +1094,9 @@ def p_for_bounds(s):
...
@@ -1090,6 +1094,9 @@ def p_for_bounds(s):
rel2
=
p_for_from_relation
(
s
)
rel2
=
p_for_from_relation
(
s
)
bound2
=
p_bit_expr
(
s
)
bound2
=
p_bit_expr
(
s
)
step
=
p_for_from_step
(
s
)
step
=
p_for_from_step
(
s
)
if
target
is
None
:
target
=
ExprNodes
.
NameNode
(
name2_pos
,
name
=
name2
)
else
:
if
not
target
.
is_name
:
if
not
target
.
is_name
:
error
(
target
.
pos
,
error
(
target
.
pos
,
"Target of for-from statement must be a variable name"
)
"Target of for-from statement must be a variable name"
)
...
@@ -1105,8 +1112,6 @@ def p_for_bounds(s):
...
@@ -1105,8 +1112,6 @@ def p_for_bounds(s):
'relation2'
:
rel2
,
'relation2'
:
rel2
,
'bound2'
:
bound2
,
'bound2'
:
bound2
,
'step'
:
step
}
'step'
:
step
}
else
:
s
.
error
(
"Expected 'in' or 'from'"
)
def
p_for_from_relation
(
s
):
def
p_for_from_relation
(
s
):
if
s
.
sy
in
inequality_relations
:
if
s
.
sy
in
inequality_relations
:
...
...
tests/compile/forfromelse.pyx
View file @
d3e1ddfc
...
@@ -5,3 +5,8 @@ cdef void spam():
...
@@ -5,3 +5,8 @@ cdef void spam():
else
:
else
:
k
=
j
k
=
j
# new syntax
for
0
<=
i
<
10
:
j
=
i
else
:
j
=
k
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