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
c0fb8492
Commit
c0fb8492
authored
Feb 09, 2010
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify p_positional_and_keyword_args with s.peek()
parent
69160834
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
21 deletions
+14
-21
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+14
-21
No files found.
Cython/Compiler/Parsing.py
View file @
c0fb8492
...
@@ -1747,15 +1747,10 @@ def p_positional_and_keyword_args(s, end_sy_set, type_positions=(), type_keyword
...
@@ -1747,15 +1747,10 @@ def p_positional_and_keyword_args(s, end_sy_set, type_positions=(), type_keyword
was_keyword
=
False
was_keyword
=
False
parsed_type
=
False
parsed_type
=
False
if
s
.
sy
==
'IDENT'
:
if
s
.
sy
==
'IDENT'
and
s
.
peek
()[
0
]
==
'='
:
# Since we can have either types or expressions as positional args,
# we use a strategy of looking an extra step forward for a '=' and
# if it is a positional arg we backtrack.
ident
=
s
.
systring
ident
=
s
.
systring
s
.
next
()
# s.sy is '='
s
.
next
()
s
.
next
()
if
s
.
sy
==
'='
:
s
.
next
()
# Is keyword arg
if
type_keywords
is
None
or
ident
in
type_keywords
:
if
type_keywords
is
None
or
ident
in
type_keywords
:
base_type
=
p_c_base_type
(
s
)
base_type
=
p_c_base_type
(
s
)
declarator
=
p_c_declarator
(
s
,
empty
=
1
)
declarator
=
p_c_declarator
(
s
,
empty
=
1
)
...
@@ -1768,10 +1763,8 @@ def p_positional_and_keyword_args(s, end_sy_set, type_positions=(), type_keyword
...
@@ -1768,10 +1763,8 @@ def p_positional_and_keyword_args(s, end_sy_set, type_positions=(), type_keyword
arg
.
pos
,
value
=
EncodedString
(
ident
))
arg
.
pos
,
value
=
EncodedString
(
ident
))
keyword_args
.
append
((
keyword_node
,
arg
))
keyword_args
.
append
((
keyword_node
,
arg
))
was_keyword
=
True
was_keyword
=
True
else
:
s
.
put_back
(
'IDENT'
,
ident
)
if
not
was_keyword
:
else
:
if
type_positions
is
None
or
pos_idx
in
type_positions
:
if
type_positions
is
None
or
pos_idx
in
type_positions
:
base_type
=
p_c_base_type
(
s
)
base_type
=
p_c_base_type
(
s
)
declarator
=
p_c_declarator
(
s
,
empty
=
1
)
declarator
=
p_c_declarator
(
s
,
empty
=
1
)
...
...
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