<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Web 2.1 &#187; rainy day</title>
	<atom:link href="http://web.2point1.com/tag/rainy-day/feed/" rel="self" type="application/rss+xml" />
	<link>http://web.2point1.com</link>
	<description>Tim Whitlock&#039;s home in the Blogohedron</description>
	<lastBuildDate>Thu, 13 May 2010 21:26:34 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>jParser and jTokenizer released</title>
		<link>http://web.2point1.com/2009/11/14/jparser-and-jtokenizer-released/</link>
		<comments>http://web.2point1.com/2009/11/14/jparser-and-jtokenizer-released/#comments</comments>
		<pubDate>Sat, 14 Nov 2009 17:24:52 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jParser]]></category>
		<category><![CDATA[parsing]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[rainy day]]></category>

		<guid isPermaLink="false">http://web.2point1.com/?p=243</guid>
		<description><![CDATA[After nearly two years I&#8217;ve finally gotten around to releasing my PHP JavaScript parser, although documentation is still thin on the ground.

Download jParser 1.0.0 (recommended)

Download jParser devel package (Full source and build scripts)
See the library examples running at timwhitlock.info/jparser

The library has been split in two:

jTokenizer &#8211; A JavaScript tokenizer designed to mimic the PHP tokenizer.
jParser [...]]]></description>
			<content:encoded><![CDATA[<p>After nearly two years I&#8217;ve <em>finally</em> gotten around to releasing my PHP JavaScript parser, although documentation is still thin on the ground.</p>
<ul>
<li><strong><a href="http://web.2point1.com/wp-content/uploads/2009/11/jparser-1-0-0.tgz">Download jParser 1.0.0</a> </strong><strong>(recommended)<br />
</strong></li>
<li><a href="http://web.2point1.com/wp-content/uploads/2009/11/jparser-devel-1-0-0.tgz">Download jParser devel package</a> (Full source and build scripts)</li>
<li>See the library examples running at <a href="http://timwhitlock.info/jparser/" target="_blank">timwhitlock.info/jparser</a></li>
</ul>
<p>The library has been split in two:</p>
<ol>
<li><strong>jTokenizer</strong> &#8211; A JavaScript tokenizer designed to mimic the <a href="http://www.php.net/manual/en/book.tokenizer.php" target="_blank">PHP tokenizer</a>.</li>
<li><strong>jParser </strong>- The fully blown JavaScript syntactical parser which generates a parse tree.</li>
</ol>
<p><span id="more-243"></span>The reason for the split is that for most purposes where you think you need a parser, you in fact just need a tokenizer. The tokenizer library is about 15KB, whereas the parser is over 700KB (minified), so you can see why you might not want to include it unnecessarily.</p>
<p>The library files <code>jparser.php</code> and <code>jtokenizer.php</code> are self-contained, minified files for production use. If you wish to inspect or modify the code you will need to download the devel package. This package provides a build script which collates the libraries into their distributable files.</p>
<h3>jTokenizer</h3>
<p>Possible uses for the tokenizer include code highlighting and simple manipulation of JavaScript source code.</p>
<p>The main function you will want to use is <code>j_token_get_all</code> which behaves the same as the PHP <a href="http://www.php.net/manual/en/function.token-get-all.php" target="_blank">token_get_all</a> function with the addition of a column number as well as a line number. Additionally there is the <code>j_token_name</code> as per the PHP <a href="http://www.php.net/manual/en/function.token-name.php" target="_blank">token_name</a> function.</p>
<h3>jParser</h3>
<p>This is a full, syntactical parser. On its own it simply generates a parse tree which can be traversed and manipulated. There is no proper documentation on this yet, but take a look at the node classes in the devel package if you are serious about doing something useful with this parser.</p>
<h3>Some other notes in no particular order</h3>
<p>The full parser uses a lot of juice. I recommend giving PHP loads of memory, and be careful what you throw at it if you&#8217;re going to run it on a production server.</p>
<p>A parser is not an interpreter or a JavaScript engine. If you want to develop such a thing in PHP you might be insane, but it could be done with this parser as a base.</p>
<p>The JParser parse tree is purposefully not a full tree, it collapses redundant nodes to save memory. If you want to see a full tree then take a look at the <code>JParserRaw</code> class. (devel package required)</p>
<p>Splitting the parsing process into two parts (tokenize/parse) is probably not the most efficient and probably uses more memory than it would another way. However, I figured it would be neat to mimic the PHP tokenizer functionality so that parsers could be built that take a stream of PHP tokens.</p>
]]></content:encoded>
			<wfw:commentRss>http://web.2point1.com/2009/11/14/jparser-and-jtokenizer-released/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
