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
5c33d86b
Kaydet (Commit)
5c33d86b
authored
Haz 07, 2009
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
use booleans for flags
üst
dea29d0c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
19 deletions
+19
-19
asdl.py
Parser/asdl.py
+9
-9
asdl_c.py
Parser/asdl_c.py
+10
-10
No files found.
Parser/asdl.py
Dosyayı görüntüle @
5c33d86b
...
@@ -204,19 +204,19 @@ class ASDLParser(spark.GenericParser, object):
...
@@ -204,19 +204,19 @@ class ASDLParser(spark.GenericParser, object):
def
p_field_2
(
self
,
(
type
,
_
,
name
)):
def
p_field_2
(
self
,
(
type
,
_
,
name
)):
" field ::= Id * Id "
" field ::= Id * Id "
return
Field
(
type
,
name
,
seq
=
1
)
return
Field
(
type
,
name
,
seq
=
True
)
def
p_field_3
(
self
,
(
type
,
_
,
name
)):
def
p_field_3
(
self
,
(
type
,
_
,
name
)):
" field ::= Id ? Id "
" field ::= Id ? Id "
return
Field
(
type
,
name
,
opt
=
1
)
return
Field
(
type
,
name
,
opt
=
True
)
def
p_field_4
(
self
,
(
type
,
_
)):
def
p_field_4
(
self
,
(
type
,
_
)):
" field ::= Id * "
" field ::= Id * "
return
Field
(
type
,
seq
=
1
)
return
Field
(
type
,
seq
=
True
)
def
p_field_5
(
self
,
(
type
,
_
)):
def
p_field_5
(
self
,
(
type
,
_
)):
" field ::= Id ? "
" field ::= Id ? "
return
Field
(
type
,
opt
=
1
)
return
Field
(
type
,
opt
=
True
)
builtin_types
=
(
"identifier"
,
"string"
,
"int"
,
"bool"
,
"object"
)
builtin_types
=
(
"identifier"
,
"string"
,
"int"
,
"bool"
,
"object"
)
...
@@ -256,7 +256,7 @@ class Constructor(AST):
...
@@ -256,7 +256,7 @@ class Constructor(AST):
return
"Constructor(
%
s,
%
s)"
%
(
self
.
name
,
self
.
fields
)
return
"Constructor(
%
s,
%
s)"
%
(
self
.
name
,
self
.
fields
)
class
Field
(
AST
):
class
Field
(
AST
):
def
__init__
(
self
,
type
,
name
=
None
,
seq
=
0
,
opt
=
0
):
def
__init__
(
self
,
type
,
name
=
None
,
seq
=
False
,
opt
=
False
):
self
.
type
=
type
self
.
type
=
type
self
.
name
=
name
self
.
name
=
name
self
.
seq
=
seq
self
.
seq
=
seq
...
@@ -264,9 +264,9 @@ class Field(AST):
...
@@ -264,9 +264,9 @@ class Field(AST):
def
__repr__
(
self
):
def
__repr__
(
self
):
if
self
.
seq
:
if
self
.
seq
:
extra
=
", seq=
1
"
extra
=
", seq=
True
"
elif
self
.
opt
:
elif
self
.
opt
:
extra
=
", opt=
1
"
extra
=
", opt=
True
"
else
:
else
:
extra
=
""
extra
=
""
if
self
.
name
is
None
:
if
self
.
name
is
None
:
...
@@ -294,7 +294,7 @@ class Product(AST):
...
@@ -294,7 +294,7 @@ class Product(AST):
class
VisitorBase
(
object
):
class
VisitorBase
(
object
):
def
__init__
(
self
,
skip
=
0
):
def
__init__
(
self
,
skip
=
False
):
self
.
cache
=
{}
self
.
cache
=
{}
self
.
skip
=
skip
self
.
skip
=
skip
...
@@ -329,7 +329,7 @@ class VisitorBase(object):
...
@@ -329,7 +329,7 @@ class VisitorBase(object):
class
Check
(
VisitorBase
):
class
Check
(
VisitorBase
):
def
__init__
(
self
):
def
__init__
(
self
):
super
(
Check
,
self
)
.
__init__
(
skip
=
1
)
super
(
Check
,
self
)
.
__init__
(
skip
=
True
)
self
.
cons
=
{}
self
.
cons
=
{}
self
.
errors
=
0
self
.
errors
=
0
self
.
types
=
{}
self
.
types
=
{}
...
...
Parser/asdl_c.py
Dosyayı görüntüle @
5c33d86b
...
@@ -86,7 +86,7 @@ class EmitVisitor(asdl.VisitorBase):
...
@@ -86,7 +86,7 @@ class EmitVisitor(asdl.VisitorBase):
self
.
file
=
file
self
.
file
=
file
super
(
EmitVisitor
,
self
)
.
__init__
()
super
(
EmitVisitor
,
self
)
.
__init__
()
def
emit
(
self
,
s
,
depth
,
reflow
=
1
):
def
emit
(
self
,
s
,
depth
,
reflow
=
True
):
# XXX reflow long lines?
# XXX reflow long lines?
if
reflow
:
if
reflow
:
lines
=
reflow_lines
(
s
,
depth
)
lines
=
reflow_lines
(
s
,
depth
)
...
@@ -255,7 +255,7 @@ class PrototypeVisitor(EmitVisitor):
...
@@ -255,7 +255,7 @@ class PrototypeVisitor(EmitVisitor):
ctype
=
get_c_type
(
type
)
ctype
=
get_c_type
(
type
)
self
.
emit_function
(
cons
.
name
,
ctype
,
args
,
attrs
)
self
.
emit_function
(
cons
.
name
,
ctype
,
args
,
attrs
)
def
emit_function
(
self
,
name
,
ctype
,
args
,
attrs
,
union
=
1
):
def
emit_function
(
self
,
name
,
ctype
,
args
,
attrs
,
union
=
True
):
args
=
args
+
attrs
args
=
args
+
attrs
if
args
:
if
args
:
argstr
=
", "
.
join
([
"
%
s
%
s"
%
(
atype
,
aname
)
argstr
=
", "
.
join
([
"
%
s
%
s"
%
(
atype
,
aname
)
...
@@ -267,19 +267,19 @@ class PrototypeVisitor(EmitVisitor):
...
@@ -267,19 +267,19 @@ class PrototypeVisitor(EmitVisitor):
for
i
in
range
(
1
,
len
(
args
)
+
1
):
for
i
in
range
(
1
,
len
(
args
)
+
1
):
margs
+=
", a
%
d"
%
i
margs
+=
", a
%
d"
%
i
self
.
emit
(
"#define
%
s(
%
s) _Py_
%
s(
%
s)"
%
(
name
,
margs
,
name
,
margs
),
0
,
self
.
emit
(
"#define
%
s(
%
s) _Py_
%
s(
%
s)"
%
(
name
,
margs
,
name
,
margs
),
0
,
reflow
=
0
)
reflow
=
False
)
self
.
emit
(
"
%
s _Py_
%
s(
%
s);"
%
(
ctype
,
name
,
argstr
),
0
)
self
.
emit
(
"
%
s _Py_
%
s(
%
s);"
%
(
ctype
,
name
,
argstr
),
False
)
def
visitProduct
(
self
,
prod
,
name
):
def
visitProduct
(
self
,
prod
,
name
):
self
.
emit_function
(
name
,
get_c_type
(
name
),
self
.
emit_function
(
name
,
get_c_type
(
name
),
self
.
get_args
(
prod
.
fields
),
[],
union
=
0
)
self
.
get_args
(
prod
.
fields
),
[],
union
=
False
)
class
FunctionVisitor
(
PrototypeVisitor
):
class
FunctionVisitor
(
PrototypeVisitor
):
"""Visitor to generate constructor functions for AST."""
"""Visitor to generate constructor functions for AST."""
def
emit_function
(
self
,
name
,
ctype
,
args
,
attrs
,
union
=
1
):
def
emit_function
(
self
,
name
,
ctype
,
args
,
attrs
,
union
=
True
):
def
emit
(
s
,
depth
=
0
,
reflow
=
1
):
def
emit
(
s
,
depth
=
0
,
reflow
=
True
):
self
.
emit
(
s
,
depth
,
reflow
)
self
.
emit
(
s
,
depth
,
reflow
)
argstr
=
", "
.
join
([
"
%
s
%
s"
%
(
atype
,
aname
)
argstr
=
", "
.
join
([
"
%
s
%
s"
%
(
atype
,
aname
)
for
atype
,
aname
,
opt
in
args
+
attrs
])
for
atype
,
aname
,
opt
in
args
+
attrs
])
...
@@ -298,7 +298,7 @@ class FunctionVisitor(PrototypeVisitor):
...
@@ -298,7 +298,7 @@ class FunctionVisitor(PrototypeVisitor):
emit
(
"PyErr_SetString(PyExc_ValueError,"
,
2
)
emit
(
"PyErr_SetString(PyExc_ValueError,"
,
2
)
msg
=
"field
%
s is required for
%
s"
%
(
argname
,
name
)
msg
=
"field
%
s is required for
%
s"
%
(
argname
,
name
)
emit
(
' "
%
s");'
%
msg
,
emit
(
' "
%
s");'
%
msg
,
2
,
reflow
=
0
)
2
,
reflow
=
False
)
emit
(
'return NULL;'
,
2
)
emit
(
'return NULL;'
,
2
)
emit
(
'}'
,
1
)
emit
(
'}'
,
1
)
...
@@ -314,7 +314,7 @@ class FunctionVisitor(PrototypeVisitor):
...
@@ -314,7 +314,7 @@ class FunctionVisitor(PrototypeVisitor):
emit
(
""
)
emit
(
""
)
def
emit_body_union
(
self
,
name
,
args
,
attrs
):
def
emit_body_union
(
self
,
name
,
args
,
attrs
):
def
emit
(
s
,
depth
=
0
,
reflow
=
1
):
def
emit
(
s
,
depth
=
0
,
reflow
=
True
):
self
.
emit
(
s
,
depth
,
reflow
)
self
.
emit
(
s
,
depth
,
reflow
)
emit
(
"p->kind =
%
s_kind;"
%
name
,
1
)
emit
(
"p->kind =
%
s_kind;"
%
name
,
1
)
for
argtype
,
argname
,
opt
in
args
:
for
argtype
,
argname
,
opt
in
args
:
...
@@ -323,7 +323,7 @@ class FunctionVisitor(PrototypeVisitor):
...
@@ -323,7 +323,7 @@ class FunctionVisitor(PrototypeVisitor):
emit
(
"p->
%
s =
%
s;"
%
(
argname
,
argname
),
1
)
emit
(
"p->
%
s =
%
s;"
%
(
argname
,
argname
),
1
)
def
emit_body_struct
(
self
,
name
,
args
,
attrs
):
def
emit_body_struct
(
self
,
name
,
args
,
attrs
):
def
emit
(
s
,
depth
=
0
,
reflow
=
1
):
def
emit
(
s
,
depth
=
0
,
reflow
=
True
):
self
.
emit
(
s
,
depth
,
reflow
)
self
.
emit
(
s
,
depth
,
reflow
)
for
argtype
,
argname
,
opt
in
args
:
for
argtype
,
argname
,
opt
in
args
:
emit
(
"p->
%
s =
%
s;"
%
(
argname
,
argname
),
1
)
emit
(
"p->
%
s =
%
s;"
%
(
argname
,
argname
),
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