Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Swift 2 Design Patterns

You're reading from   Swift 2 Design Patterns Build robust and scalable iOS and Mac OS X game applications

Arrow left icon
Product type Paperback
Published in Oct 2015
Publisher
ISBN-13 9781785887611
Length 224 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Julien Lange Julien Lange
Author Profile Icon Julien Lange
Julien Lange
Arrow right icon
View More author details
Toc

The interpreter pattern


The interpreter pattern is not really used, but it can be really useful. Usually, this pattern is described in terms of formal grammar but the area where it can be applied, can be extended.

You can refer to the following for more information: Lecture de chiffre Romain (http://www.oodesign.com/interpreter-pattern.html) and https://en.wikipedia.org/wiki/Roman_numerals.

Roles

The interpreter pattern defines an object representation of a language grammar in order to evaluate some expression written in this language by interpreting them.

This pattern can be used to interpret some expressions that are represented as a hierarchical tree. It may be applied when:

  • Grammar of expression is simple

  • Evaluation doesn't need to be quick

Some examples where this pattern can be used are:

  • In rule engines

  • To add some functionality to the composite pattern

Design

The implementation of this pattern is seen in the use of the composite pattern applied to represent a grammar (refer to the The composite...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image