<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>PHPDeveloper.org</title>
    <link>http://www.phpdeveloper.org</link>
    <description>Up-to-the Minute PHP News, views and community</description>
    <language>en-us</language>
    <pubDate>Sat, 18 May 2013 02:29:38 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Michael Nitschinger's Blog: Writing a simple lexer in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/17942</guid>
      <link>http://www.phpdeveloper.org/news/17942</link>
      <description><![CDATA[<p>
In <a href="http://nitschinger.at/Writing-a-simple-lexer-in-PHP">this new post</a> to his blog <i>Michael Nitschinger</i> shows you how to create a simple <a href="http://en.wikipedia.org/wiki/Lexical_analysis">lexer</a> to parse incoming content (like custom configuration files or anything that uses its own domain-specific language).
</p>
<blockquote>
A lot of developers avoid writing parsers because they think it's pretty hard to do so. Writing an efficient parser for a general purpose language (like PHP, Ruby, Java,...) is hard, but fortunately, most of the time we don't need that much complexity. Typically we just want to parse input coming from config files or from a specific problem domain (expressed through DSLs). DSLs (Domain Specific Languages) are pretty cool, because they allow you to express logic and flow in a very specific and convenient way for a limited set of tasks.
</blockquote>
<p>
He illustrates with an example based on the <a href="http://lithify.me/">Lithium</a> framework's routing engine and how it could parse a text file that relates a route to a controller/action combination. He creates a "Lexer" class that defines a few regular expressions to parse the incoming text strings for matches on things like whitespace, URLs and identifiers (words) and return each in the lexer's output. 
</p>]]></description>
      <pubDate>Thu, 10 May 2012 12:57:00 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Sameer Borate's Blog: Building a simple Parser and Lexer in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/17142</guid>
      <link>http://www.phpdeveloper.org/news/17142</link>
      <description><![CDATA[<p>
In a new post to his blog <i>Sameer Borate</i> shows how to <a href="http://www.codediesel.com/php/building-a-simple-parser-and-lexer-in-php/">create a lexer and parser</a> in PHP to work directly with the tokens of a PHP script.
</p>
<blockquote>
After looking around for a while [for a good resource on compilers] I settled for Terence Parr's <a href="http://www.amazon.com/Language-Implementation-Patterns-Domain-Specific-Programming/dp/193435645X/">Language Implementation Patterns</a>. This is exactly what I needed - bit sized patterns on compiler and parser design with working code. The book provides a recipe style approach, gradually moving from simple to complex compiler/parser design issues. As I primarily work with PHP, I thought of porting some code to PHP to see how it works.
</blockquote>
<p>
He shows examples <a href="http://www.codediesel.com/downloads/lexer-parser">using his custom tool</a> to show a basic lexer output for a list and a complete listing of the code involved. Ultimately, though, he finds that PHP isn't overly suited to the task - anything more than his simple example could be more trouble than it's worth.
</p>]]></description>
      <pubDate>Thu, 17 Nov 2011 11:57:59 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Erling Alf Ellingsen's Blog: PHP Must Die]]></title>
      <guid>http://www.phpdeveloper.org/news/13816</guid>
      <link>http://www.phpdeveloper.org/news/13816</link>
      <description><![CDATA[<p>
In a <a href="http://www.steike.com/code/php-must-die/">(slightly inflammatory) post</a> to his blog today <i>Erling Alf Ellingsen</i> shares why he thinks that "PHP must die", mostly due to some of the inconsistencies his has with other languages.
</p>
<p>His examples include:</p>
<ul>
<li>String vs. numeric handling 
<li>That PHP supports octal numbers "by accident"
<li>A lexer bug with hex values
<li>A parser bug involving the ternary operator
</ul>
<p>
<a href="http://www.steike.com/code/php-must-die/#comments">Comments</a> on the post include those supporting the "die" opinion - that PHP just doesn't have it together like other languages - and those taking a bit more balanced approach on PHP's strengths and weaknesses.
</p>]]></description>
      <pubDate>Mon, 11 Jan 2010 13:49:41 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Abhinav Singh's Blog: PHP tokens & opcodes: 3 useful extensions for understanding the Zend Engine]]></title>
      <guid>http://www.phpdeveloper.org/news/13584</guid>
      <link>http://www.phpdeveloper.org/news/13584</link>
      <description><![CDATA[<p>
<i>Abhinav Singh</i> has <a href="http://abhinavsingh.com/blog/2009/11/php-tokens-and-opcodes-3-useful-extensions-for-understanding-the-working-of-zend-engine/">a recent post</a> to his blog looking at three extensions that you can use to help understand the inner workings of the core Zend Engine.
</p>
<blockquote>
"PHP tokens and opcodes" - When a PHP script is executed it goes through a number of processes, before the final result is displayed. These processes are namely: Lexing, Parsing, Compiling and Executing. In this blog post, I will walk you through all these processes with a sample example. In the end I will list some useful PHP extensions, which can be used to analyze results of every intermediate process.
</blockquote>
<p>
He touches on the steps the average PHP script takes in its processing - lexing, parsing/compiling and the actual execution of the opcodes. The <a href="http://www.php.net/manual/en/ref.tokenizer.php">tokenizer</a>, <a href="http://www.php.net/manual/en/ref.parsekit.php">parsekit</a> and <a href="http://derickrethans.nl/vld.php">VLD</a> (Vulcan Logic Disassembler) extensions can help you get down into the nuts and bolts of the language and the engine that makes it work.
</p>]]></description>
      <pubDate>Tue, 24 Nov 2009 11:32:31 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Wez Furlong's Blog: parser and lexer generators for PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/6771</guid>
      <link>http://www.phpdeveloper.org/news/6771</link>
      <description><![CDATA[<p>
When finding he was in need of a parser and lexer, <i>Wez Furlong</i> decided to work up one that was PHP-based and a take off of the popular <a href="http://www.hwaci.com/sw/lemon/lemon.html">lemon</a> parser and <a href="http://www.cs.princeton.edu/~appel/modern/java/JLex/">JLex</a> lexer.
</p>
<blockquote>
From time to time, I find that I need to put a parser together. Most of the time I find that I need to do this in C for performance, but other times I just want something convenient, like PHP, and have been out of luck.
</blockquote>
<p>
<a href="http://netevil.org/node.php?nid=941">His result</a> is two new packages - <a href="http://netevil.org/downloads/lemon-php-151.tgz">lemon-php</a> and <a href="http://netevil.org/downloads/JLexPHP-151.tgz">JLexPHP</a> (under a BSDish license) you can download and compile on your own system.
</p>
<p>
Also, if you'll remember a while back, <i>Greg Beaver</i> had wanted something similar (as <a href="http://netevil.org/node.php?nid=941&SC=1#comments">mentioned in the comments</a>) and <a href="http://www.phpdeveloper.org/news/6181">created his own</a> lexer/generator as well.
</p>]]></description>
      <pubDate>Mon, 27 Nov 2006 09:34:00 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Greg Beaver's Blog: PHP_ParserGenerator and PHP_LexerGenerator]]></title>
      <guid>http://www.phpdeveloper.org/news/5678</guid>
      <link>http://www.phpdeveloper.org/news/5678</link>
      <description><![CDATA[<p>
<i>Greg Beaver</i> has blogged today with <a href="http://greg.chiaraquartet.net/archives/138-PHP_ParserGenerator-and-PHP_LexerGenerator.html">more about</a> the port he's been wokring on of the Lemon parser generator to PHP5, this time discussion the creation of two packages - PHP_ParserGenerator and PHP_LexerGenerator.
</p>
<blockquote>
<p>
Last week, I blogged about completing a port of the Lemon parser generator to PHP 5, which I thought was pretty cool. However, in an email, Alex Merz pointed out that without a lexer generator to accompany lemon, it's pretty difficult to write a decent parser.
</p>
<p>
After Alex's email, I started thinking about what it would take to write a lexer generator. Basically, a lexer generator requires parsing and compiling regular expressions, then scanning the source one character at a time to find matches. So, it occurred to me that perhaps simply combining regular expressions with sub-patterns could accomplish this task quite easily.
</p>
</blockquote>
<p>
He <a href="http://greg.chiaraquartet.net/archives/138-PHP_ParserGenerator-and-PHP_LexerGenerator.html">goes on</a> to explain this process, showing how a simple regular expresion call (and a look at its return arguments) could create a simple, easy solution. Since the <a href="http://re2c.org">re2c</a> format is still unsupported in PHP (without a goto to go to), he opts to stick with the regular expressions and creates a "lex2php" format instead.
</p>
<p>
He's packaged up both halves of <a href="http://greg.chiaraquartet.net/archives/138-PHP_ParserGenerator-and-PHP_LexerGenerator.html">this setup</a> and has already posted proposals for them to the PEAR site:
<ul>
<li><a href="http://pear.php.net/pepr/pepr-proposal-show.php?id=415">PHP_LexerGenerator</a>
<li><a href="http://pear.php.net/pepr/pepr-proposal-show.php?id=416">PHP_ParserGenerator</a>
</ul>
</p>]]></description>
      <pubDate>Sun, 25 Jun 2006 17:00:41 -0500</pubDate>
    </item>
  </channel>
</rss>
