Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
254eb538
Kaydet (Commit)
254eb538
authored
Eyl 17, 2002
tarafından
Kurt B. Kaiser
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Merge Py Idle changes:
Rev 1.10 doerwalter (string methods)
üst
d8e20a0e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
27 deletions
+22
-27
PyParse.py
Lib/idlelib/PyParse.py
+22
-27
No files found.
Lib/idlelib/PyParse.py
Dosyayı görüntüle @
254eb538
import
string
import
re
import
re
import
sys
import
sys
...
@@ -7,7 +6,7 @@ C_NONE, C_BACKSLASH, C_STRING, C_BRACKET = range(4)
...
@@ -7,7 +6,7 @@ C_NONE, C_BACKSLASH, C_STRING, C_BRACKET = range(4)
if
0
:
# for throwaway debugging output
if
0
:
# for throwaway debugging output
def
dump
(
*
stuff
):
def
dump
(
*
stuff
):
sys
.
__stdout__
.
write
(
string
.
join
(
map
(
str
,
stuff
),
" "
)
+
"
\n
"
)
sys
.
__stdout__
.
write
(
" "
.
join
(
map
(
str
,
stuff
)
)
+
"
\n
"
)
# Find what looks like the start of a popular stmt.
# Find what looks like the start of a popular stmt.
...
@@ -103,7 +102,7 @@ for ch in ")}]":
...
@@ -103,7 +102,7 @@ for ch in ")}]":
_tran
[
ord
(
ch
)]
=
')'
_tran
[
ord
(
ch
)]
=
')'
for
ch
in
"
\"
'
\\\n
#"
:
for
ch
in
"
\"
'
\\\n
#"
:
_tran
[
ord
(
ch
)]
=
ch
_tran
[
ord
(
ch
)]
=
ch
_tran
=
string
.
join
(
_tran
,
''
)
_tran
=
''
.
join
(
_tran
)
del
ch
del
ch
try
:
try
:
...
@@ -153,13 +152,12 @@ class Parser:
...
@@ -153,13 +152,12 @@ class Parser:
# Python 1.5.2 (#0, Apr 13 1999, ...
# Python 1.5.2 (#0, Apr 13 1999, ...
def
find_good_parse_start
(
self
,
use_ps1
,
is_char_in_string
=
None
,
def
find_good_parse_start
(
self
,
use_ps1
,
is_char_in_string
=
None
,
_rfind
=
string
.
rfind
,
_synchre
=
_synchre
):
_synchre
=
_synchre
):
str
,
pos
=
self
.
str
,
None
str
,
pos
=
self
.
str
,
None
if
use_ps1
:
if
use_ps1
:
# shell window
# shell window
ps1
=
'
\n
'
+
sys
.
ps1
ps1
=
'
\n
'
+
sys
.
ps1
i
=
_rfind
(
str
,
ps1
)
i
=
str
.
rfind
(
ps1
)
if
i
>=
0
:
if
i
>=
0
:
pos
=
i
+
len
(
ps1
)
pos
=
i
+
len
(
ps1
)
# make it look like there's a newline instead
# make it look like there's a newline instead
...
@@ -178,10 +176,10 @@ class Parser:
...
@@ -178,10 +176,10 @@ class Parser:
# bumped to a legitimate synch point.
# bumped to a legitimate synch point.
limit
=
len
(
str
)
limit
=
len
(
str
)
for
tries
in
range
(
5
):
for
tries
in
range
(
5
):
i
=
_rfind
(
str
,
":
\n
"
,
0
,
limit
)
i
=
str
.
rfind
(
":
\n
"
,
0
,
limit
)
if
i
<
0
:
if
i
<
0
:
break
break
i
=
_rfind
(
str
,
'
\n
'
,
0
,
i
)
+
1
# start of colon line
i
=
str
.
rfind
(
'
\n
'
,
0
,
i
)
+
1
# start of colon line
m
=
_synchre
(
str
,
i
,
limit
)
m
=
_synchre
(
str
,
i
,
limit
)
if
m
and
not
is_char_in_string
(
m
.
start
()):
if
m
and
not
is_char_in_string
(
m
.
start
()):
pos
=
m
.
start
()
pos
=
m
.
start
()
...
@@ -226,7 +224,7 @@ class Parser:
...
@@ -226,7 +224,7 @@ class Parser:
# based) of the non-continuation lines.
# based) of the non-continuation lines.
# Creates self.{goodlines, continuation}.
# Creates self.{goodlines, continuation}.
def
_study1
(
self
,
_replace
=
string
.
replace
,
_find
=
string
.
find
):
def
_study1
(
self
):
if
self
.
study_level
>=
1
:
if
self
.
study_level
>=
1
:
return
return
self
.
study_level
=
1
self
.
study_level
=
1
...
@@ -236,12 +234,12 @@ class Parser:
...
@@ -236,12 +234,12 @@ class Parser:
# uninteresting characters. This can cut the number of chars
# uninteresting characters. This can cut the number of chars
# by a factor of 10-40, and so greatly speed the following loop.
# by a factor of 10-40, and so greatly speed the following loop.
str
=
self
.
str
str
=
self
.
str
str
=
str
ing
.
translate
(
str
,
_tran
)
str
=
str
.
translate
(
_tran
)
str
=
_replace
(
str
,
'xxxxxxxx'
,
'x'
)
str
=
str
.
replace
(
'xxxxxxxx'
,
'x'
)
str
=
_replace
(
str
,
'xxxx'
,
'x'
)
str
=
str
.
replace
(
'xxxx'
,
'x'
)
str
=
_replace
(
str
,
'xx'
,
'x'
)
str
=
str
.
replace
(
'xx'
,
'x'
)
str
=
_replace
(
str
,
'xx'
,
'x'
)
str
=
str
.
replace
(
'xx'
,
'x'
)
str
=
_replace
(
str
,
'
\n
x'
,
'
\n
'
)
str
=
str
.
replace
(
'
\n
x'
,
'
\n
'
)
# note that replacing x\n with \n would be incorrect, because
# note that replacing x\n with \n would be incorrect, because
# x may be preceded by a backslash
# x may be preceded by a backslash
...
@@ -322,7 +320,7 @@ class Parser:
...
@@ -322,7 +320,7 @@ class Parser:
if
ch
==
'#'
:
if
ch
==
'#'
:
# consume the comment
# consume the comment
i
=
_find
(
str
,
'
\n
'
,
i
)
i
=
str
.
find
(
'
\n
'
,
i
)
assert
i
>=
0
assert
i
>=
0
continue
continue
...
@@ -363,8 +361,7 @@ class Parser:
...
@@ -363,8 +361,7 @@ class Parser:
# self.lastopenbracketpos
# self.lastopenbracketpos
# if continuation is C_BRACKET, index of last open bracket
# if continuation is C_BRACKET, index of last open bracket
def
_study2
(
self
,
_rfind
=
string
.
rfind
,
_find
=
string
.
find
,
def
_study2
(
self
):
_ws
=
string
.
whitespace
):
if
self
.
study_level
>=
2
:
if
self
.
study_level
>=
2
:
return
return
self
.
_study1
()
self
.
_study1
()
...
@@ -381,7 +378,7 @@ class Parser:
...
@@ -381,7 +378,7 @@ class Parser:
q
=
p
q
=
p
for
nothing
in
range
(
goodlines
[
i
-
1
],
goodlines
[
i
]):
for
nothing
in
range
(
goodlines
[
i
-
1
],
goodlines
[
i
]):
# tricky: sets p to 0 if no preceding newline
# tricky: sets p to 0 if no preceding newline
p
=
_rfind
(
str
,
'
\n
'
,
0
,
p
-
1
)
+
1
p
=
str
.
rfind
(
'
\n
'
,
0
,
p
-
1
)
+
1
# The stmt str[p:q] isn't a continuation, but may be blank
# The stmt str[p:q] isn't a continuation, but may be blank
# or a non-indenting comment line.
# or a non-indenting comment line.
if
_junkre
(
str
,
p
):
if
_junkre
(
str
,
p
):
...
@@ -444,7 +441,7 @@ class Parser:
...
@@ -444,7 +441,7 @@ class Parser:
if
ch
==
'#'
:
if
ch
==
'#'
:
# consume comment and trailing newline
# consume comment and trailing newline
p
=
_find
(
str
,
'
\n
'
,
p
,
q
)
+
1
p
=
str
.
find
(
'
\n
'
,
p
,
q
)
+
1
assert
p
>
0
assert
p
>
0
continue
continue
...
@@ -465,13 +462,13 @@ class Parser:
...
@@ -465,13 +462,13 @@ class Parser:
# Assuming continuation is C_BRACKET, return the number
# Assuming continuation is C_BRACKET, return the number
# of spaces the next line should be indented.
# of spaces the next line should be indented.
def
compute_bracket_indent
(
self
,
_find
=
string
.
find
):
def
compute_bracket_indent
(
self
):
self
.
_study2
()
self
.
_study2
()
assert
self
.
continuation
==
C_BRACKET
assert
self
.
continuation
==
C_BRACKET
j
=
self
.
lastopenbracketpos
j
=
self
.
lastopenbracketpos
str
=
self
.
str
str
=
self
.
str
n
=
len
(
str
)
n
=
len
(
str
)
origi
=
i
=
str
ing
.
rfind
(
str
,
'
\n
'
,
0
,
j
)
+
1
origi
=
i
=
str
.
rfind
(
'
\n
'
,
0
,
j
)
+
1
j
=
j
+
1
# one beyond open bracket
j
=
j
+
1
# one beyond open bracket
# find first list item; set i to start of its line
# find first list item; set i to start of its line
while
j
<
n
:
while
j
<
n
:
...
@@ -482,7 +479,7 @@ class Parser:
...
@@ -482,7 +479,7 @@ class Parser:
break
break
else
:
else
:
# this line is junk; advance to next line
# this line is junk; advance to next line
i
=
j
=
_find
(
str
,
'
\n
'
,
j
)
+
1
i
=
j
=
str
.
find
(
'
\n
'
,
j
)
+
1
else
:
else
:
# nothing interesting follows the bracket;
# nothing interesting follows the bracket;
# reproduce the bracket line's indentation + a level
# reproduce the bracket line's indentation + a level
...
@@ -490,8 +487,7 @@ class Parser:
...
@@ -490,8 +487,7 @@ class Parser:
while
str
[
j
]
in
"
\t
"
:
while
str
[
j
]
in
"
\t
"
:
j
=
j
+
1
j
=
j
+
1
extra
=
self
.
indentwidth
extra
=
self
.
indentwidth
return
len
(
string
.
expandtabs
(
str
[
i
:
j
],
return
len
(
str
[
i
:
j
]
.
expandtabs
(
self
.
tabwidth
))
+
extra
self
.
tabwidth
))
+
extra
# Return number of physical lines in last stmt (whether or not
# Return number of physical lines in last stmt (whether or not
# it's an interesting stmt! this is intended to be called when
# it's an interesting stmt! this is intended to be called when
...
@@ -517,7 +513,7 @@ class Parser:
...
@@ -517,7 +513,7 @@ class Parser:
# See whether the initial line starts an assignment stmt; i.e.,
# See whether the initial line starts an assignment stmt; i.e.,
# look for an = operator
# look for an = operator
endpos
=
str
ing
.
find
(
str
,
'
\n
'
,
startpos
)
+
1
endpos
=
str
.
find
(
'
\n
'
,
startpos
)
+
1
found
=
level
=
0
found
=
level
=
0
while
i
<
endpos
:
while
i
<
endpos
:
ch
=
str
[
i
]
ch
=
str
[
i
]
...
@@ -553,8 +549,7 @@ class Parser:
...
@@ -553,8 +549,7 @@ class Parser:
while
str
[
i
]
not
in
"
\t\n
"
:
while
str
[
i
]
not
in
"
\t\n
"
:
i
=
i
+
1
i
=
i
+
1
return
len
(
string
.
expandtabs
(
str
[
self
.
stmt_start
:
return
len
(
str
[
self
.
stmt_start
:
i
]
.
expandtabs
(
\
i
],
self
.
tabwidth
))
+
1
self
.
tabwidth
))
+
1
# Return the leading whitespace on the initial line of the last
# Return the leading whitespace on the initial line of the last
...
...
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