composite pattern: expressions

2
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

Upload: hollie

Post on 07-Jan-2016

18 views

Category:

Documents


0 download

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 Presentation

TRANSCRIPT

Page 1: Composite Pattern: Expressions

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

Page 2: Composite Pattern: Expressions

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

*

*