Design Patterns : Elements of Reusable Object-Oriented Software


Design Patterns: Elements of Reusable Object-Oriented Software



Download 4,06 Mb.
Pdf ko'rish
bet187/288
Sana07.04.2022
Hajmi4,06 Mb.
#535140
1   ...   183   184   185   186   187   188   189   190   ...   288
Bog'liq
GOF Design Patterns

Design Patterns: Elements of Reusable Object-Oriented Software 
277 
Structure 
Participants 

AbstractExpression
(RegularExpression) 
o
declares an abstract Interpret operation that is common to all nodes 
in the abstract syntax tree. 

TerminalExpression
(LiteralExpression) 
o
implements an Interpret operation associated with terminal symbols 
in the grammar. 
o
an instance is required for every terminal symbol in a sentence. 

NonterminalExpression
(AlternationExpression,RepetitionExpression, 
SequenceExpressions) 
o
one such class is required for every rule 
R
::= 
R
1
R
2
... 
R
n
in the 
grammar. 
o
maintains instance variables of type AbstractExpression for each 
of the symbols 
R
1
through 
R
n

o
implements an Interpret operation for nonterminal symbols in the 
grammar. Interpret typically calls itself recursively on the 
variables representing 
R
1
through 
R
n


Context
o
contains information that's global to the interpreter. 

Client
o
builds (or is given) an abstract syntax tree representing a 
particular sentence in the language that the grammar defines. The 
abstract syntax tree is assembled from instances of the 
NonterminalExpression and TerminalExpression classes. 
o
invokes the Interpret operation. 


Design Patterns: Elements of Reusable Object-Oriented Software 
278 
Collaborations 

The client builds (or is given) the sentence as an abstract syntaxtree of 
NonterminalExpression and TerminalExpression instances. Thenthe client 
initializes the context and invokes the Interpretoperation. 

Each NonterminalExpression node defines Interpret in terms ofInterpret on 
each subexpression. The Interpret operation of eachTerminalExpression 
defines the base case in the recursion. 

The Interpret operations at each node use the context tostore and access 
the state of the interpreter. 

Download 4,06 Mb.

Do'stlaringiz bilan baham:
1   ...   183   184   185   186   187   188   189   190   ...   288




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish