K
Karl Tikjøb Krukow
I recently started playing with the idea of writing a partial evaluator
for JavaScript in JavaScript. I have tried to build a minimal
proof-of-concept by extending Crockford's Pratt parser for 'simplified'
JavaScript [1].
The current (very experimental) version extends Function.prototype with
a specialize function so e.g.,
var mk_tag = function(tag,clz,cont) {
return "<"+tag+" class='"+clz+"'>"+cont+"</"+tag+">";
};
var mk_div_green = mk_tag.specialize({tag:'div', clz: 'green'});
mk_div_green("Pratt rocks!");
//result: <div class='green'>Pratt rocks!</div>
I've started an open source project, Jeene [2], and I thought you
hardcore JavaScripters might be interested. There are some portability
issues, e.g., it depends on Function.prototype.toString to obtain a
parseable representation of a function. A problem here is that
ECMAScript 3 says that the result of toString is "implementation
dependent". I am hoping for project Harmony to strengthen the contract
on toString, but I don't feel sure that will happen ;-)
Anyway, hope to have triggered some interest!
for JavaScript in JavaScript. I have tried to build a minimal
proof-of-concept by extending Crockford's Pratt parser for 'simplified'
JavaScript [1].
The current (very experimental) version extends Function.prototype with
a specialize function so e.g.,
var mk_tag = function(tag,clz,cont) {
return "<"+tag+" class='"+clz+"'>"+cont+"</"+tag+">";
};
var mk_div_green = mk_tag.specialize({tag:'div', clz: 'green'});
mk_div_green("Pratt rocks!");
//result: <div class='green'>Pratt rocks!</div>
I've started an open source project, Jeene [2], and I thought you
hardcore JavaScripters might be interested. There are some portability
issues, e.g., it depends on Function.prototype.toString to obtain a
parseable representation of a function. A problem here is that
ECMAScript 3 says that the result of toString is "implementation
dependent". I am hoping for project Harmony to strengthen the contract
on toString, but I don't feel sure that will happen ;-)
Anyway, hope to have triggered some interest!