Questions tagged [interpreter-pattern]

The Interpreter pattern implements a specialized language. It is one of the Gang of Four's behavioral design patterns. When using this tag on implementation heavy questions - tag the code language the implementation is written in.

The Interpreter design pattern is one of the Gang of Four's behavioral , first published in Gamma et al.'s book "Design Patterns: Elements of Reusable Object-Oriented Software".

The goal of this design pattern is to support a Domain Specific Language (DSL) by specifying how to evaluate sentences comprised of the DSL.

More information is available on Wikipedia.

9 questions
14
votes
3 answers

Why does the Interpreter Pattern suck?

In Steve Yegge's review of Design Patterns, he calls the Interpreter Pattern an "in-joke". He goes on to talk about how the perception of compilers have changed, yet how interpreted languages are still s*** on, although I can't see how this ties…
Mike Douglas
  • 3,345
  • 2
  • 28
  • 30
10
votes
3 answers

Using Interpreter pattern on a Composite structure

I've been asked to make an expression evaluator using Composite, Recursive Descendent Parser and Interpreter. Here's the grammar : [OR ]* [AND ]* RELOP | NOT | OPAR
StepTNT
  • 3,867
  • 7
  • 41
  • 82
10
votes
10 answers

Is INTERPRETER an anti-pattern?

To me, the Interpreter patten sounds very much like an anti-pattern known as Greenspun's tenth rule: Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common…
4
votes
2 answers

Interpreter Pattern example

I am curious to know a few real time examples of interpreter pattern. I am able to find a few repeated examples such as the "regular expression" example. Can anyone direct me towards other examples?
Aravindh
  • 137
  • 3
  • 13
2
votes
1 answer

Terminal and non terminal symbols

I am currently reading about the interpreter pattern and there it says something about Terminal and nonterminal symbols. So I went to wikipedia and read about it. But I still don't understand what a terminal and nonterminal symbol is. Can you give…
john
  • 41
  • 1
  • 5
2
votes
1 answer

Error Handling in Interpreter Pattern

Assume I want to add up either arabic numbers (1+2) or roman numbers (I+II) and I use an interpreter pattern that looks something like this: (code derived from here:…
1
vote
1 answer

Is Interpreter Pattern a form of Abstract Syntax Tree

I am learning GoF patterns and an example of interpreter pattern from Wikipedia article caught my attention: http://en.wikipedia.org/wiki/Interpreter_pattern (I am specifically looking into Java code snippet). It looks like an Abstract Syntax Tree…
0
votes
1 answer

What is the difference between the Interpreter pattern and Visitor pattern?

I have troubles understanding these two design patterns. Can you please give me contextual information or an example so I can get a clear idea and be able to map the difference between the two of them. Thanks.
0
votes
1 answer

decorator vs interpreter pattern

I recently learned interpreter pattern. I found some similarities betweeen decorator and interpreter. They have similar structure. I look in this case: one nonTerminal behaviour and one terminal behaviour in interpreter. It seems very similar to…
Vladimir Yanakiev
  • 1,240
  • 1
  • 16
  • 25