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
ffe968b8
Kaydet (Commit)
ffe968b8
authored
Tem 25, 2000
tarafından
Jeremy Hylton
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
This script demonstrates use of the visitor interface of the compiler
package.
üst
9f2550f5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
0 deletions
+38
-0
demo.py
Tools/compiler/demo.py
+38
-0
No files found.
Tools/compiler/demo.py
0 → 100755
Dosyayı görüntüle @
ffe968b8
#! /usr/bin/env python
"""Print names of all methods defined in module
This script demonstrates use of the visitor interface of the compiler
package.
"""
import
compiler
class
MethodFinder
:
"""Print the names of all the methods
Each visit method takes two arguments, the node and its current
scope. The scope is the name of the current class or None.
"""
def
visitClass
(
self
,
node
,
scope
=
None
):
self
.
visit
(
node
.
code
,
node
.
name
)
def
visitFunction
(
self
,
node
,
scope
=
None
):
if
scope
is
not
None
:
print
"
%
s.
%
s"
%
(
scope
,
node
.
name
)
self
.
visit
(
node
.
code
,
None
)
def
main
(
files
):
mf
=
MethodFinder
()
for
file
in
files
:
f
=
open
(
file
)
buf
=
f
.
read
()
f
.
close
()
ast
=
compiler
.
parse
(
buf
)
compiler
.
walk
(
ast
,
mf
)
if
__name__
==
"__main__"
:
import
sys
main
(
sys
.
argv
[
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