Programming
Article
By Harry Fuecks

J4P5: Javascript For PHP5

By Harry Fuecks
Help us help you! You'll get a... FREE 6-Month Subscription to SitePoint Premium Plus you'll go in the draw to WIN a new Macbook SitePoint 2017 Survey Yes, let's Do this It only takes 5 min

Need a distraction? Check out J4P5;

J4P5 is a JavaScript interpreter written in PHP 5, that allows to run untrusted scripts in a sandbox on your server. It aims to implement most of Ecma-262 3d edition.

I kid you not. In fact this looks like a pretty serious attempt. You’ll need to download and run yourself. There’s grammar rules for Javascript in there and a Javascript runtime written in PHP. It passes the “it works” test – the examples run straight out of $ unzip. Looking at what it does and the TODO list, aside from the Unicode issue strikes me J4P5 is already more than 50% of the way there.

Aside from novelty, one real world use might be an extension to SimpleTest’s web testing capabilities. With a little work there’s also potential to create an awesome Javascript source compressor – the lexing patterns are all there.

Need yet more distraction? Try metaphp from which J4P5 got it’s parser generator. Quite what metaphp was (is?) trying to achieve I’m not sure – seems to be attempting to build a higher level language on top of PHP with some ORM and functional programming in there for good measure (the FP stuff in the download is pretty interesting). Anyway – it produced a parser generator good enough implement a Javascript parser.

Anyone for R4P5? ;)

Login or Create Account to Comment
Login Create Account
Recommended
Sponsors
Get the most important and interesting stories in tech. Straight to your inbox, daily.Is it good?