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
cf171a7f
Commit
cf171a7f
authored
Nov 16, 2007
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup of tokenizer.c.
parent
053b4f3a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
61 deletions
+47
-61
Parser/tokenizer.c
Parser/tokenizer.c
+47
-61
No files found.
Parser/tokenizer.c
View file @
cf171a7f
...
@@ -1269,22 +1269,16 @@ tok_get(register struct tok_state *tok, char **p_start, char **p_end)
...
@@ -1269,22 +1269,16 @@ 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 r"", u"" and ur"" */
/* Process b"", r"" and br"" */
switch
(
c
)
{
if
(
c
==
'b'
||
c
==
'B'
)
{
case
'r'
:
case
'R'
:
c
=
tok_nextc
(
tok
);
c
=
tok_nextc
(
tok
);
if
(
c
==
'"'
||
c
==
'\''
)
if
(
c
==
'"'
||
c
==
'\''
)
goto
letter_quote
;
goto
letter_quote
;
break
;
}
case
'b'
:
if
(
c
==
'r'
||
c
==
'R'
)
{
case
'B'
:
c
=
tok_nextc
(
tok
);
if
(
c
==
'r'
||
c
==
'R'
)
c
=
tok_nextc
(
tok
);
c
=
tok_nextc
(
tok
);
if
(
c
==
'"'
||
c
==
'\''
)
if
(
c
==
'"'
||
c
==
'\''
)
goto
letter_quote
;
goto
letter_quote
;
break
;
}
}
while
(
is_potential_identifier_char
(
c
))
{
while
(
is_potential_identifier_char
(
c
))
{
if
(
c
>=
128
)
if
(
c
>=
128
)
...
@@ -1436,55 +1430,47 @@ tok_get(register struct tok_state *tok, char **p_start, char **p_end)
...
@@ -1436,55 +1430,47 @@ tok_get(register struct tok_state *tok, char **p_start, char **p_end)
letter_quote:
letter_quote:
/* String */
/* String */
if
(
c
==
'\''
||
c
==
'"'
)
{
if
(
c
==
'\''
||
c
==
'"'
)
{
Py_ssize_t
quote2
=
tok
->
cur
-
tok
->
start
+
1
;
int
quote
=
c
;
int
quote
=
c
;
int
triple
=
0
;
int
quote_size
=
1
;
/* 1 or 3 */
int
tripcount
=
0
;
int
end_quote_size
=
0
;
for
(;;)
{
/* Find the quote size and start of string */
c
=
tok_nextc
(
tok
);
c
=
tok_nextc
(
tok
);
if
(
c
==
'\n'
)
{
if
(
c
==
quote
)
{
if
(
!
triple
)
{
c
=
tok_nextc
(
tok
);
tok
->
done
=
E_EOLS
;
if
(
c
==
quote
)
tok_backup
(
tok
,
c
);
quote_size
=
3
;
return
ERRORTOKEN
;
else
}
end_quote_size
=
1
;
/* empty string found */
tripcount
=
0
;
tok
->
cont_line
=
1
;
/* multiline string. */
}
}
else
if
(
c
==
EOF
)
{
if
(
c
!=
quote
)
if
(
triple
)
tok_backup
(
tok
,
c
);
/* Get rest of string */
while
(
end_quote_size
!=
quote_size
)
{
c
=
tok_nextc
(
tok
);
if
(
c
==
EOF
)
{
if
(
quote_size
==
3
)
tok
->
done
=
E_EOFS
;
tok
->
done
=
E_EOFS
;
else
else
tok
->
done
=
E_EOLS
;
tok
->
done
=
E_EOLS
;
tok
->
cur
=
tok
->
inp
;
tok
->
cur
=
tok
->
inp
;
return
ERRORTOKEN
;
return
ERRORTOKEN
;
}
}
else
if
(
c
==
quote
)
{
if
(
quote_size
==
1
&&
c
==
'\n'
)
{
tripcount
++
;
if
(
tok
->
cur
-
tok
->
start
==
quote2
)
{
c
=
tok_nextc
(
tok
);
if
(
c
==
quote
)
{
triple
=
1
;
tripcount
=
0
;
continue
;
}
tok_backup
(
tok
,
c
);
}
if
(
!
triple
||
tripcount
==
3
)
break
;
}
else
if
(
c
==
'\\'
)
{
tripcount
=
0
;
c
=
tok_nextc
(
tok
);
if
(
c
==
EOF
)
{
tok
->
done
=
E_EOLS
;
tok
->
done
=
E_EOLS
;
tok
->
cur
=
tok
->
inp
;
tok
->
cur
=
tok
->
inp
;
return
ERRORTOKEN
;
return
ERRORTOKEN
;
}
}
if
(
c
==
quote
)
end_quote_size
+=
1
;
else
{
end_quote_size
=
0
;
if
(
c
==
'\\'
)
c
=
tok_nextc
(
tok
);
/* skip escaped char */
}
}
else
tripcount
=
0
;
}
}
*
p_start
=
tok
->
start
;
*
p_start
=
tok
->
start
;
*
p_end
=
tok
->
cur
;
*
p_end
=
tok
->
cur
;
return
STRING
;
return
STRING
;
...
...
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