SlideShare a Scribd company logo
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 !

More Related Content

What's hot

Java Serialization
Java SerializationJava Serialization
Java Serialization
imypraz
 
Visitor Pattern
Visitor PatternVisitor Pattern
Visitor Pattern
Ider Zheng
 
Asp.net architecture
Asp.net architectureAsp.net architecture
Asp.net architecture
Iblesoft
 
The Singleton Pattern Presentation
The Singleton Pattern PresentationThe Singleton Pattern Presentation
The Singleton Pattern Presentation
JAINIK PATEL
 
Reflection power pointpresentation ppt
Reflection power pointpresentation pptReflection power pointpresentation ppt
Reflection power pointpresentation ppt
Rohit Vipin Mathews
 
ASP.NET - Life cycle of asp
ASP.NET - Life cycle of aspASP.NET - Life cycle of asp
ASP.NET - Life cycle of asp
priya Nithya
 
L11 array list
L11 array listL11 array list
L11 array list
teach4uin
 
Bridge Design Pattern
Bridge Design PatternBridge Design Pattern
Bridge Design Pattern
Shahriar Hyder
 
Joshua bloch effect java chapter 3
Joshua bloch effect java   chapter 3Joshua bloch effect java   chapter 3
Joshua bloch effect java chapter 3
Kamal Mukkamala
 
Cracking OCA and OCP Java 8 Exams
Cracking OCA and OCP Java 8 ExamsCracking OCA and OCP Java 8 Exams
Cracking OCA and OCP Java 8 Exams
Ganesh Samarthyam
 
Fly Weight Design Pattern.pptx
Fly Weight Design Pattern.pptxFly Weight Design Pattern.pptx
Fly Weight Design Pattern.pptx
Saifullah568810
 
Prototype Pattern
Prototype PatternPrototype Pattern
Prototype Pattern
Ider Zheng
 
Factory Design Pattern
Factory Design PatternFactory Design Pattern
Factory Design Pattern
Jyaasa Technologies
 
NestJS
NestJSNestJS
NestJS
Wilson Su
 
Visitor design patterns
Visitor design patternsVisitor design patterns
Visitor design patterns
Nishant Mevawala
 
Spring Framework - AOP
Spring Framework - AOPSpring Framework - AOP
Spring Framework - AOP
Dzmitry Naskou
 
Servlet Filters
Servlet FiltersServlet Filters
Servlet Filters
Wings Interactive
 
Design patterns
Design patternsDesign patterns
Design patterns
abhisheksagi
 
Javascript validating form
Javascript validating formJavascript validating form
Javascript validating form
Jesus Obenita Jr.
 
ASP.NET Web API
ASP.NET Web APIASP.NET Web API
ASP.NET Web API
habib_786
 

What's hot (20)

Java Serialization
Java SerializationJava Serialization
Java Serialization
 
Visitor Pattern
Visitor PatternVisitor Pattern
Visitor Pattern
 
Asp.net architecture
Asp.net architectureAsp.net architecture
Asp.net architecture
 
The Singleton Pattern Presentation
The Singleton Pattern PresentationThe Singleton Pattern Presentation
The Singleton Pattern Presentation
 
Reflection power pointpresentation ppt
Reflection power pointpresentation pptReflection power pointpresentation ppt
Reflection power pointpresentation ppt
 
ASP.NET - Life cycle of asp
ASP.NET - Life cycle of aspASP.NET - Life cycle of asp
ASP.NET - Life cycle of asp
 
L11 array list
L11 array listL11 array list
L11 array list
 
Bridge Design Pattern
Bridge Design PatternBridge Design Pattern
Bridge Design Pattern
 
Joshua bloch effect java chapter 3
Joshua bloch effect java   chapter 3Joshua bloch effect java   chapter 3
Joshua bloch effect java chapter 3
 
Cracking OCA and OCP Java 8 Exams
Cracking OCA and OCP Java 8 ExamsCracking OCA and OCP Java 8 Exams
Cracking OCA and OCP Java 8 Exams
 
Fly Weight Design Pattern.pptx
Fly Weight Design Pattern.pptxFly Weight Design Pattern.pptx
Fly Weight Design Pattern.pptx
 
Prototype Pattern
Prototype PatternPrototype Pattern
Prototype Pattern
 
Factory Design Pattern
Factory Design PatternFactory Design Pattern
Factory Design Pattern
 
NestJS
NestJSNestJS
NestJS
 
Visitor design patterns
Visitor design patternsVisitor design patterns
Visitor design patterns
 
Spring Framework - AOP
Spring Framework - AOPSpring Framework - AOP
Spring Framework - AOP
 
Servlet Filters
Servlet FiltersServlet Filters
Servlet Filters
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Javascript validating form
Javascript validating formJavascript validating form
Javascript validating form
 
ASP.NET Web API
ASP.NET Web APIASP.NET Web API
ASP.NET Web API
 

Viewers also liked

2010 sector study_report_english
2010 sector study_report_english2010 sector study_report_english
2010 sector study_report_english
Saravuth kong
 
Management of diabetes
Management of diabetesManagement of diabetes
Management of diabetes
Ivan Luyimbazi
 
Anemia
AnemiaAnemia
Get started with dropbox
Get started with dropboxGet started with dropbox
Get started with dropbox
Arnold 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, London
SocialMediaOasisChurch
 
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
KoAwatea
 
Freedom from depression
Freedom from depressionFreedom from depression
Freedom from depression
SocialMediaOasisChurch
 
Statistika
StatistikaStatistika
Hepatitis and its complications
Hepatitis and its complicationsHepatitis and its complications
Hepatitis and its complications
Ivan 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
 

Viewers also liked (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...
 

Similar to Interpreter Design Pattern

Core java
Core javaCore java
Core java
kasaragaddaslide
 
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
Robert 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.docx
monicafrancis71118
 
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.docx
cargillfilberto
 
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
drandy1
 
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
Moaid Hathot
 
Declare Your Language: Syntax Definition
Declare Your Language: Syntax DefinitionDeclare Your Language: Syntax Definition
Declare Your Language: Syntax Definition
Eelco Visser
 
AFPS_2011
AFPS_2011AFPS_2011
Advance python
Advance pythonAdvance python
Advance python
pulkit agrawal
 
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
 
srgoc
srgocsrgoc
A Proposal to Orchestrate Test Cases
A Proposal to Orchestrate Test CasesA Proposal to Orchestrate Test Cases
A Proposal to Orchestrate Test Cases
Boni García
 
(3) cpp procedural programming
(3) cpp procedural programming(3) cpp procedural programming
(3) cpp procedural programming
Nico 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.pdf
arri2009av
 
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
Singamvineela
 
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.docx
mydrynan
 
Functional Programming You Already Know
Functional Programming You Already KnowFunctional Programming You Already Know
Functional Programming You Already Know
Kevlin Henney
 
Interpreter
InterpreterInterpreter
Interpreter
Ahmad Al-bsheer
 

Similar to 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
 

Recently uploaded

Open Channel Flow: fluid flow with a free surface
Open Channel Flow: fluid flow with a free surfaceOpen Channel Flow: fluid flow with a free surface
Open Channel Flow: fluid flow with a free surface
Indrajeet sahu
 
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
ydzowc
 
Tools & Techniques for Commissioning and Maintaining PV Systems W-Animations ...
Tools & Techniques for Commissioning and Maintaining PV Systems W-Animations ...Tools & Techniques for Commissioning and Maintaining PV Systems W-Animations ...
Tools & Techniques for Commissioning and Maintaining PV Systems W-Animations ...
Transcat
 
Blood finder application project report (1).pdf
Blood finder application project report (1).pdfBlood finder application project report (1).pdf
Blood finder application project report (1).pdf
Kamal Acharya
 
Unit -II Spectroscopy - EC I B.Tech.pdf
Unit -II Spectroscopy - EC  I B.Tech.pdfUnit -II Spectroscopy - EC  I B.Tech.pdf
Unit -II Spectroscopy - EC I B.Tech.pdf
TeluguBadi
 
Digital Twins Computer Networking Paper Presentation.pptx
Digital Twins Computer Networking Paper Presentation.pptxDigital Twins Computer Networking Paper Presentation.pptx
Digital Twins Computer Networking Paper Presentation.pptx
aryanpankaj78
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
ijaia
 
DESIGN AND MANUFACTURE OF CEILING BOARD USING SAWDUST AND WASTE CARTON MATERI...
DESIGN AND MANUFACTURE OF CEILING BOARD USING SAWDUST AND WASTE CARTON MATERI...DESIGN AND MANUFACTURE OF CEILING BOARD USING SAWDUST AND WASTE CARTON MATERI...
DESIGN AND MANUFACTURE OF CEILING BOARD USING SAWDUST AND WASTE CARTON MATERI...
OKORIE1
 
Generative AI Use cases applications solutions and implementation.pdf
Generative AI Use cases applications solutions and implementation.pdfGenerative AI Use cases applications solutions and implementation.pdf
Generative AI Use cases applications solutions and implementation.pdf
mahaffeycheryld
 
Assistant Engineer (Chemical) Interview Questions.pdf
Assistant Engineer (Chemical) Interview Questions.pdfAssistant Engineer (Chemical) Interview Questions.pdf
Assistant Engineer (Chemical) Interview Questions.pdf
Seetal Daas
 
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
ecqow
 
Bituminous road construction project based learning report
Bituminous road construction project based learning reportBituminous road construction project based learning report
Bituminous road construction project based learning report
CE19KaushlendraKumar
 
Ericsson LTE Throughput Troubleshooting Techniques.ppt
Ericsson LTE Throughput Troubleshooting Techniques.pptEricsson LTE Throughput Troubleshooting Techniques.ppt
Ericsson LTE Throughput Troubleshooting Techniques.ppt
wafawafa52
 
Object Oriented Analysis and Design - OOAD
Object Oriented Analysis and Design - OOADObject Oriented Analysis and Design - OOAD
Object Oriented Analysis and Design - OOAD
PreethaV16
 
A high-Speed Communication System is based on the Design of a Bi-NoC Router, ...
A high-Speed Communication System is based on the Design of a Bi-NoC Router, ...A high-Speed Communication System is based on the Design of a Bi-NoC Router, ...
A high-Speed Communication System is based on the Design of a Bi-NoC Router, ...
DharmaBanothu
 
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
nedcocy
 
Null Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAMNull Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAM
Divyanshu
 
Zener Diode and its V-I Characteristics and Applications
Zener Diode and its V-I Characteristics and ApplicationsZener Diode and its V-I Characteristics and Applications
Zener Diode and its V-I Characteristics and Applications
Shiny Christobel
 
Impartiality as per ISO /IEC 17025:2017 Standard
Impartiality as per ISO /IEC 17025:2017 StandardImpartiality as per ISO /IEC 17025:2017 Standard
Impartiality as per ISO /IEC 17025:2017 Standard
MuhammadJazib15
 
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
PriyankaKilaniya
 

Recently uploaded (20)

Open Channel Flow: fluid flow with a free surface
Open Channel Flow: fluid flow with a free surfaceOpen Channel Flow: fluid flow with a free surface
Open Channel Flow: fluid flow with a free surface
 
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
 
Tools & Techniques for Commissioning and Maintaining PV Systems W-Animations ...
Tools & Techniques for Commissioning and Maintaining PV Systems W-Animations ...Tools & Techniques for Commissioning and Maintaining PV Systems W-Animations ...
Tools & Techniques for Commissioning and Maintaining PV Systems W-Animations ...
 
Blood finder application project report (1).pdf
Blood finder application project report (1).pdfBlood finder application project report (1).pdf
Blood finder application project report (1).pdf
 
Unit -II Spectroscopy - EC I B.Tech.pdf
Unit -II Spectroscopy - EC  I B.Tech.pdfUnit -II Spectroscopy - EC  I B.Tech.pdf
Unit -II Spectroscopy - EC I B.Tech.pdf
 
Digital Twins Computer Networking Paper Presentation.pptx
Digital Twins Computer Networking Paper Presentation.pptxDigital Twins Computer Networking Paper Presentation.pptx
Digital Twins Computer Networking Paper Presentation.pptx
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
 
DESIGN AND MANUFACTURE OF CEILING BOARD USING SAWDUST AND WASTE CARTON MATERI...
DESIGN AND MANUFACTURE OF CEILING BOARD USING SAWDUST AND WASTE CARTON MATERI...DESIGN AND MANUFACTURE OF CEILING BOARD USING SAWDUST AND WASTE CARTON MATERI...
DESIGN AND MANUFACTURE OF CEILING BOARD USING SAWDUST AND WASTE CARTON MATERI...
 
Generative AI Use cases applications solutions and implementation.pdf
Generative AI Use cases applications solutions and implementation.pdfGenerative AI Use cases applications solutions and implementation.pdf
Generative AI Use cases applications solutions and implementation.pdf
 
Assistant Engineer (Chemical) Interview Questions.pdf
Assistant Engineer (Chemical) Interview Questions.pdfAssistant Engineer (Chemical) Interview Questions.pdf
Assistant Engineer (Chemical) Interview Questions.pdf
 
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
 
Bituminous road construction project based learning report
Bituminous road construction project based learning reportBituminous road construction project based learning report
Bituminous road construction project based learning report
 
Ericsson LTE Throughput Troubleshooting Techniques.ppt
Ericsson LTE Throughput Troubleshooting Techniques.pptEricsson LTE Throughput Troubleshooting Techniques.ppt
Ericsson LTE Throughput Troubleshooting Techniques.ppt
 
Object Oriented Analysis and Design - OOAD
Object Oriented Analysis and Design - OOADObject Oriented Analysis and Design - OOAD
Object Oriented Analysis and Design - OOAD
 
A high-Speed Communication System is based on the Design of a Bi-NoC Router, ...
A high-Speed Communication System is based on the Design of a Bi-NoC Router, ...A high-Speed Communication System is based on the Design of a Bi-NoC Router, ...
A high-Speed Communication System is based on the Design of a Bi-NoC Router, ...
 
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
 
Null Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAMNull Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAM
 
Zener Diode and its V-I Characteristics and Applications
Zener Diode and its V-I Characteristics and ApplicationsZener Diode and its V-I Characteristics and Applications
Zener Diode and its V-I Characteristics and Applications
 
Impartiality as per ISO /IEC 17025:2017 Standard
Impartiality as per ISO /IEC 17025:2017 StandardImpartiality as per ISO /IEC 17025:2017 Standard
Impartiality as per ISO /IEC 17025:2017 Standard
 
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
 

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