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
5dddf11d
Commit
5dddf11d
authored
Feb 09, 2013
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make a couple of parser errors non-fatal to keep parsing
parent
5abdcce5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
20 deletions
+25
-20
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+25
-20
No files found.
Cython/Compiler/Parsing.py
View file @
5dddf11d
...
@@ -349,7 +349,8 @@ def p_yield_expression(s):
...
@@ -349,7 +349,8 @@ def p_yield_expression(s):
arg
=
p_testlist
(
s
)
arg
=
p_testlist
(
s
)
else
:
else
:
if
is_yield_from
:
if
is_yield_from
:
s
.
error
(
"'yield from' requires a source argument"
,
pos
=
pos
)
s
.
error
(
"'yield from' requires a source argument"
,
pos
=
pos
,
fatal
=
False
)
arg
=
None
arg
=
None
if
is_yield_from
:
if
is_yield_from
:
return
ExprNodes
.
YieldFromExprNode
(
pos
,
arg
=
arg
)
return
ExprNodes
.
YieldFromExprNode
(
pos
,
arg
=
arg
)
...
@@ -412,7 +413,7 @@ def p_call_parse_args(s, allow_genexp = True):
...
@@ -412,7 +413,7 @@ def p_call_parse_args(s, allow_genexp = True):
if
s
.
sy
==
'*'
:
if
s
.
sy
==
'*'
:
if
star_arg
:
if
star_arg
:
s
.
error
(
"only one star-arg parameter allowed"
,
s
.
error
(
"only one star-arg parameter allowed"
,
pos
=
s
.
position
())
pos
=
s
.
position
())
s
.
next
()
s
.
next
()
star_arg
=
p_test
(
s
)
star_arg
=
p_test
(
s
)
else
:
else
:
...
@@ -421,18 +422,19 @@ def p_call_parse_args(s, allow_genexp = True):
...
@@ -421,18 +422,19 @@ def p_call_parse_args(s, allow_genexp = True):
s
.
next
()
s
.
next
()
if
not
arg
.
is_name
:
if
not
arg
.
is_name
:
s
.
error
(
"Expected an identifier before '='"
,
s
.
error
(
"Expected an identifier before '='"
,
pos
=
arg
.
pos
)
pos
=
arg
.
pos
)
encoded_name
=
EncodedString
(
arg
.
name
)
encoded_name
=
EncodedString
(
arg
.
name
)
keyword
=
ExprNodes
.
IdentifierStringNode
(
arg
.
pos
,
value
=
encoded_name
)
keyword
=
ExprNodes
.
IdentifierStringNode
(
arg
.
pos
,
value
=
encoded_name
)
arg
=
p_test
(
s
)
arg
=
p_test
(
s
)
keyword_args
.
append
((
keyword
,
arg
))
keyword_args
.
append
((
keyword
,
arg
))
else
:
else
:
if
keyword_args
:
if
keyword_args
:
s
.
error
(
"Non-keyword arg following keyword arg"
,
s
.
error
(
"Non-keyword arg following keyword arg"
,
pos
=
arg
.
pos
)
pos
=
arg
.
pos
)
if
star_arg
:
if
star_arg
:
s
.
error
(
"Non-keyword arg following star-arg"
,
s
.
error
(
"Non-keyword arg following star-arg"
,
pos
=
arg
.
pos
)
pos
=
arg
.
pos
)
positional_args
.
append
(
arg
)
positional_args
.
append
(
arg
)
if
s
.
sy
!=
','
:
if
s
.
sy
!=
','
:
break
break
...
@@ -808,7 +810,8 @@ def p_string_literal(s, kind_override=None):
...
@@ -808,7 +810,8 @@ def p_string_literal(s, kind_override=None):
if
len
(
systr
)
==
4
:
if
len
(
systr
)
==
4
:
chars
.
append_charval
(
int
(
systr
[
2
:],
16
)
)
chars
.
append_charval
(
int
(
systr
[
2
:],
16
)
)
else
:
else
:
s
.
error
(
"Invalid hex escape '%s'"
%
systr
)
s
.
error
(
"Invalid hex escape '%s'"
%
systr
,
fatal
=
False
)
elif
c
in
u'NUu'
and
kind
in
(
'u'
,
''
):
# \uxxxx, \Uxxxxxxxx, \N{...}
elif
c
in
u'NUu'
and
kind
in
(
'u'
,
''
):
# \uxxxx, \Uxxxxxxxx, \N{...}
chrval
=
-
1
chrval
=
-
1
if
c
==
u'N'
:
if
c
==
u'N'
:
...
@@ -823,7 +826,8 @@ def p_string_literal(s, kind_override=None):
...
@@ -823,7 +826,8 @@ def p_string_literal(s, kind_override=None):
s
.
error
(
"Invalid unicode escape '%s'"
%
systr
)
s
.
error
(
"Invalid unicode escape '%s'"
%
systr
)
chrval
=
-
1
chrval
=
-
1
else
:
else
:
s
.
error
(
"Invalid unicode escape '%s'"
%
systr
)
s
.
error
(
"Invalid unicode escape '%s'"
%
systr
,
fatal
=
False
)
if
chrval
>=
0
:
if
chrval
>=
0
:
chars
.
append_uescape
(
chrval
,
systr
)
chars
.
append_uescape
(
chrval
,
systr
)
else
:
else
:
...
@@ -836,10 +840,9 @@ def p_string_literal(s, kind_override=None):
...
@@ -836,10 +840,9 @@ def p_string_literal(s, kind_override=None):
elif
sy
==
'END_STRING'
:
elif
sy
==
'END_STRING'
:
break
break
elif
sy
==
'EOF'
:
elif
sy
==
'EOF'
:
s
.
error
(
"Unclosed string literal"
,
pos
=
pos
)
s
.
error
(
"Unclosed string literal"
,
pos
=
pos
)
else
:
else
:
s
.
error
(
s
.
error
(
"Unexpected token %r:%r in string literal"
%
"Unexpected token %r:%r in string literal"
%
(
sy
,
s
.
systring
))
(
sy
,
s
.
systring
))
if
kind
==
'c'
:
if
kind
==
'c'
:
unicode_value
=
None
unicode_value
=
None
...
@@ -851,7 +854,8 @@ def p_string_literal(s, kind_override=None):
...
@@ -851,7 +854,8 @@ def p_string_literal(s, kind_override=None):
if
is_python3_source
and
has_non_ASCII_literal_characters
:
if
is_python3_source
and
has_non_ASCII_literal_characters
:
# Python 3 forbids literal non-ASCII characters in byte strings
# Python 3 forbids literal non-ASCII characters in byte strings
if
kind
!=
'u'
:
if
kind
!=
'u'
:
s
.
error
(
"bytes can only contain ASCII literal characters."
,
pos
=
pos
)
s
.
error
(
"bytes can only contain ASCII literal characters."
,
pos
=
pos
,
fatal
=
False
)
bytes_value
=
None
bytes_value
=
None
s
.
next
()
s
.
next
()
return
(
kind
,
bytes_value
,
unicode_value
)
return
(
kind
,
bytes_value
,
unicode_value
)
...
@@ -1840,7 +1844,7 @@ def p_statement(s, ctx, first_statement = 0):
...
@@ -1840,7 +1844,7 @@ def p_statement(s, ctx, first_statement = 0):
return
node
return
node
else
:
else
:
if
ctx
.
api
:
if
ctx
.
api
:
s
.
error
(
"'api' not allowed with this statement"
)
s
.
error
(
"'api' not allowed with this statement"
,
fatal
=
False
)
elif
s
.
sy
==
'def'
:
elif
s
.
sy
==
'def'
:
# def statements aren't allowed in pxd files, except
# def statements aren't allowed in pxd files, except
# as part of a cdef class
# as part of a cdef class
...
@@ -1908,7 +1912,7 @@ def p_suite(s, ctx = Ctx(), with_doc = 0, with_pseudo_doc = 0):
...
@@ -1908,7 +1912,7 @@ def p_suite(s, ctx = Ctx(), with_doc = 0, with_pseudo_doc = 0):
s
.
expect_dedent
()
s
.
expect_dedent
()
else
:
else
:
if
ctx
.
api
:
if
ctx
.
api
:
s
.
error
(
"'api' not allowed with this statement"
)
s
.
error
(
"'api' not allowed with this statement"
,
fatal
=
False
)
if
ctx
.
level
in
(
'module'
,
'class'
,
'function'
,
'other'
):
if
ctx
.
level
in
(
'module'
,
'class'
,
'function'
,
'other'
):
body
=
p_simple_statement_list
(
s
,
ctx
)
body
=
p_simple_statement_list
(
s
,
ctx
)
else
:
else
:
...
@@ -1933,7 +1937,7 @@ def p_positional_and_keyword_args(s, end_sy_set, templates = None):
...
@@ -1933,7 +1937,7 @@ def p_positional_and_keyword_args(s, end_sy_set, templates = None):
while
s
.
sy
not
in
end_sy_set
:
while
s
.
sy
not
in
end_sy_set
:
if
s
.
sy
==
'*'
or
s
.
sy
==
'**'
:
if
s
.
sy
==
'*'
or
s
.
sy
==
'**'
:
s
.
error
(
'Argument expansion not allowed here.'
)
s
.
error
(
'Argument expansion not allowed here.'
,
fatal
=
False
)
parsed_type
=
False
parsed_type
=
False
if
s
.
sy
==
'IDENT'
and
s
.
peek
()[
0
]
==
'='
:
if
s
.
sy
==
'IDENT'
and
s
.
peek
()[
0
]
==
'='
:
...
@@ -1966,7 +1970,7 @@ def p_positional_and_keyword_args(s, end_sy_set, templates = None):
...
@@ -1966,7 +1970,7 @@ def p_positional_and_keyword_args(s, end_sy_set, templates = None):
pos_idx
+=
1
pos_idx
+=
1
if
len
(
keyword_args
)
>
0
:
if
len
(
keyword_args
)
>
0
:
s
.
error
(
"Non-keyword arg following keyword arg"
,
s
.
error
(
"Non-keyword arg following keyword arg"
,
pos
=
arg
.
pos
)
pos
=
arg
.
pos
)
if
s
.
sy
!=
','
:
if
s
.
sy
!=
','
:
if
s
.
sy
not
in
end_sy_set
:
if
s
.
sy
not
in
end_sy_set
:
...
@@ -2398,8 +2402,9 @@ def p_c_simple_declarator(s, ctx, empty, is_type, cmethod_flag,
...
@@ -2398,8 +2402,9 @@ def p_c_simple_declarator(s, ctx, empty, is_type, cmethod_flag,
op
+=
s
.
sy
# +=, -=, ...
op
+=
s
.
sy
# +=, -=, ...
s
.
next
()
s
.
next
()
if
op
not
in
supported_overloaded_operators
:
if
op
not
in
supported_overloaded_operators
:
s
.
error
(
"Overloading operator '%s' not yet supported."
%
op
)
s
.
error
(
"Overloading operator '%s' not yet supported."
%
op
,
name
=
name
+
op
fatal
=
False
)
name
+=
op
result
=
Nodes
.
CNameDeclaratorNode
(
pos
,
result
=
Nodes
.
CNameDeclaratorNode
(
pos
,
name
=
name
,
cname
=
cname
,
default
=
rhs
)
name
=
name
,
cname
=
cname
,
default
=
rhs
)
result
.
calling_convention
=
calling_convention
result
.
calling_convention
=
calling_convention
...
@@ -2722,7 +2727,7 @@ def p_visibility(s, prev_visibility):
...
@@ -2722,7 +2727,7 @@ def p_visibility(s, prev_visibility):
visibility
=
s
.
systring
visibility
=
s
.
systring
if
prev_visibility
!=
'private'
and
visibility
!=
prev_visibility
:
if
prev_visibility
!=
'private'
and
visibility
!=
prev_visibility
:
s
.
error
(
"Conflicting visibility options '%s' and '%s'"
s
.
error
(
"Conflicting visibility options '%s' and '%s'"
%
(
prev_visibility
,
visibility
))
%
(
prev_visibility
,
visibility
)
,
fatal
=
False
)
s
.
next
()
s
.
next
()
return
visibility
return
visibility
...
@@ -2925,7 +2930,7 @@ def p_c_class_definition(s, pos, ctx):
...
@@ -2925,7 +2930,7 @@ def p_c_class_definition(s, pos, ctx):
s
.
next
()
s
.
next
()
base_class_path
.
append
(
p_ident
(
s
))
base_class_path
.
append
(
p_ident
(
s
))
if
s
.
sy
==
','
:
if
s
.
sy
==
','
:
s
.
error
(
"C class may only have one base class"
)
s
.
error
(
"C class may only have one base class"
,
fatal
=
False
)
s
.
expect
(
')'
)
s
.
expect
(
')'
)
base_class_module
=
"."
.
join
(
base_class_path
[:
-
1
])
base_class_module
=
"."
.
join
(
base_class_path
[:
-
1
])
base_class_name
=
base_class_path
[
-
1
]
base_class_name
=
base_class_path
[
-
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