language-javascript
Parser for JavaScript
https://github.com/erikd/language-javascript
LTS Haskell 23.27: | 0.7.1.0 |
Stackage Nightly 2025-07-12: | 0.7.1.0 |
Latest on Hackage: | 0.7.1.0 |
language-javascript-0.7.1.0@sha256:3c68380fc4794475ff4ebec608f8cf7ce9b15b9b69eb938d423f8aafdefbe0d7,3865
Module documentation for 0.7.1.0
- Language
- Language.JavaScript
- Language.JavaScript.Parser
- Language.JavaScript.Pretty
- Language.JavaScript.Process
- Language.JavaScript
Parser for JavaScript
Based (loosely) on language-python
Two Versions
There are currently two versions:
0.5 series : Is a continuation of the 0.5.X.Y series, from the [master](https://github.com/erikd/language-javascript/tree/master) branch of thisgithub repository.
0.6 and 0.7 series : This has a vastly different and improved AST which makes if farmore difficult to build an non-sensical Javascript AST. This code is in thenew-ast branch ofthis github repository.
How to build
Make sure your locale supports UTF-8. For example, on most Unix-like platforms,you can type:
export LC_ALL=en_US.UTF-8
Library:
cabal clean && cabal configure && cabal build
Tests:
cabal clean && cabal configure -fbuildtests && cabal build
Running the tests
./dist/build/runtests/runtests
To debug the grammar
happy -iparse.txt -g -a -d src/Language/JavaScript/Parser/Grammar5.y
This generates src/Language/JavaScript/Parser/Grammar5.hs, delete thiswhen done with the debug version
UTF8/Unicode version
Alex 3.0 now supports unicode natively, and has been included as adependency in the cabal file.
Note: The generation of the lexical analyser has been separated out,to remove the install-time dependency on Alex. If any changesneed to be made to the lexer, the Lexer.x source lies insrc-dev, and the runalex.sh script will invoke Alex with theappropriate directories.
Changes
ChangeLog forlanguage-javascript
0.7.1.0 – 2020-03-22
- Add support for
async
function specifiers andawait
keyword.
0.7.0.0 – 2019-10-10
- Add support for (Ryan Hendrickson):
- Destructuring in var declarations
const
in for statements- ES6 property shorthand syntax
- Template literals
- Computed property names
- Bare import declarations
- Exotic parameter syntaxes
- Generators and
yield
- Method definitions
- classes
- super
keyword
0.6.0.13 – 2019-06-17
- Add support for (Cyril Sobierajewicz):
- Unparenthesized arrow functions of one parameter
- Export from declarations
- Add back support for identifiers named
as
0.6.0.12 – 2019-05-03
- Add support for for..of and friends (Franco Bulgarelli)