Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Interpreter pattern
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Structure == === UML class and object diagram === [[File:w3sDesign Interpreter Design Pattern UML.jpg|frame|none|A sample UML class and object diagram for the Interpreter design pattern.<ref>{{cite web|title=The Interpreter design pattern - Structure and Collaboration|url=http://w3sdesign.com/?gr=b03&ugr=struct|website=w3sDesign.com|access-date=2017-08-12}}</ref>]] In the above [[Unified Modeling Language|UML]] [[class diagram]], the <code>Client</code> class refers to the common <code>AbstractExpression</code> interface for interpreting an expression <code>interpret(context)</code>. <br> The <code>TerminalExpression</code> class has no children and interprets an expression directly. <br> The <code>NonTerminalExpression</code> class maintains a container of child expressions (<code>expressions</code>) and forwards interpret requests to these <code>expressions</code>. <br> The object collaboration diagram shows the run-time interactions: The <code>Client</code> object sends an interpret request to the abstract syntax tree. The request is forwarded to (performed on) all objects downwards the tree structure. <br>The <code>NonTerminalExpression</code> objects (<code>ntExpr1,ntExpr2</code>) forward the request to their child expressions. <br>The <code>TerminalExpression</code> objects (<code>tExpr1,tExpr2,…</code>) perform the interpretation directly. === UML class diagram === [[Image:Interpreter_UML_class_diagram.svg]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)