Home arrow PHP arrow Manipulating String Literals with Interpreter Classes in PHP 5

Manipulating String Literals with Interpreter Classes in PHP 5

Among the huge variety of design patterns that can be easily implemented in PHP 5, the interpreter is one that might be particularly interesting to you. It allows you to build effortlessly the so-called parser layers. Welcome to the second installment of the series that began with “Building Interpreter Classes with PHP 5.” Made up of three parts, this series introduces the core concepts on this useful pattern, and also complements its theory with numerous educational hands-on examples.

TABLE OF CONTENTS:
  1. Manipulating String Literals with Interpreter Classes in PHP 5
  2. Handling literals
  3. Defining a string interpreter class
  4. Parsing string commands by using the StringInterpreter class
By: Alejandro Gervasio
Rating: starstarstarstarstar / 5
April 09, 2007

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Introduction

Stepping back for a moment to the preceding article of the series, I’m pretty sure that all the concepts deployed in that tutorial concerning the concrete implementation of the interpreter pattern in PHP 5 will be familiar to you now. However, if that’s not the case, let me remind you quickly how this pattern works, so you can grasp more easily all the code samples that I plan to include in this article.

In plain terms, where this pattern is applied, there’s a class, usually called “interpreter,” which is responsible for parsing a predefined set of commands. These commands are sent out by one or more additional classes. As you can see, this definition is easy to understand because it is similar to the concept of parsers.

However, building interpreter classes is by far a much simpler process than developing full-featured parsers. I hope to demonstrate this by showing you some didactical code samples, where this pattern will be mostly used as a simple yet efficient parsing layer.

Bearing in mind that in the first article of the series I illustrated how to use an interpreter class to handle a group of fictional users, in this tutorial I’m going to go teach you how to utilize this pattern for manipulating a set of string processing classes.

By the end of this tutorial, you should be equipped with a solid background in how the interpreter pattern works. This may be very useful to you, particularly if you’re taking your first steps into pattern-based programming with PHP 5.

Now, having outlined the topics that will be covered in the next few lines, it’s time to move on and continue learning more on how to build interpreter classes. Let’s get started now!



 
 
>>> More PHP Articles          >>> More By Alejandro Gervasio
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: