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
923c4eee
Kaydet (Commit)
923c4eee
authored
Eki 06, 1997
tarafından
Fred Drake
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Don't do weird things with the "import parser"; just do it. Sheesh...
üst
a11ccccd
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
11 deletions
+11
-11
AST.py
Lib/AST.py
+11
-11
No files found.
Lib/AST.py
Dosyayı görüntüle @
923c4eee
...
...
@@ -55,13 +55,16 @@ tuple()
"""
__version__
=
'$Revision$'
__copyright__
=
"""Copyright (c) 1995, 1996 by Fred L. Drake, Jr.
__copyright__
=
"""Copyright (c) 1995, 1996
, 1997
by Fred L. Drake, Jr.
This software may be used and distributed freely for any purpose provided
that this notice is included unchanged on any and all copies. The author
does not warrant or guarantee this software in any way.
"""
import
parser
class
AST
:
"""Base class for Abstract Syntax Tree objects.
...
...
@@ -71,9 +74,6 @@ class AST:
This base class provides all of the query methods for subclass
objects defined in this module.
"""
import
parser
# import internally to avoid
_p
=
parser
# namespace pollution at the
# top level
_text
=
None
_code
=
None
_ast
=
None
...
...
@@ -94,8 +94,8 @@ class AST:
raise
TypeError
,
'Base AST class requires tuple parameter.'
self
.
_tupl
=
tuple
self
.
_ast
=
self
.
_p
.
tuple2ast
(
tuple
)
self
.
_type
=
(
self
.
_p
.
isexpr
(
self
.
_ast
)
and
'expression'
)
or
'suite'
self
.
_ast
=
parser
.
tuple2ast
(
tuple
)
self
.
_type
=
(
parser
.
isexpr
(
self
.
_ast
)
and
'expression'
)
or
'suite'
def
list
(
self
,
line_info
=
0
):
"""Returns a fresh list representing the parse tree.
...
...
@@ -104,7 +104,7 @@ class AST:
If true, includes line number information for terminal tokens in
the output data structure,
"""
return
self
.
_p
.
ast2list
(
self
.
_ast
,
line_info
)
return
parser
.
ast2list
(
self
.
_ast
,
line_info
)
def
tuple
(
self
,
line_info
=
0
):
"""Returns the tuple representing the parse tree.
...
...
@@ -114,7 +114,7 @@ class AST:
the output data structure,
"""
if
self
.
_tupl
is
None
:
self
.
_tupl
=
self
.
_p
.
ast2tuple
(
self
.
_ast
,
line_info
)
self
.
_tupl
=
parser
.
ast2tuple
(
self
.
_ast
,
line_info
)
return
self
.
_tupl
def
code
(
self
):
...
...
@@ -126,7 +126,7 @@ class AST:
regarding execution of code objects apply.
"""
if
not
self
.
_code
:
self
.
_code
=
self
.
_p
.
compileast
(
self
.
_ast
)
self
.
_code
=
parser
.
compileast
(
self
.
_ast
)
return
self
.
_code
def
ast
(
self
):
...
...
@@ -180,7 +180,7 @@ class SuiteAST(AST):
if
type
(
text
)
is
not
type
(
''
):
raise
TypeError
,
'SuiteAST requires source text parameter.'
self
.
_text
=
text
self
.
_ast
=
self
.
_p
.
suite
(
text
)
self
.
_ast
=
parser
.
suite
(
text
)
def
isSuite
(
self
):
return
1
...
...
@@ -228,7 +228,7 @@ class ExpressionAST(AST):
if
type
(
text
)
is
not
type
(
''
):
raise
TypeError
,
'ExpressionAST requires source text parameter.'
self
.
_text
=
text
self
.
_ast
=
self
.
_p
.
expr
(
text
)
self
.
_ast
=
parser
.
expr
(
text
)
def
isSuite
(
self
):
return
0
...
...
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