composite pattern: expressions
DESCRIPTION
Assign. BinaryExp. Add. Expression. Constant. Variable. 2. Composite Pattern: Expressions. Leaf and non-Leaf (part/whole) have same interface Treat whole like part How are parts added to a whole? Simple interface, control propagates through system - PowerPoint PPT PresentationTRANSCRIPT
CPS 100 rsg.1
Composite Pattern: Expressions Leaf and non-Leaf (part/whole) have same
interface Treat whole like part How are parts added to a whole? Simple interface, control propagates through
system Expression and BinaryExp are abstract base
classes What makes a class abstract? Why are abstract classes designed?
How is a BinaryExp class evaluated? What about a Constant? Variable?
Expression
Constant Variable BinaryExp
Assign Add
2
CPS 100 rsg.2
RSG Composite
What’s in a Production?
What’s in a Definition?
What’s in a Nonterminal?
Definition
GrammarElement
Terminal Nonterminal Production
*
*