Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
6ecf77b3
Commit
6ecf77b3
authored
Mar 04, 2012
by
Armin Ronacher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Basic support for PEP 414 without docs or tests.
parent
745ccf8b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
11 deletions
+32
-11
Lib/tokenize.py
Lib/tokenize.py
+22
-8
Parser/tokenizer.c
Parser/tokenizer.c
+7
-3
Python/ast.c
Python/ast.c
+3
-0
No files found.
Lib/tokenize.py
View file @
6ecf77b3
...
@@ -135,10 +135,10 @@ Double = r'[^"\\]*(?:\\.[^"\\]*)*"'
...
@@ -135,10 +135,10 @@ Double = r'[^"\\]*(?:\\.[^"\\]*)*"'
Single3
=
r"[^'\\]*(?:(?:\\.|'(?!''))[^'\\]*)*'''"
Single3
=
r"[^'\\]*(?:(?:\\.|'(?!''))[^'\\]*)*'''"
# Tail end of """ string.
# Tail end of """ string.
Double3
=
r'[^"\\]*(?:(?:\\.|"(?!""))[^"\\]*)*"""'
Double3
=
r'[^"\\]*(?:(?:\\.|"(?!""))[^"\\]*)*"""'
Triple
=
group
(
"[bB
]?[rR]?'''"
,
'[bB
]?[rR]?"""'
)
Triple
=
group
(
"[bB
uU]?[rR]?'''"
,
'[bBuU
]?[rR]?"""'
)
# Single-line ' or " string.
# Single-line ' or " string.
String
=
group
(
r"[bB]?[rR]?'[^\n'\\]*(?:\\.[^\n'\\]*)*'"
,
String
=
group
(
r"[bB
uU
]?[rR]?'[^\n'\\]*(?:\\.[^\n'\\]*)*'"
,
r'[bB]?[rR]?"[^\n"\\]*(?:\\.[^\n"\\]*)*"'
)
r'[bB
uU
]?[rR]?"[^\n"\\]*(?:\\.[^\n"\\]*)*"'
)
# Because of leftmost-then-longest match semantics, be sure to put the
# Because of leftmost-then-longest match semantics, be sure to put the
# longest operators first (e.g., if = came before ==, == would get
# longest operators first (e.g., if = came before ==, == would get
...
@@ -156,9 +156,9 @@ PlainToken = group(Number, Funny, String, Name)
...
@@ -156,9 +156,9 @@ PlainToken = group(Number, Funny, String, Name)
Token = Ignore + PlainToken
Token = Ignore + PlainToken
# First (or only) line of ' or "
string
.
# First (or only) line of ' or "
string
.
ContStr
=
group
(
r"[bB]?[rR]?'[^\n'\\]*(?:\\.[^\n'\\]*)*"
+
ContStr
=
group
(
r"[bB
uU
]?[rR]?'[^\n'\\]*(?:\\.[^\n'\\]*)*"
+
group
(
"'"
,
r'\\\r?\n'
),
group
(
"'"
,
r'\\\r?\n'
),
r'[bB]?[rR]?"[^\n"\\]*(?:\\.[^\n"\\]*)*'
+
r'[bB
uU
]?[rR]?"[^\n"\\]*(?:\\.[^\n"\\]*)*'
+
group
(
'"'
,
r'\\\r?\n'
))
group
(
'"'
,
r'\\\r?\n'
))
PseudoExtras
=
group
(
r'\\\r?\n'
,
Comment
,
Triple
)
PseudoExtras
=
group
(
r'\\\r?\n'
,
Comment
,
Triple
)
PseudoToken
=
Whitespace
+
group
(
PseudoExtras
,
Number
,
Funny
,
ContStr
,
Name
)
PseudoToken
=
Whitespace
+
group
(
PseudoExtras
,
Number
,
Funny
,
ContStr
,
Name
)
...
@@ -176,21 +176,35 @@ endpats = {"'": Single, '"': Double,
...
@@ -176,21 +176,35 @@ endpats = {"'": Single, '"': Double,
"bR'''"
:
Single3
,
'bR"""'
:
Double3
,
"bR'''"
:
Single3
,
'bR"""'
:
Double3
,
"Br'''"
:
Single3
,
'Br"""'
:
Double3
,
"Br'''"
:
Single3
,
'Br"""'
:
Double3
,
"BR'''"
:
Single3
,
'BR"""'
:
Double3
,
"BR'''"
:
Single3
,
'BR"""'
:
Double3
,
'r'
:
None
,
'R'
:
None
,
'b'
:
None
,
'B'
:
None
}
"u'''"
:
Single3
,
'u"""'
:
Double3
,
"ur'''"
:
Single3
,
'ur"""'
:
Double3
,
"R'''"
:
Single3
,
'R"""'
:
Double3
,
"U'''"
:
Single3
,
'U"""'
:
Double3
,
"uR'''"
:
Single3
,
'uR"""'
:
Double3
,
"Ur'''"
:
Single3
,
'Ur"""'
:
Double3
,
"UR'''"
:
Single3
,
'UR"""'
:
Double3
,
'r'
:
None
,
'R'
:
None
,
'b'
:
None
,
'B'
:
None
,
'u'
:
None
,
'U'
:
None
}
triple_quoted
=
{}
triple_quoted
=
{}
for
t
in
(
"'''"
,
'"""'
,
for
t
in
(
"'''"
,
'"""'
,
"r'''"
,
'r"""'
,
"R'''"
,
'R"""'
,
"r'''"
,
'r"""'
,
"R'''"
,
'R"""'
,
"b'''"
,
'b"""'
,
"B'''"
,
'B"""'
,
"b'''"
,
'b"""'
,
"B'''"
,
'B"""'
,
"br'''"
,
'br"""'
,
"Br'''"
,
'Br"""'
,
"br'''"
,
'br"""'
,
"Br'''"
,
'Br"""'
,
"bR'''"
,
'bR"""'
,
"BR'''"
,
'BR"""'
):
"bR'''"
,
'bR"""'
,
"BR'''"
,
'BR"""'
,
"u'''"
,
'u"""'
,
"U'''"
,
'U"""'
,
"ur'''"
,
'ur"""'
,
"Ur'''"
,
'Ur"""'
,
"uR'''"
,
'uR"""'
,
"UR'''"
,
'UR"""'
):
triple_quoted
[
t
]
=
t
triple_quoted
[
t
]
=
t
single_quoted
=
{}
single_quoted
=
{}
for
t
in
(
"'"
,
'"'
,
for
t
in
(
"'"
,
'"'
,
"r'"
,
'r"'
,
"R'"
,
'R"'
,
"r'"
,
'r"'
,
"R'"
,
'R"'
,
"b'"
,
'b"'
,
"B'"
,
'B"'
,
"b'"
,
'b"'
,
"B'"
,
'B"'
,
"br'"
,
'br"'
,
"Br'"
,
'Br"'
,
"br'"
,
'br"'
,
"Br'"
,
'Br"'
,
"bR'"
,
'bR"'
,
"BR'"
,
'BR"'
):
"bR'"
,
'bR"'
,
"BR'"
,
'BR"'
,
"u'"
,
'u"'
,
"U'"
,
'U"'
,
"ur'"
,
'ur"'
,
"Ur'"
,
'Ur"'
,
"uR'"
,
'uR"'
,
"UR'"
,
'UR"'
):
single_quoted
[
t
]
=
t
single_quoted
[
t
]
=
t
tabsize
=
8
tabsize
=
8
...
...
Parser/tokenizer.c
View file @
6ecf77b3
...
@@ -1412,11 +1412,15 @@ tok_get(register struct tok_state *tok, char **p_start, char **p_end)
...
@@ -1412,11 +1412,15 @@ tok_get(register struct tok_state *tok, char **p_start, char **p_end)
/* Identifier (most frequent token!) */
/* Identifier (most frequent token!) */
nonascii
=
0
;
nonascii
=
0
;
if
(
is_potential_identifier_start
(
c
))
{
if
(
is_potential_identifier_start
(
c
))
{
/* Process b"", r"",
br"" and rb
"" */
/* Process b"", r"",
u"", br"", rb"" and ur
"" */
int
saw_b
=
0
,
saw_r
=
0
;
int
saw_b
=
0
,
saw_r
=
0
,
saw_u
=
0
;
while
(
1
)
{
while
(
1
)
{
if
(
!
saw_b
&&
(
c
==
'b'
||
c
==
'B'
))
if
(
!
(
saw_b
||
saw_u
)
&&
(
c
==
'b'
||
c
==
'B'
))
saw_b
=
1
;
saw_b
=
1
;
/* Since this is a backwards compatibility support literal we don't
want to support it in arbitrary order like byte literals. */
else
if
(
!
(
saw_b
||
saw_u
||
saw_r
)
&&
(
c
==
'u'
||
c
==
'U'
))
saw_u
=
1
;
else
if
(
!
saw_r
&&
(
c
==
'r'
||
c
==
'R'
))
else
if
(
!
saw_r
&&
(
c
==
'r'
||
c
==
'R'
))
saw_r
=
1
;
saw_r
=
1
;
else
else
...
...
Python/ast.c
View file @
6ecf77b3
...
@@ -3796,6 +3796,9 @@ parsestr(struct compiling *c, const node *n, int *bytesmode)
...
@@ -3796,6 +3796,9 @@ parsestr(struct compiling *c, const node *n, int *bytesmode)
quote
=
*++
s
;
quote
=
*++
s
;
*
bytesmode
=
1
;
*
bytesmode
=
1
;
}
}
else
if
(
quote
==
'u'
||
quote
==
'U'
)
{
quote
=
*++
s
;
}
else
if
(
quote
==
'r'
||
quote
==
'R'
)
{
else
if
(
quote
==
'r'
||
quote
==
'R'
)
{
quote
=
*++
s
;
quote
=
*++
s
;
rawmode
=
1
;
rawmode
=
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