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
577b5b96
Kaydet (Commit)
577b5b96
authored
Şub 27, 2006
tarafından
Martin v. Löwis
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Create _ast module.
Cleanup Python-ast.c generation.
üst
2086eaf7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
55 additions
and
1 deletion
+55
-1
lib.tex
Doc/lib/lib.tex
+1
-0
libast.tex
Doc/lib/libast.tex
+47
-0
NEWS
Misc/NEWS
+1
-1
config.c.in
Modules/config.c.in
+4
-0
config.c
PC/config.c
+2
-0
asdl_c.py
Parser/asdl_c.py
+0
-0
Python-ast.c
Python/Python-ast.c
+0
-0
No files found.
Doc/lib/lib.tex
Dosyayı görüntüle @
577b5b96
...
...
@@ -416,6 +416,7 @@ and how to embed it in other applications.
\input
{
distutils
}
\input
{
compiler
}
% compiler package
\input
{
libast
}
\input
{
libmisc
}
% Miscellaneous Services
\input
{
libformatter
}
...
...
Doc/lib/libast.tex
0 → 100644
Dosyayı görüntüle @
577b5b96
% XXX Label can't be _ast?
% XXX Where should this section/chapter go?
\chapter
{
Abstract Syntax Trees
\label
{
ast
}}
\sectionauthor
{
Martin v. L
\"
owis
}{
martin@v.loewis.de
}
The
\code
{_
ast
}
module helps Python applications to process
trees of the Python abstract syntax grammar. The Python compiler
currently provides read-only access to such trees, meaning that
applications can only create a tree for a given piece of Python
source code; generating byte code from a (potentially modified)
tree is not supported. The abstract syntax itself might change with
each Python release; this module helps to find out programmatically
what the current grammar looks like.
An abstract syntax tree can be generated by passing
\code
{_
ast.PyCF
_
ONLY
_
AST
}
as a flag to the
\function
{
compile
}
builtin function. The result will be a tree
of objects whose classes all inherit from
\code
{_
ast.AST
}
.
The actual classes are derived from the
\code
{
Parser/Python.asdl
}
file,
which is reproduced below. There is one class defined for each left-hand
side symbol in the abstract grammar (for example,
\code
{_
ast.stmt
}
or
\code
{_
ast.expr
}
).
In addition, there is one class defined for each constructor on the
right-hand side; these classes inherit from the classes for the left-hand
side trees. For example,
\code
{_
ast.BinOp
}
inherits from
\code
{_
ast.expr
}
.
For production rules with alternatives (aka "sums"), the left-hand side
class is abstract: only instances of specific constructor nodes are ever
created.
Each concrete class has an attribute
\code
{_
fields
}
which gives the
names of all child nodes.
Each instance of a concrete class has one attribute for each child node,
of the type as defined in the grammar. For example,
\code
{_
ast.BinOp
}
instances have an attribute
\code
{
left
}
of type
\code
{_
ast.expr
}
.
If these attributes are marked as optional in the grammar (using a
question mark), the value might be
\code
{
None
}
. If the attributes
can have zero-or-more values (marked with an asterisk), the
values are represented as Python lists.
\subsection
{
Abstract Grammar
}
The abstract grammar is currently defined as follows:
\verbatiminput
{
../../Parser/Python.asdl
}
\ No newline at end of file
Misc/NEWS
Dosyayı görüntüle @
577b5b96
...
...
@@ -76,7 +76,7 @@ Core and builtins
- A new AST parser implementation was completed. The abstract
syntax tree is available for read-only (non-compile) access
to Python code.
to Python code
; an _ast module was added
.
- SF bug #1167751: fix incorrect code being for generator expressions.
The following code now raises a SyntaxError: foo(a = i for i in range(10))
...
...
Modules/config.c.in
Dosyayı görüntüle @
577b5b96
...
...
@@ -23,6 +23,7 @@ redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
extern void PyMarshal_Init(void);
extern void initimp(void);
extern void initgc(void);
extern void init_ast(void);
struct _inittab _PyImport_Inittab[] = {
...
...
@@ -34,6 +35,9 @@ struct _inittab _PyImport_Inittab[] = {
/* This lives in import.c */
{"imp", initimp},
/* This lives in Python/Python-ast.c */
{"_ast", init_ast},
/* These entries are here for sys.builtin_module_names */
{"__main__", NULL},
{"__builtin__", NULL},
...
...
PC/config.c
Dosyayı görüntüle @
577b5b96
...
...
@@ -67,6 +67,7 @@ extern void init_codecs_kr(void);
extern
void
init_codecs_tw
(
void
);
extern
void
init_subprocess
(
void
);
extern
void
init_lsprof
(
void
);
extern
void
init_ast
(
void
);
/* tools/freeze/makeconfig.py marker for additional "extern" */
/* -- ADDMODULE MARKER 1 -- */
...
...
@@ -77,6 +78,7 @@ extern void initimp(void);
struct
_inittab
_PyImport_Inittab
[]
=
{
{
"array"
,
initarray
},
{
"_ast"
,
init_ast
},
#ifdef MS_WINDOWS
#ifndef MS_WIN64
{
"audioop"
,
initaudioop
},
...
...
Parser/asdl_c.py
Dosyayı görüntüle @
577b5b96
This diff is collapsed.
Click to expand it.
Python/Python-ast.c
Dosyayı görüntüle @
577b5b96
This diff is collapsed.
Click to expand it.
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