Jump to content

  • Log In with Google      Sign In   
  • Create Account





A haskell interpreter in Javascript

Posted by Johan Gustafsson, 18 May 2010 · 189 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.

October 2014 »

S M T W T F S
   1234
567891011
12131415161718
19 20 2122232425
262728293031 

Recent Comments

Recent Comments

PARTNERS