SlideShare ist ein Scribd-Unternehmen logo
1 von 14
Interpreter Design Pattern
1- Review
2- Intent
3- Implements
4- Sample Code
5- Applicability
6- Consequences
7- Know Uses
Overview
1- Review
- What is Behavioral Pattern ?
-> Design patterns that identify common communication patterns between
object.
- What is a common pattern?
2- Intent
Given a language, define a representation for its grammar along with an interpreter
that uses the representation to interpret sentences in the language.
- The Implementation of the Interpreter pattern is just the use of the composite
pattern applied to represent a grammar.
- The Interpreter defines the behaviour while the composite defines only the
structure.
3- Implements
3- Implements (Cont.)
Abstract Expression
- Declares an interface for executing an operator
Terminal Expression
- Implements an Interpret operation associated with terminal symbols in the grammar.
- Interprets expressions containing any of the terminal tokens in the grammar.
Nonterminal Expression
- Interprets all of the nonterminal expressions in the grammar .
Context
- Contains the global information that is part of the parse.
Client
- Builds the syntax tree from the preceding expression types and invokes the interpret
operation.
3- Implements (Cont.)
public class Context {
private string input;
private int output;
public Context (String input) {
this.input = input;
}
public String getInput () {
return input;
}
public void setInput(String input) {
this.input = input;
}
public int getOutput () {
return output;
}
public void setOutput (int output) {
this.output = output;
}
}
4- Sample Code
public abstract class Expression {
public void interpret (Context context) {
if (context.getInput().length() == 0) {
return;
}
if (context.getInput().startsWith(nine)) {
context.setOutput(context.getOutput() + (9 * multiplier() ));
context.setInput(context.getInput().subString(2));
}
else if (context.getInput().startsWith(four)) {
context.setOutput(context.getOutput() + (4 * multiplier() ));
context.setInput(context.getInput().subString(2));
}
while (context.getInput().startsWith(one)) {
context.setOutput(context.getOutput() + (4 * multiplier() ));
context.setInput(context.getInput().subString(1));
}
}
4- Sample Code (Cont.)
public abstract String one();
public abstract String fout();
public abstract String nine();
public abstract int multiplier();
}
4- Sample Code (Cont.)
The template method pattern should be used :
- The interpreter pattern is used exhaustively in defining grammar, tokenize
input and store it.
- A specific area where Interpreter can be used are the rule engines.
- The Interpreter pattern can be used to add functionality to the composite
pattern.
5- Applicability
- Easier to change and extend the grammar
- Implementing the grammar is easily
- Adding new ways to interpret expressions
- Lets you embed a language into program
- Complex grammars are hard to maintain
6- Consequences
- Python uses the Interpreter pattern to generate byte code for a parse tree.
- A scheme interpreter pattern, directly executes the parse tree, making small
optimizations as it goes along.
- Text editors and Web browsers use the interpreter pattern to lay out document
and check spelling.
7- Know Uses
Thanks !

Weitere ähnliche Inhalte

Was ist angesagt?

Relational Algebra and MapReduce
Relational Algebra and MapReduceRelational Algebra and MapReduce
Relational Algebra and MapReducePietro Michiardi
 
Google mock training
Google mock trainingGoogle mock training
Google mock trainingThierry Gayet
 
The Singleton Pattern Presentation
The Singleton Pattern PresentationThe Singleton Pattern Presentation
The Singleton Pattern PresentationJAINIK PATEL
 
Unit4: Knowledge Representation
Unit4: Knowledge RepresentationUnit4: Knowledge Representation
Unit4: Knowledge RepresentationTekendra Nath Yogi
 
Singleton Pattern (Sole Object with Global Access)
Singleton Pattern (Sole Object with Global Access)Singleton Pattern (Sole Object with Global Access)
Singleton Pattern (Sole Object with Global Access)Sameer Rathoud
 
Behavioral Design Patterns
Behavioral Design PatternsBehavioral Design Patterns
Behavioral Design PatternsLidan Hifi
 
Android notification
Android notificationAndroid notification
Android notificationKrazy Koder
 
House Price Prediction An AI Approach.
House Price Prediction An AI Approach.House Price Prediction An AI Approach.
House Price Prediction An AI Approach.Nahian Ahmed
 
Object-Oriented Analysis And Design With Applications Grady Booch
Object-Oriented Analysis And Design With Applications Grady BoochObject-Oriented Analysis And Design With Applications Grady Booch
Object-Oriented Analysis And Design With Applications Grady BoochSorina Chirilă
 
A real-world example of Functional Programming with fp-ts - no experience req...
A real-world example of Functional Programming with fp-ts - no experience req...A real-world example of Functional Programming with fp-ts - no experience req...
A real-world example of Functional Programming with fp-ts - no experience req...Frederick Fogerty
 

Was ist angesagt? (20)

Builder pattern
Builder patternBuilder pattern
Builder pattern
 
Design Pattern Cheatsheet
Design Pattern CheatsheetDesign Pattern Cheatsheet
Design Pattern Cheatsheet
 
Reasoning in AI
Reasoning in AIReasoning in AI
Reasoning in AI
 
2D graphics
2D graphics2D graphics
2D graphics
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Relational Algebra and MapReduce
Relational Algebra and MapReduceRelational Algebra and MapReduce
Relational Algebra and MapReduce
 
Google mock training
Google mock trainingGoogle mock training
Google mock training
 
The Singleton Pattern Presentation
The Singleton Pattern PresentationThe Singleton Pattern Presentation
The Singleton Pattern Presentation
 
Unit4: Knowledge Representation
Unit4: Knowledge RepresentationUnit4: Knowledge Representation
Unit4: Knowledge Representation
 
Singleton Pattern (Sole Object with Global Access)
Singleton Pattern (Sole Object with Global Access)Singleton Pattern (Sole Object with Global Access)
Singleton Pattern (Sole Object with Global Access)
 
Behavioral Design Patterns
Behavioral Design PatternsBehavioral Design Patterns
Behavioral Design Patterns
 
GUI components in Java
GUI components in JavaGUI components in Java
GUI components in Java
 
Android notification
Android notificationAndroid notification
Android notification
 
Tic tac toe simple ai game
Tic tac toe simple ai gameTic tac toe simple ai game
Tic tac toe simple ai game
 
House Price Prediction An AI Approach.
House Price Prediction An AI Approach.House Price Prediction An AI Approach.
House Price Prediction An AI Approach.
 
Object-Oriented Analysis And Design With Applications Grady Booch
Object-Oriented Analysis And Design With Applications Grady BoochObject-Oriented Analysis And Design With Applications Grady Booch
Object-Oriented Analysis And Design With Applications Grady Booch
 
Kr using rules
Kr using rulesKr using rules
Kr using rules
 
Python-DataAbstarction.pptx
Python-DataAbstarction.pptxPython-DataAbstarction.pptx
Python-DataAbstarction.pptx
 
DESIGN PATTERNS: Strategy Patterns
DESIGN PATTERNS: Strategy PatternsDESIGN PATTERNS: Strategy Patterns
DESIGN PATTERNS: Strategy Patterns
 
A real-world example of Functional Programming with fp-ts - no experience req...
A real-world example of Functional Programming with fp-ts - no experience req...A real-world example of Functional Programming with fp-ts - no experience req...
A real-world example of Functional Programming with fp-ts - no experience req...
 

Andere mochten auch

2010 sector study_report_english
2010 sector study_report_english2010 sector study_report_english
2010 sector study_report_englishSaravuth kong
 
Management of diabetes
Management of diabetesManagement of diabetes
Management of diabetesIvan Luyimbazi
 
Get started with dropbox
Get started with dropboxGet started with dropbox
Get started with dropboxArnold Laconsay
 
The most outstanding Leader i have worked with.
The most outstanding Leader i have worked with.The most outstanding Leader i have worked with.
The most outstanding Leader i have worked with.Nya Offiong
 
Promoting Clinical Research and Application to Practice - Counties Manukau He...
Promoting Clinical Research and Application to Practice - Counties Manukau He...Promoting Clinical Research and Application to Practice - Counties Manukau He...
Promoting Clinical Research and Application to Practice - Counties Manukau He...KoAwatea
 
Working Seamlessly Across Organisations - Kidney Society, Auckland and Count...
 Working Seamlessly Across Organisations - Kidney Society, Auckland and Count... Working Seamlessly Across Organisations - Kidney Society, Auckland and Count...
Working Seamlessly Across Organisations - Kidney Society, Auckland and Count...KoAwatea
 
IndagineConoscitivaEbook2005
IndagineConoscitivaEbook2005IndagineConoscitivaEbook2005
IndagineConoscitivaEbook2005Chiara Pacquola
 
Deepak & Celia Mahtani - Freedom talk, Oasis Church, Collierswood, London
Deepak & Celia Mahtani - Freedom talk, Oasis Church, Collierswood, LondonDeepak & Celia Mahtani - Freedom talk, Oasis Church, Collierswood, London
Deepak & Celia Mahtani - Freedom talk, Oasis Church, Collierswood, LondonSocialMediaOasisChurch
 
Assuring quality improvement - Jerome Ng - Waitemata DHB
Assuring quality improvement - Jerome Ng - Waitemata DHBAssuring quality improvement - Jerome Ng - Waitemata DHB
Assuring quality improvement - Jerome Ng - Waitemata DHBKoAwatea
 
Hepatitis and its complications
Hepatitis and its complicationsHepatitis and its complications
Hepatitis and its complicationsIvan Luyimbazi
 
Working Seamlessly Across Organisations - National Hauora Coalition, Tamariki...
Working Seamlessly Across Organisations - National Hauora Coalition, Tamariki...Working Seamlessly Across Organisations - National Hauora Coalition, Tamariki...
Working Seamlessly Across Organisations - National Hauora Coalition, Tamariki...KoAwatea
 

Andere mochten auch (14)

2010 sector study_report_english
2010 sector study_report_english2010 sector study_report_english
2010 sector study_report_english
 
Management of diabetes
Management of diabetesManagement of diabetes
Management of diabetes
 
Anemia
AnemiaAnemia
Anemia
 
Get started with dropbox
Get started with dropboxGet started with dropbox
Get started with dropbox
 
The most outstanding Leader i have worked with.
The most outstanding Leader i have worked with.The most outstanding Leader i have worked with.
The most outstanding Leader i have worked with.
 
Promoting Clinical Research and Application to Practice - Counties Manukau He...
Promoting Clinical Research and Application to Practice - Counties Manukau He...Promoting Clinical Research and Application to Practice - Counties Manukau He...
Promoting Clinical Research and Application to Practice - Counties Manukau He...
 
Working Seamlessly Across Organisations - Kidney Society, Auckland and Count...
 Working Seamlessly Across Organisations - Kidney Society, Auckland and Count... Working Seamlessly Across Organisations - Kidney Society, Auckland and Count...
Working Seamlessly Across Organisations - Kidney Society, Auckland and Count...
 
IndagineConoscitivaEbook2005
IndagineConoscitivaEbook2005IndagineConoscitivaEbook2005
IndagineConoscitivaEbook2005
 
Deepak & Celia Mahtani - Freedom talk, Oasis Church, Collierswood, London
Deepak & Celia Mahtani - Freedom talk, Oasis Church, Collierswood, LondonDeepak & Celia Mahtani - Freedom talk, Oasis Church, Collierswood, London
Deepak & Celia Mahtani - Freedom talk, Oasis Church, Collierswood, London
 
Assuring quality improvement - Jerome Ng - Waitemata DHB
Assuring quality improvement - Jerome Ng - Waitemata DHBAssuring quality improvement - Jerome Ng - Waitemata DHB
Assuring quality improvement - Jerome Ng - Waitemata DHB
 
Freedom from depression
Freedom from depressionFreedom from depression
Freedom from depression
 
Statistika
StatistikaStatistika
Statistika
 
Hepatitis and its complications
Hepatitis and its complicationsHepatitis and its complications
Hepatitis and its complications
 
Working Seamlessly Across Organisations - National Hauora Coalition, Tamariki...
Working Seamlessly Across Organisations - National Hauora Coalition, Tamariki...Working Seamlessly Across Organisations - National Hauora Coalition, Tamariki...
Working Seamlessly Across Organisations - National Hauora Coalition, Tamariki...
 

Ähnlich wie Interpreter Design Pattern

Golang basics for Java developers - Part 1
Golang basics for Java developers - Part 1Golang basics for Java developers - Part 1
Golang basics for Java developers - Part 1Robert Stern
 
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docxCOMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docxmonicafrancis71118
 
C programming language tutorial
C programming language tutorial C programming language tutorial
C programming language tutorial javaTpoint s
 
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docxCOMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docxcargillfilberto
 
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docxCOMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docxdrandy1
 
What's new in c# 8.0
What's new in c# 8.0What's new in c# 8.0
What's new in c# 8.0Moaid Hathot
 
Declare Your Language: Syntax Definition
Declare Your Language: Syntax DefinitionDeclare Your Language: Syntax Definition
Declare Your Language: Syntax DefinitionEelco Visser
 
Binary Studio Academy PRO: ANTLR course by Alexander Vasiltsov (lesson 3)
Binary Studio Academy PRO: ANTLR course by Alexander Vasiltsov (lesson 3)Binary Studio Academy PRO: ANTLR course by Alexander Vasiltsov (lesson 3)
Binary Studio Academy PRO: ANTLR course by Alexander Vasiltsov (lesson 3)Binary Studio
 
A Proposal to Orchestrate Test Cases
A Proposal to Orchestrate Test CasesA Proposal to Orchestrate Test Cases
A Proposal to Orchestrate Test CasesBoni García
 
(3) cpp procedural programming
(3) cpp procedural programming(3) cpp procedural programming
(3) cpp procedural programmingNico Ludwig
 
It’s sometimes useful to make a little language for a simple problem.pdf
It’s sometimes useful to make a little language for a simple problem.pdfIt’s sometimes useful to make a little language for a simple problem.pdf
It’s sometimes useful to make a little language for a simple problem.pdfarri2009av
 
Python Modules, executing modules as script.pptx
Python Modules, executing modules as script.pptxPython Modules, executing modules as script.pptx
Python Modules, executing modules as script.pptxSingamvineela
 
Presentation slides for "A formal foundation for trace-based JIT compilation"
Presentation slides for "A formal foundation for trace-based JIT compilation"Presentation slides for "A formal foundation for trace-based JIT compilation"
Presentation slides for "A formal foundation for trace-based JIT compilation"mvdcamme
 
Faculty of ScienceDepartment of ComputingFinal Examinati.docx
Faculty of ScienceDepartment of ComputingFinal Examinati.docxFaculty of ScienceDepartment of ComputingFinal Examinati.docx
Faculty of ScienceDepartment of ComputingFinal Examinati.docxmydrynan
 
Functional Programming You Already Know
Functional Programming You Already KnowFunctional Programming You Already Know
Functional Programming You Already KnowKevlin Henney
 

Ähnlich wie Interpreter Design Pattern (20)

Core java
Core javaCore java
Core java
 
Golang basics for Java developers - Part 1
Golang basics for Java developers - Part 1Golang basics for Java developers - Part 1
Golang basics for Java developers - Part 1
 
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docxCOMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
 
C programming language tutorial
C programming language tutorial C programming language tutorial
C programming language tutorial
 
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docxCOMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
 
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docxCOMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
 
What's new in c# 8.0
What's new in c# 8.0What's new in c# 8.0
What's new in c# 8.0
 
Declare Your Language: Syntax Definition
Declare Your Language: Syntax DefinitionDeclare Your Language: Syntax Definition
Declare Your Language: Syntax Definition
 
AFPS_2011
AFPS_2011AFPS_2011
AFPS_2011
 
Advance python
Advance pythonAdvance python
Advance python
 
Binary Studio Academy PRO: ANTLR course by Alexander Vasiltsov (lesson 3)
Binary Studio Academy PRO: ANTLR course by Alexander Vasiltsov (lesson 3)Binary Studio Academy PRO: ANTLR course by Alexander Vasiltsov (lesson 3)
Binary Studio Academy PRO: ANTLR course by Alexander Vasiltsov (lesson 3)
 
srgoc
srgocsrgoc
srgoc
 
A Proposal to Orchestrate Test Cases
A Proposal to Orchestrate Test CasesA Proposal to Orchestrate Test Cases
A Proposal to Orchestrate Test Cases
 
(3) cpp procedural programming
(3) cpp procedural programming(3) cpp procedural programming
(3) cpp procedural programming
 
It’s sometimes useful to make a little language for a simple problem.pdf
It’s sometimes useful to make a little language for a simple problem.pdfIt’s sometimes useful to make a little language for a simple problem.pdf
It’s sometimes useful to make a little language for a simple problem.pdf
 
Python Modules, executing modules as script.pptx
Python Modules, executing modules as script.pptxPython Modules, executing modules as script.pptx
Python Modules, executing modules as script.pptx
 
Presentation slides for "A formal foundation for trace-based JIT compilation"
Presentation slides for "A formal foundation for trace-based JIT compilation"Presentation slides for "A formal foundation for trace-based JIT compilation"
Presentation slides for "A formal foundation for trace-based JIT compilation"
 
Faculty of ScienceDepartment of ComputingFinal Examinati.docx
Faculty of ScienceDepartment of ComputingFinal Examinati.docxFaculty of ScienceDepartment of ComputingFinal Examinati.docx
Faculty of ScienceDepartment of ComputingFinal Examinati.docx
 
Functional Programming You Already Know
Functional Programming You Already KnowFunctional Programming You Already Know
Functional Programming You Already Know
 
Interpreter
InterpreterInterpreter
Interpreter
 

Kürzlich hochgeladen

(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdfKamal Acharya
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsRussian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdfKamal Acharya
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Christo Ananth
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...ranjana rawat
 

Kürzlich hochgeladen (20)

(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsRussian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 

Interpreter Design Pattern

  • 2. 1- Review 2- Intent 3- Implements 4- Sample Code 5- Applicability 6- Consequences 7- Know Uses Overview
  • 3. 1- Review - What is Behavioral Pattern ? -> Design patterns that identify common communication patterns between object. - What is a common pattern?
  • 4. 2- Intent Given a language, define a representation for its grammar along with an interpreter that uses the representation to interpret sentences in the language.
  • 5. - The Implementation of the Interpreter pattern is just the use of the composite pattern applied to represent a grammar. - The Interpreter defines the behaviour while the composite defines only the structure. 3- Implements
  • 7. Abstract Expression - Declares an interface for executing an operator Terminal Expression - Implements an Interpret operation associated with terminal symbols in the grammar. - Interprets expressions containing any of the terminal tokens in the grammar. Nonterminal Expression - Interprets all of the nonterminal expressions in the grammar . Context - Contains the global information that is part of the parse. Client - Builds the syntax tree from the preceding expression types and invokes the interpret operation. 3- Implements (Cont.)
  • 8. public class Context { private string input; private int output; public Context (String input) { this.input = input; } public String getInput () { return input; } public void setInput(String input) { this.input = input; } public int getOutput () { return output; } public void setOutput (int output) { this.output = output; } } 4- Sample Code
  • 9. public abstract class Expression { public void interpret (Context context) { if (context.getInput().length() == 0) { return; } if (context.getInput().startsWith(nine)) { context.setOutput(context.getOutput() + (9 * multiplier() )); context.setInput(context.getInput().subString(2)); } else if (context.getInput().startsWith(four)) { context.setOutput(context.getOutput() + (4 * multiplier() )); context.setInput(context.getInput().subString(2)); } while (context.getInput().startsWith(one)) { context.setOutput(context.getOutput() + (4 * multiplier() )); context.setInput(context.getInput().subString(1)); } } 4- Sample Code (Cont.)
  • 10. public abstract String one(); public abstract String fout(); public abstract String nine(); public abstract int multiplier(); } 4- Sample Code (Cont.)
  • 11. The template method pattern should be used : - The interpreter pattern is used exhaustively in defining grammar, tokenize input and store it. - A specific area where Interpreter can be used are the rule engines. - The Interpreter pattern can be used to add functionality to the composite pattern. 5- Applicability
  • 12. - Easier to change and extend the grammar - Implementing the grammar is easily - Adding new ways to interpret expressions - Lets you embed a language into program - Complex grammars are hard to maintain 6- Consequences
  • 13. - Python uses the Interpreter pattern to generate byte code for a parse tree. - A scheme interpreter pattern, directly executes the parse tree, making small optimizations as it goes along. - Text editors and Web browsers use the interpreter pattern to lay out document and check spelling. 7- Know Uses