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
9eefda4b
Commit
9eefda4b
authored
May 17, 2008
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
enable ur'abc' literals and b'abc'/br'abc' literals
parent
0e875775
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
14 deletions
+21
-14
Cython/Compiler/Lexicon.py
Cython/Compiler/Lexicon.py
+3
-3
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+12
-8
Cython/Compiler/Scanning.py
Cython/Compiler/Scanning.py
+3
-1
tests/run/append.pyx
tests/run/append.pyx
+3
-2
No files found.
Cython/Compiler/Lexicon.py
View file @
9eefda4b
...
@@ -5,7 +5,8 @@
...
@@ -5,7 +5,8 @@
# to be rebuilt next time pyrexc is run.
# to be rebuilt next time pyrexc is run.
#
#
string_prefixes
=
"cCrRuU"
raw_prefixes
=
"rR"
string_prefixes
=
"cCuUbB"
def
make_lexicon
():
def
make_lexicon
():
from
Cython.Plex
import
\
from
Cython.Plex
import
\
...
@@ -55,9 +56,8 @@ def make_lexicon():
...
@@ -55,9 +56,8 @@ def make_lexicon():
+
Rep
(
non_dq
|
(
Str
(
'"'
)
+
non_dq
)
|
(
Str
(
'""'
)
+
non_dq
))
+
Rep
(
non_dq
|
(
Str
(
'"'
)
+
non_dq
)
|
(
Str
(
'""'
)
+
non_dq
))
+
Str
(
'"""'
)
+
Str
(
'"""'
)
)
)
stringlit
=
Opt
(
Any
(
string_prefixes
))
+
(
sq_string
|
dq_string
|
tsq_string
|
tdq_string
)
beginstring
=
Opt
(
Any
(
string_prefixes
))
+
(
Str
(
"'"
)
|
Str
(
'"'
)
|
Str
(
"'''"
)
|
Str
(
'"""'
))
beginstring
=
Opt
(
Any
(
string_prefixes
))
+
Opt
(
Any
(
raw_prefixes
))
+
(
Str
(
"'"
)
|
Str
(
'"'
)
|
Str
(
"'''"
)
|
Str
(
'"""'
))
two_oct
=
octdigit
+
octdigit
two_oct
=
octdigit
+
octdigit
three_oct
=
octdigit
+
octdigit
+
octdigit
three_oct
=
octdigit
+
octdigit
+
octdigit
two_hex
=
hexdigit
+
hexdigit
two_hex
=
hexdigit
+
hexdigit
...
...
Cython/Compiler/Parsing.py
View file @
9eefda4b
...
@@ -512,7 +512,7 @@ def p_name(s, name):
...
@@ -512,7 +512,7 @@ def p_name(s, name):
def
p_cat_string_literal
(
s
):
def
p_cat_string_literal
(
s
):
# A sequence of one or more adjacent string literals.
# A sequence of one or more adjacent string literals.
# Returns (kind, value) where kind in ('
', 'c', 'r
', 'u')
# Returns (kind, value) where kind in ('
b', 'c
', 'u')
kind
,
value
=
p_string_literal
(
s
)
kind
,
value
=
p_string_literal
(
s
)
if
kind
!=
'c'
:
if
kind
!=
'c'
:
strings
=
[
value
]
strings
=
[
value
]
...
@@ -537,19 +537,23 @@ def p_opt_string_literal(s):
...
@@ -537,19 +537,23 @@ def p_opt_string_literal(s):
def
p_string_literal
(
s
):
def
p_string_literal
(
s
):
# A single string or char literal.
# A single string or char literal.
# Returns (kind, value) where kind in ('
', 'c', 'r
', 'u')
# Returns (kind, value) where kind in ('
b', 'c
', 'u')
# s.sy == 'BEGIN_STRING'
# s.sy == 'BEGIN_STRING'
pos
=
s
.
position
()
pos
=
s
.
position
()
#is_raw = s.systring[:1].lower() == "r"
is_raw
=
0
kind
=
s
.
systring
[:
1
].
lower
()
kind
=
s
.
systring
[:
1
].
lower
()
if
kind
not
in
"cru"
:
if
kind
==
'r'
:
kind
=
''
is_raw
=
1
elif
kind
in
'ub'
:
is_raw
=
s
.
systring
[
1
:
2
].
lower
()
==
'r'
elif
kind
!=
'c'
:
kind
=
''
kind
=
''
if
Future
.
unicode_literals
in
s
.
context
.
future_directives
:
if
Future
.
unicode_literals
in
s
.
context
.
future_directives
:
if
kind
==
''
:
if
kind
==
''
:
kind
=
'u'
kind
=
'u'
elif
kind
==
'u'
:
elif
kind
==
''
:
s
.
error
(
"string literal must not start with 'u' when importing __future__.unicode_literals"
)
kind
=
'b'
return
(
'u'
,
''
)
chars
=
[]
chars
=
[]
while
1
:
while
1
:
s
.
next
()
s
.
next
()
...
@@ -562,7 +566,7 @@ def p_string_literal(s):
...
@@ -562,7 +566,7 @@ def p_string_literal(s):
chars
.
append
(
systr
)
chars
.
append
(
systr
)
elif
sy
==
'ESCAPE'
:
elif
sy
==
'ESCAPE'
:
systr
=
s
.
systring
systr
=
s
.
systring
if
kind
==
'r'
:
if
is_raw
:
if
systr
==
'
\
\
\
n
'
:
if
systr
==
'
\
\
\
n
'
:
chars
.
append
(
r'\\\n'
)
chars
.
append
(
r'\\\n'
)
elif
systr
==
r'\"'
:
elif
systr
==
r'\"'
:
...
...
Cython/Compiler/Scanning.py
View file @
9eefda4b
...
@@ -15,7 +15,7 @@ from Cython import Plex, Utils
...
@@ -15,7 +15,7 @@ from Cython import Plex, Utils
from
Cython.Plex
import
Scanner
from
Cython.Plex
import
Scanner
from
Cython.Plex.Errors
import
UnrecognizedInput
from
Cython.Plex.Errors
import
UnrecognizedInput
from
Errors
import
CompileError
,
error
from
Errors
import
CompileError
,
error
from
Lexicon
import
string_prefixes
,
make_lexicon
from
Lexicon
import
string_prefixes
,
raw_prefixes
,
make_lexicon
plex_version
=
getattr
(
Plex
,
'_version'
,
None
)
plex_version
=
getattr
(
Plex
,
'_version'
,
None
)
#print "Plex version:", plex_version ###
#print "Plex version:", plex_version ###
...
@@ -262,6 +262,8 @@ class PyrexScanner(Scanner):
...
@@ -262,6 +262,8 @@ class PyrexScanner(Scanner):
def
begin_string_action
(
self
,
text
):
def
begin_string_action
(
self
,
text
):
if
text
[:
1
]
in
string_prefixes
:
if
text
[:
1
]
in
string_prefixes
:
text
=
text
[
1
:]
text
=
text
[
1
:]
if
text
[:
1
]
in
raw_prefixes
:
text
=
text
[
1
:]
self
.
begin
(
self
.
string_states
[
text
])
self
.
begin
(
self
.
string_states
[
text
])
self
.
produce
(
'BEGIN_STRING'
)
self
.
produce
(
'BEGIN_STRING'
)
...
...
tests/run/append.pyx
View file @
9eefda4b
...
@@ -25,11 +25,12 @@ class A:
...
@@ -25,11 +25,12 @@ class A:
def
append
(
self
,
x
):
def
append
(
self
,
x
):
print
u"appending"
print
u"appending"
return
x
return
x
class
B
(
list
):
class
B
(
list
):
def
append
(
self
,
*
args
):
def
append
(
self
,
*
args
):
append
=
super
(
B
,
self
).
append
for
arg
in
args
:
for
arg
in
args
:
list
.
append
(
self
,
arg
)
append
(
arg
)
def
test_append
(
L
):
def
test_append
(
L
):
print
L
.
append
(
1
)
print
L
.
append
(
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