> My first go at it went pretty much like op-overloading. I came by an issue, though. It seems Shaper.parseExpression accepts only ~valid~ JavaScript. This is kind of sensible since it uses Narcissus as backend...
Shaper is an extensible framework for JavaScript syntax tree shaping, thus it requires well formed JavaScript. It is possible to add extra info to the syntax tree by annotations (as done in bitwiser) and it's also possible to change the semantics (as done in restricter), but you cannot change the syntax of the input language.
/Olov
/Olov
> Do you think it would be feasible to make it possible to do this kind of stuff dynamically via JSShaper API? No idea if that's easy or anything... It just happens to be a really cool possibility even though you stated that the project's main goal is to provide JS to JS kind of transformations.
It would bring in an awful lot of complexity and would require making the JS lexer and parser pluggable. I can see how it could be useful for some, but it's not a direction I plan to pursue with Shaper. If you want to create a compiler for a new language (targeting JS), starting out from scratch syntax-wise might be something to consider, like CoffeeScript did.
/Olov