The language-javascript package

[Tags: bsd3, library]

Parses Javascript into an Abstract Syntax Tree (AST). Initially intended as frontend to hjsmin.

Note: Version 0.5.0 breaks compatibility with prior versions, the AST has been reworked to allow round trip processing of JavaScript.

[Skip to ReadMe]


Versions0.0.1, 0.0.2, 0.0.3, 0.1.0, 0.2.0, 0.2.1, 0.2.2, 0.3.0, 0.4.0, 0.4.1, 0.4.2, 0.4.3, 0.4.4, 0.4.5, 0.4.6, 0.4.7, 0.4.8, 0.4.9, 0.4.10, 0.5.0, 0.5.1, 0.5.2, 0.5.3, 0.5.4, 0.5.5, 0.5.6, 0.5.7, 0.5.8, 0.5.9, 0.5.11, 0.5.12, 0.5.13,,,,,,,
Change logNone available
Dependenciesarray (>=0.3 && <0.5), base (==4.*), blaze-builder (>=0.2 && <1), bytestring (>=0.9.1 && <1), containers (>=0.2 && <0.5), mtl (>=1.1 && <2.9), utf8-light (>=0.4 && <1.0), utf8-string (>=0.3.7 && <1) [details]
Copyright(c) 2010,2011,2012 Alan Zimmerman
AuthorAlan Zimmerman
Home page
Bug tracker
Source repositoryhead: git clone git://
UploadedMon Apr 23 18:24:37 UTC 2012 by AlanZimmerman
DistributionsDebian:, Fedora:0.5.13, FreeBSD:, LTSHaskell:, NixOS:, Stackage:
Downloads30947 total (202 in last 30 days)
0 []
StatusDocs uploaded by user
Build status unknown [no reports yet]




Maintainers' corner

For package maintainers and hackage trustees

Readme for language-javascript-0.5.3

Parser for JavaScript

Based (loosely) on language-python

How to build


cabal clean && cabal configure && cabal build


cabal clean && cabal configure -fbuildtests && cabal build

Running the tests


To debug the grammar

happy -iparse.txt -g -a  -d src/Language/JavaScript/Parser/Grammar5.y

This generates src/Language/JavaScript/Parser/Grammar.hs, delete this
when done with the debug version

UTF8/Unicode version

Alex 3.0 now supports unicode natively, and has been included as a
dependency in the cabal file.


0.5.3 Merge pull requests from @aszlig to add octal support, and to
      allow leading zeros in exponents

0.5.2 Merged pull request from @markwright added some missing test
      files to the cabal file.
      Added and Lexer.x to the cabal file.

0.5.1 Export CommentAnnotation(..). Simplify AST by getting rid of
      JSFunctionBody, JSSourceElements, JSStatementBlock, JSStatementList.
      They are replaced by JSBlock or a simple list.
      Also fix lexer mode in presence of whitespace.
      Changed way tests are invoked, to allow Travis integration.

0.5.0 Rework AST to allow full round-trip parsing and output of
      JavaScript. Breaks AST compatibility with prior versions

0.4.10 Moved Lexer.x into a separate directory, and made a script to
       call alex to generate Lexer.hs. This means alex is not required
       at install time

0.4.9 Make alex and happy versions more explicit. Expose the AlexSpan
      data type, so parse error positions can be reported.

0.4.8 Close issue by
      correcting the lexical analyser for DecimalLiteral

0.4.7 Continue ECMASCRIPT update, remove incorrect future reserved words for
      "code", "mode", "of", "one", "or" and "strict", put in by accident/stupidity.

0.4.6 Update to ECMASCRIPT 5.1 by allowing continuations in string literals
      Include build dependencies on alex >= 3.0 and happy.

0.4.5 Update cabal file and docs for Alex 3.0, giving out of the box unicode support

0.4.4 Allow unicode characters in comments

0.4.3 correct lexer for decimalToken, only leading digit needs to be non-zero.

0.4.2 Expose SrcSpan

0.4.1 Expose AST.Node as well.

0.4.0 Updated JSNode to include location information, and made the parse more true to the original by leaving blocks as such, not replacing with ';'.

0.3.0 ECMA-262 edition 5 compliance.  Required adding JSFunctionExpression and JSPropertyAccessor to the AST.

0.2.2 Heading toward compliance with edition 5. Trailing commas allowed in array literals too.

0.2.1 Allow trailing comma in object literal

0.2.0 ECMAScript 3 allows function expressions to have names, AST.JSFunctionExpression now reflects this

0.1.0 Simplified AST by removing JSElement and JSElementList components

0.0.3 Support for unicode in source. At the moment it only supports
UTF8 encoding, does not recognise byte order marks or UTF-16/UTF-32

0.0.2 Multiline comments were processed in greedy form, now end of
comment recognised properly. Thanks to Tony Morris for reporting this.

0.0.1 Initial release