-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] fixes and npm testing #3
base: master
Are you sure you want to change the base?
Conversation
the parser workaround still produced errors for code, where multiple tokens were between a phony "regexp" and the final parse error consider this fragment, which produced an error ')' cannot be coerced to '/': if(u===i&&(0!==u||1/u==1/i)||u!==u&&i!==i){} This fix follows the solution found here https://github.com/antlr/grammars-v4/blob/3b25fdc6dc6a2ea74c000406e2439fdc1d2f64e7/ecmascript/JavaScript/ECMAScript.g4#L108
This implements a test runner capable of running transformed and original versions of a function side-by side and diffing the effect traces. The idea is, to be able to quickly verify behavioral equivalence of a CPS - transformed program, to its original, over varying (possibly generated) sets of inputs. the interface for a test is function(CONT, F, G, H, ..., M) { function(a, b, c, ..., h) { // << code >> } } where F, G, H, ..., M are effects available to the test code and a, b, c, ..., h are test case input values Effect Interface: Effects are regular functions, that would generally record their calling order, inputs and outputs to an effect trace and provide a programmable return value. In testing of transformed programs, effects may also program their continuation(s) and suspend. TBD Swapping out number-gen-async proved to be inconsistent. The traces have identical heads, until the (equivalently seeded) prng diverges. Whether this is due to an (undesirable) reordering of traces, or due to some problem with the prng isolation in the test suite is to be determined .. Larger (possibly generated) suits of program fragments, excercising JS' features could be created ...
cps-transformation.lisp
Outdated
(if (null statement-tail) | ||
;; No special handling is required when there's no statement tail | ||
(call-next-method) | ||
(cond |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This introduces some logic to handle labelled if-blocks by wrapping them in labelled statement blocks, but as it turns out, the then
and else
blocks can be labelled as well, and those can't be handled faithfully by wrapping the whole if
, because of break-label visibility.
So this is incomplete without 326635d, but that's a rewrite of if
, so I left it as a separate commit ..
ret.effect_id = \"number-gen\"; | ||
return ret; | ||
})")) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The next two forms generate a test runner in /tmp/foo/simple.js
, that you can run with cd /tmp/foo; node install random-seed deep-diff; node simple.js
Hi Herwig, Thanks, this is all awesome! I will try to get to look at the changes as soon as possible. Fair warning, this is code I wrote ten years ago and I am in the middle of getting ready for a transcontinental move and major job change, so it won't happen overnight. :) |
Hi James, Great, I'd love to hear your feedback! No worries about timing, I'm used to other people's timelines in open source and already more than happy, you answered & are interested. Best of fortune for your travels! |
Hi, I've stumbled over your project, when looking for .. well, a CPS transformer for javascript, that does what it should. It's pretty impressive, congrats!
I tried to apply it to some JS, I've got laying around and quickly found some lexer and parser bugs:
Each of the above fixes is rather simple, but WIP in the sense, that the parser fixes should probably be fixed in the descriptor file, right? I hope you can help there.
After those fixes, that made my 2.4M minified JS file parse (correctly?), I ran into two missing CPS transformations: breaks in labelled statement-blocks and (obviously) finally.
I implemented labelled blocks, but before trying finally (ha), I'd like to have (possibly generative) side-by-side testing in nodejs. The initial thing looks promising (see last commit), but I'll probably have to leave it for some time and come back later ..
I'll comment some more on the specific commits, feel free to leave feedback and request changes ..