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
1b1498b4
Kaydet (Commit)
1b1498b4
authored
Agu 28, 2007
tarafından
Collin Winter
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Idiom adjustment in the docs for the parser module.
üst
d1d9a890
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
8 deletions
+6
-8
parser.rst
Doc/library/parser.rst
+6
-8
No files found.
Doc/library/parser.rst
Dosyayı görüntüle @
1b1498b4
...
...
@@ -474,19 +474,17 @@ representation to be ``['variable_name']``. A simple recursive function can
implement the pattern matching, returning a Boolean and a dictionary of variable
name to value mappings. (See file :file:`example.py`.) ::
from types import ListType, TupleType
def match(pattern, data, vars=None):
if vars is None:
vars = {}
if
type(pattern) is ListType
:
if
isinstance(pattern, list)
:
vars[pattern[0]] = data
return
1
, vars
if
type(pattern) is not TupleType
:
return
True
, vars
if
not instance(pattern, tuple)
:
return (pattern == data), vars
if len(data) != len(pattern):
return
0
, vars
for pattern, data in
map(None,
pattern, data):
return
False
, vars
for pattern, data in
zip(
pattern, data):
same, vars = match(pattern, data, vars)
if not same:
break
...
...
@@ -528,7 +526,7 @@ docstring from the parse tree created previously is easy::
>>> found, vars = match(DOCSTRING_STMT_PATTERN, tup[1])
>>> found
1
True
>>> vars
{'docstring': '"""Some documentation.\n"""'}
...
...
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