<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Rewriting JavaScript</title>
	<atom:link href="http://blog.mozilla.com/tglek/2007/10/24/rewriting-javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.mozilla.com/tglek/2007/10/24/rewriting-javascript/</link>
	<description>Just another Blog.mozilla.com weblog</description>
	<lastBuildDate>Sun, 12 Feb 2012 07:38:09 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: fredrik</title>
		<link>http://blog.mozilla.com/tglek/2007/10/24/rewriting-javascript/comment-page-1/#comment-4913</link>
		<dc:creator>fredrik</dc:creator>
		<pubDate>Fri, 26 Oct 2007 08:55:09 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mozilla.com/tglek/2007/10/24/rewriting-javascript/#comment-4913</guid>
		<description>Yeah, it sounds like a lot of fun.</description>
		<content:encoded><![CDATA[<p>Yeah, it sounds like a lot of fun.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tglek</title>
		<link>http://blog.mozilla.com/tglek/2007/10/24/rewriting-javascript/comment-page-1/#comment-4903</link>
		<dc:creator>tglek</dc:creator>
		<pubDate>Thu, 25 Oct 2007 18:29:39 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mozilla.com/tglek/2007/10/24/rewriting-javascript/#comment-4903</guid>
		<description>fredrik,
Yes dehydra tries to simplify the ast as much as possible before passing it to js. It just so happens that it starts from an Elsa AST.

In reality to be compatible with DeHydra, one can just provide the standard API and call the same callbacks that DeHydra scripts expect from any other JS program(including a webpage?). Thus JSON is a natural choice since one can write the simplification step in JS to keep life really simple :)

Any chance of you wanting to play with the easier approach?</description>
		<content:encoded><![CDATA[<p>fredrik,<br />
Yes dehydra tries to simplify the ast as much as possible before passing it to js. It just so happens that it starts from an Elsa AST.</p>
<p>In reality to be compatible with DeHydra, one can just provide the standard API and call the same callbacks that DeHydra scripts expect from any other JS program(including a webpage?). Thus JSON is a natural choice since one can write the simplification step in JS to keep life really simple <img src='http://blog.mozilla.com/tglek/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Any chance of you wanting to play with the easier approach?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: fredrik</title>
		<link>http://blog.mozilla.com/tglek/2007/10/24/rewriting-javascript/comment-page-1/#comment-4901</link>
		<dc:creator>fredrik</dc:creator>
		<pubDate>Thu, 25 Oct 2007 17:57:24 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mozilla.com/tglek/2007/10/24/rewriting-javascript/#comment-4901</guid>
		<description>But DeHydra does consume the AST that Elsa/Oink spits out on some level, no? Through a syntax tree visitor (JSVisitor IIRC). That&#039;s what I gathered from browsing the code at least. 

I just figured that if that was the common ground, having DeHydra just needing to understand the AST format produced by astgen, it would make things easier (barring AST node name problems). You could still use SpiderMonkey, have it output the JSON and then build the AST from that (or just build it directly). It&#039;s entirely possible I&#039;m wrong.

You&#039;re correct re: the catch-up problems with SpiderMonkey, and that was one of my major concerns. It&#039;s probably thankless to use Elkhound/astgen for JavaScript, both short- and long-term now that I think about it. Saves me wasting time on it :).</description>
		<content:encoded><![CDATA[<p>But DeHydra does consume the AST that Elsa/Oink spits out on some level, no? Through a syntax tree visitor (JSVisitor IIRC). That&#8217;s what I gathered from browsing the code at least. </p>
<p>I just figured that if that was the common ground, having DeHydra just needing to understand the AST format produced by astgen, it would make things easier (barring AST node name problems). You could still use SpiderMonkey, have it output the JSON and then build the AST from that (or just build it directly). It&#8217;s entirely possible I&#8217;m wrong.</p>
<p>You&#8217;re correct re: the catch-up problems with SpiderMonkey, and that was one of my major concerns. It&#8217;s probably thankless to use Elkhound/astgen for JavaScript, both short- and long-term now that I think about it. Saves me wasting time on it <img src='http://blog.mozilla.com/tglek/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tglek</title>
		<link>http://blog.mozilla.com/tglek/2007/10/24/rewriting-javascript/comment-page-1/#comment-4892</link>
		<dc:creator>tglek</dc:creator>
		<pubDate>Thu, 25 Oct 2007 16:01:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mozilla.com/tglek/2007/10/24/rewriting-javascript/#comment-4892</guid>
		<description>fredrik,

DeHydra actually doesn&#039;t use the astgen stuff because it&#039;s way too low level. I think writing a new JS parser in C++ doesn&#039;t really make sense for a few reasons:
a) SpiderMonkey is the &quot;standard&quot; parser that you&#039;d have to play catchup with every time someone adds a feature(or a bug) to the language. I&#039;m in that boat with elsa and C++ right now, it sucks.
b) There is Esc a new ecmascript compiler written in JS. Using JSON as an intermediate format should make it fairly simple to switch to a pure-JS solution as soon as that becomes available.
We should talk about your work some more, sounds cool.

Justin &amp; Axel, thanks for the heads up. As long as it&#039;s just simple conditionals, we should be able to pretend that there is no preprocessor. Please tell me that there aren&#039;t any function-like macros in this. In the worst case I can reuse my MCPP work on this.

Gijs, as I said to fredrik, it&#039;s nice to use the &quot;standard&quot; even if it is a little painful.</description>
		<content:encoded><![CDATA[<p>fredrik,</p>
<p>DeHydra actually doesn&#8217;t use the astgen stuff because it&#8217;s way too low level. I think writing a new JS parser in C++ doesn&#8217;t really make sense for a few reasons:<br />
a) SpiderMonkey is the &#8220;standard&#8221; parser that you&#8217;d have to play catchup with every time someone adds a feature(or a bug) to the language. I&#8217;m in that boat with elsa and C++ right now, it sucks.<br />
b) There is Esc a new ecmascript compiler written in JS. Using JSON as an intermediate format should make it fairly simple to switch to a pure-JS solution as soon as that becomes available.<br />
We should talk about your work some more, sounds cool.</p>
<p>Justin &amp; Axel, thanks for the heads up. As long as it&#8217;s just simple conditionals, we should be able to pretend that there is no preprocessor. Please tell me that there aren&#8217;t any function-like macros in this. In the worst case I can reuse my MCPP work on this.</p>
<p>Gijs, as I said to fredrik, it&#8217;s nice to use the &#8220;standard&#8221; even if it is a little painful.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gijs</title>
		<link>http://blog.mozilla.com/tglek/2007/10/24/rewriting-javascript/comment-page-1/#comment-4891</link>
		<dc:creator>Gijs</dc:creator>
		<pubDate>Thu, 25 Oct 2007 15:55:04 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mozilla.com/tglek/2007/10/24/rewriting-javascript/#comment-4891</guid>
		<description>I hope you know that there is a JS JS parser (narcissus) in the tree? And there&#039;s Rhino, of course, and I was told ages ago that the Parrot people were &quot;working on it&quot; as far as JS support was concerned. So maybe those would be easier to use than Spidermonkey?</description>
		<content:encoded><![CDATA[<p>I hope you know that there is a JS JS parser (narcissus) in the tree? And there&#8217;s Rhino, of course, and I was told ages ago that the Parrot people were &#8220;working on it&#8221; as far as JS support was concerned. So maybe those would be easier to use than Spidermonkey?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Axel Hecht</title>
		<link>http://blog.mozilla.com/tglek/2007/10/24/rewriting-javascript/comment-page-1/#comment-4889</link>
		<dc:creator>Axel Hecht</dc:creator>
		<pubDate>Thu, 25 Oct 2007 08:13:49 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mozilla.com/tglek/2007/10/24/rewriting-javascript/#comment-4889</guid>
		<description>I think we actually feed most of our js through the xul preprocessor now. I guess most of it just passes through unchanged, but some of it is actually modified. Not as bad as C++ is, of course.

http://mxr.mozilla.org/mozilla/search?string=%23if&amp;find=%5C.js%24&amp;findi=%5C.xul%24&amp;filter=&amp;tree=mozilla has examples.</description>
		<content:encoded><![CDATA[<p>I think we actually feed most of our js through the xul preprocessor now. I guess most of it just passes through unchanged, but some of it is actually modified. Not as bad as C++ is, of course.</p>
<p><a href="http://mxr.mozilla.org/mozilla/search?string=%23if&#038;find=%5C.js%24&#038;findi=%5C.xul%24&#038;filter=&#038;tree=mozilla" rel="nofollow">http://mxr.mozilla.org/mozilla/search?string=%23if&#038;find=%5C.js%24&#038;findi=%5C.xul%24&#038;filter=&#038;tree=mozilla</a> has examples.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: fredrik</title>
		<link>http://blog.mozilla.com/tglek/2007/10/24/rewriting-javascript/comment-page-1/#comment-4888</link>
		<dc:creator>fredrik</dc:creator>
		<pubDate>Thu, 25 Oct 2007 08:12:08 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mozilla.com/tglek/2007/10/24/rewriting-javascript/#comment-4888</guid>
		<description>To learn a little about the Elsa backend stuff, I wrote a small Lua parser using Flex/Elkhound/astgen. (Well, it doesn&#039;t build an AST yet because I fell ill with the cold from hell, but that shouldn&#039;t be too hard to knock out once my head isn&#039;t filled with cotton. It spits out parse trees like there&#039;s no tomorrow, though.)

My goal with this is to ultimately build a JavaScript parser for the very reason you mentioned. To be able to run DeHydra on it seamlessly. 

You using SpiderMonkey is one of those &quot;I wish I&#039;d thought of that&quot; moments. You could even bridge the JSON output through astgen so you needn&#039;t do too much to DeHydra in terms of how it interfaces to the representation of the underlying program you&#039;re rewriting (essentially replacing Flex/Elkhound with SpiderMonkey itself, astgen and some glue).

I&#039;m personally excited about the possibilities of extending all this to a toolkit for rewriting any language you can write a &quot;plug-in&quot; for. Possibly, source-to-source transformations between languages (many languages are, on some level, isomorphic). C++ to JS2 would be cool.</description>
		<content:encoded><![CDATA[<p>To learn a little about the Elsa backend stuff, I wrote a small Lua parser using Flex/Elkhound/astgen. (Well, it doesn&#8217;t build an AST yet because I fell ill with the cold from hell, but that shouldn&#8217;t be too hard to knock out once my head isn&#8217;t filled with cotton. It spits out parse trees like there&#8217;s no tomorrow, though.)</p>
<p>My goal with this is to ultimately build a JavaScript parser for the very reason you mentioned. To be able to run DeHydra on it seamlessly. </p>
<p>You using SpiderMonkey is one of those &#8220;I wish I&#8217;d thought of that&#8221; moments. You could even bridge the JSON output through astgen so you needn&#8217;t do too much to DeHydra in terms of how it interfaces to the representation of the underlying program you&#8217;re rewriting (essentially replacing Flex/Elkhound with SpiderMonkey itself, astgen and some glue).</p>
<p>I&#8217;m personally excited about the possibilities of extending all this to a toolkit for rewriting any language you can write a &#8220;plug-in&#8221; for. Possibly, source-to-source transformations between languages (many languages are, on some level, isomorphic). C++ to JS2 would be cool.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Justin Dolske</title>
		<link>http://blog.mozilla.com/tglek/2007/10/24/rewriting-javascript/comment-page-1/#comment-4887</link>
		<dc:creator>Justin Dolske</dc:creator>
		<pubDate>Thu, 25 Oct 2007 06:27:24 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mozilla.com/tglek/2007/10/24/rewriting-javascript/#comment-4887</guid>
		<description>No JS preprocessing? :-)

http://mxr.mozilla.org/seamonkey/search?string=ifdef&amp;find=\.js&amp;tree=seamonkey

Not anyway as bad as our C++, of course.</description>
		<content:encoded><![CDATA[<p>No JS preprocessing? <img src='http://blog.mozilla.com/tglek/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><a href="http://mxr.mozilla.org/seamonkey/search?string=ifdef&#038;find=" rel="nofollow">http://mxr.mozilla.org/seamonkey/search?string=ifdef&#038;find=</a>\.js&amp;tree=seamonkey</p>
<p>Not anyway as bad as our C++, of course.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

