Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!






A haskell interpreter in Javascript

Posted by Johan Gustafsson, 18 May 2010 · 194 views

The report for my bachelor thesis has just been completed, a Haskell interpreter written i javascript. We were four people working on this project and my main responsibility was to make the parser, this meant stripping comment, applying the layout rules, parsing the actual grammar and generating the abstract syntax tree. Most of the language as it is specified in the Haskell 98 online report can be parsed, but we have not tested everything yet so there are probably a lot of bugs. The layout rules are applied correctly in most cases but some things like let expressions in list comprehensions does not expand correctly as we do not keep track of invalid and valid parsings for let expression, just of matching 'let ... in' expression do get the basic stuff working.

The simple lexer and the complete parser was made using a parser combinator library called JSParse and it worked out fine except that it does not keep track of line numbers, columns or which parser that failed so it is really hard to get any good error messages. There were also a couple of bugs in the butnot-parser and in the caching for the choice parser. I managed to fix both of them and the functioning version can be found at our git repository.

We do not support type classes at the moment but we will most likely fix that in the two coming weeks as we really want them in the final presentation of the project.

The source code for the whole project can be found at our git repository, feel free to clone it. http://github.com/johang88/haskellinjavascript

I have also put up an online demo at http://hiji.tinyrocket.se that works in firefox and chrome but internet explorer remains untested. The demo has a small part of the standard prelude library the definition of which can be found here http://hiji.tinyrocket.se/hs/Prelude.hs

Have a nice day

/ Johan




Bit late maybe, but have you looked at http://javascript.crockford.com/tdop/tdop.html for building a parser? Seems very suitable for this situation.
Nice find, looks like i missed that one.

December 2014 »

S M T W T F S
 123456
78910111213
14151617181920
21222324 25 2627
28293031   

Recent Comments

Recent Comments

PARTNERS