Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: brownplt/webbits
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: jswebtools/language-ecmascript
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
Showing with 3,563 additions and 1,830 deletions.
  1. +3 −0 .gitignore
  2. +17 −0 .travis.yml
  3. +106 −0 CHANGELOG
  4. +5 −4 LICENSE
  5. +30 −0 README.md
  6. +0 −72 WebBits.cabal
  7. +18 −0 default.nix
  8. +110 −0 language-ecmascript.cabal
  9. +3 −0 nixpkgs.json
  10. +0 −25 scripts/fetch-test-js
  11. +0 −23 scripts/ghci
  12. +0 −9 scripts/wt
  13. +1 −0 shell.nix
  14. +0 −38 src/BrownPLT/Common.hs
  15. +0 −12 src/BrownPLT/JavaScript.hs
  16. +0 −64 src/BrownPLT/JavaScript/Lexer.hs
  17. +0 −244 src/BrownPLT/JavaScript/PrettyPrint.hs
  18. +0 −157 src/BrownPLT/JavaScript/Syntax.hs
  19. +0 −113 src/BrownPLT/JavaScript/Syntax/Annotations.hs
  20. +0 −117 src/BrownPLT/Test.hs
  21. +12 −0 src/Language/ECMAScript3.hs
  22. +16 −11 src/{BrownPLT/JavaScript → Language/ECMAScript3}/Analysis/Environment.hs
  23. +19 −15 src/{BrownPLT/JavaScript → Language/ECMAScript3}/Analysis/LabelSets.hs
  24. +176 −0 src/Language/ECMAScript3/Lexer.hs
  25. +302 −246 src/{BrownPLT/JavaScript → Language/ECMAScript3}/Parser.hs
  26. +4 −0 src/Language/ECMAScript3/Parser/State.hs
  27. +9 −0 src/Language/ECMAScript3/Parser/Type.hs
  28. +503 −0 src/Language/ECMAScript3/PrettyPrint.hs
  29. +15 −0 src/Language/ECMAScript3/SourceDiff.hs
  30. +453 −0 src/Language/ECMAScript3/Syntax.hs
  31. +181 −0 src/Language/ECMAScript3/Syntax/Annotations.hs
  32. +403 −0 src/Language/ECMAScript3/Syntax/Arbitrary.hs
  33. +386 −0 src/Language/ECMAScript3/Syntax/CodeGen.hs
  34. +48 −0 src/Language/ECMAScript3/Syntax/QuasiQuote.hs
  35. +0 −31 src/UnitTest.hs
  36. +38 −0 stack.yaml
  37. +16 −0 test/Test/Arbitrary.hs
  38. +58 −0 test/Test/Diff.hs
  39. +86 −0 test/Test/Pretty.hs
  40. +50 −0 test/Test/Unit.hs
  41. +17 −0 test/TestMain.hs
  42. +2 −0 test/diff/expects/t1.diff
  43. +2 −0 test/diff/left/t1.js
  44. +1 −0 test/diff/right/t1.js
  45. 0 {tests → test}/parse-pretty/add.js
  46. 0 {tests → test}/parse-pretty/do-while.js
  47. +465 −465 {tests → test}/parse-pretty/flapjax-fxinternal-22dec2008.js
  48. 0 {tests → test}/parse-pretty/neg.js
  49. 0 {tests → test}/parse-pretty/numbers.js
  50. 0 {tests → test}/parse-pretty/object-lit-1.js
  51. 0 {tests → test}/parse-pretty/object-lit-2.js
  52. 0 {tests → test}/parse-pretty/prefix-chain.js
  53. 0 {tests → test}/parse-pretty/strings.js
  54. +0 −102 tests/MozSuite.hs
  55. +0 −37 tests/Rhino.hs
  56. +0 −45 tests/RhinoTest.java
  57. BIN tests/rhino.jar
  58. +8 −0 upload.nix
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -4,3 +4,6 @@
*.class
.DS_Store
/webbits
dist*
*~
result
17 changes: 17 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
language: nix

matrix:
fast_finish: true
include:
- env: GHCVER=ghc844
- env: GHCVER=ghc865
- env: GHCVER=ghc881
- env: GHCVER=ghc882
- env: GHCVER=ghc8101
- env: GHCVER=ghcHEAD
allow_failures:
- env: GHCVER=ghc8101
- env: GHCVER=ghcHEAD

script:
- nix-build -A language-ecmascript --argstr compiler $GHCVER
106 changes: 106 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
Version change log.

=0.19.0.1=
Version bumps and a build fix for GHC 8.8 (GitHub issue #85).

=0.19=
Pull request #84: Moved the Arbitrary instance and the testing-feat dependency to the test-suite. Removed tabs from the lexer.

=0.18=
Pull request #83: Updated dependencies, migrated to ansi-wl-pprint.

=0.17.2.0=
Issue #82: Tighter lexing of identifiers using Unicode character classes (thanks @berdario).

Dependency version bumps.

=0.17.1.0=
Improvements to pretty-printing (Github PR #78) + fixed a bug in quasi-quotation (Github PR #77).

=0.17.0.2=
Fixed a bug in the Arbitrary instance: no longer generating empty list expressions. Dependency bounds update.

=0.17.0.1=
Dependency bounds update.

=0.17=
Added helper functions for code generation (see Language.ECMAScript3.Syntax.CodeGen). Bug fixes to the Arbitrary instances.

=0.16.2=
Build fixes for GHC 7.4.2 and 7.8.2.

=0.16.1=
Removed unicode-escaping of illegal identifier characters in the
pretty-printer. Adjusted the isValid predicate to check for illegal
characters identifiers. Adjusted the Arbitrary instance to only produce
valid identifier names.

=0.16=
Rewritten the Arbitrary instances using 'testing-feat'. Adjusted the
pretty-printer to escape invalid characters in identifier names
automatically, which gives better usability in code generation use-cases.
Added an 'isValid' predicate to check the validity of the AST. Note that the
pretty-printer is guaranteed to produce syntactically correct code only
for valid ASTs.

=0.15.4=
Fixed haddock build failure.

=0.15.3=
Ported the pretty printer to use 'wl-pprint' instead of
'pretty'. Pretty-printed code is now more compact and resembles common
formatting conventions. Fixed bugs where the pretty-printer produced
unparseable source representations for expression statements starting with
'{' or "function". Disabled the QuickCheck pretty-printer test.

=0.15.2=
Fixed an error in the .cabal file that prevented some of the test modules
to be packaged.

=0.15.1=
Added semicolons after the "return" statement in the pretty printer to
avoid certain class of syntax error when printed code is parsed
again. Changed the pretty-printer to put the IntLit in parenthesis if it's
found on the left-side of the '.' (field access) operator.

=0.15=
Bug fixes in the pretty-printer, the parser and the QuickCheck arbitrary
instance for the AST. Refactored tests to use test-framework. Reorganized
the interface for the parser to make it consistent; see deprecation
warnings for details. Added Language.ECMAScript3.SourceDiff -- a simple
source-based differ for ECMAScript programs, which is now used for
visualizing test failures. Revised package dependencies. Factored the
analyses out in a separate package: language-ecmascript-analysis;
Language.ECMAScript3.Analysis.* are now deprecated.

=0.14=
Refactoring of the pretty-printing module: added class Pretty with a more
comprehensive coverage of AST datatypes and better documentation. Removed
duplicate code and deprecated all old interfaces (everything except class
Pretty). Old interfaces would be removed in 1.0 (still a long way out).

=0.13=
Added class PP for pretty-printing

=0.12=
Added a 'setAnnotation' function to the 'HasAnnotation' class. Added
a 'withAnnotation' helper function to modify the top level annotation.

=0.11.1=
Fixed binary operator precedence in the parser.

=0.11=
Added a simple quasi-quoter for ECMAScript (see
Language.ECMAScript3.Syntax.QuasiQuote)

=0.10=
The ParenExpr constructor was removed from the Expression AST
(WARNING: might break some builds). The pretty printer was rewritten
to automatically parenthesize sub-expressions based on operator
precedence. Added a (beta quality) arbitrary instance for all the
AST's to generate random JavaScript programs (useful for testing).


=0.9.1=
Increased the upper bound on data-default in dependencies. See
https://github.com/jswebtools/language-ecmascript/pull/5
9 changes: 5 additions & 4 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2007--2011, Brown University and Claudiu Saftoiu
Copyright (c) 2007--2012 Brown University, (c) 2008-2012 Claudiu Saftoiu, (c) 2012-2015 Stevens Institute of Technology, (c) 2016 Andrey Chudnov, (c) 2016 Eyal Lotem.
All Rights Reserved.

Redistribution and use in source and binary forms, with or without
@@ -9,9 +9,10 @@ modification, are permitted provided that the following conditions are met:
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Brown University nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
* Neither the name of Brown University, Stevens Institute of Technology
nor the names of its contributors may be used to endorse or promote
products derived from this software without specific prior written
permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<a href="https://travis-ci.org/jswebtools/language-ecmascript"><img src="https://travis-ci.org/jswebtools/language-ecmascript.svg"></img></a>

# Overview

Language-ecmascript is a Haskell library for parsing, transforming and pretty-printing ECMAScript (popularly known as JavaScript) source code. It is geared towards program analysis and transformation, but has also been used as a backend for compilers targeting JavaScript. The library aims to be 100% standards-compatible with an extensive test-suite and documentation. It is part of both Hackage and Stackage Haskell package databases. Language-ecmascript is licenced under the 3-clause BSD license (see LICENSE for details).

The library has started as WebBits at Brown University, and many people have contributed to it since. See language-ecmascript.cabal for the list of contributors and copyright information.

# Versioning

Since version 0.17.0.1 the library follows Haskell Package Versioning Policy (https://wiki.haskell.org/Package_versioning_policy) for its version numbers. The version is a triple of numbers MAJOR1.MAJOR2.MINOR(.PATCH), where the last number is optional and:
* MAJOR1 and MAJOR2 are incremented only on backwards-incompatible and reverse-dependency-breaking changes,
* MINOR is incremented on any additional backwards-compatible features,
* PATCH is incremented on any other changes, mostly bug/build-fixes.

If your publicly-released package depends on this library you are strongly encouraged to restrict allowed versions to at least the MAJOR version you are using.

Starting the next major version release, the library is going to follow the following versioning scheme (compatible with PVP): ESS.MAJOR.MINOR.PATCH, where
* MAJOR, MINOR and PATCH are as above, and
* ESS corresponds to the version of the ECMAScript standard the library supports.

# Contributing

Contributions are welcome, provided they are in agreement with the terms of the BSD3 license. Generally, any non-trivial (beyond formatting, spelling or simple bug/build fixes) contribution is to be reflected in the list of contributors. The preferred method of contribution is via pull requests. If you intend to contribute a lot, after your first pull request is accepted, you can get direct commit rights to the repository. As a contributor you are expected to follow the general formatting style and document your efforts in the source code comments and in the issue discussion.

If you would like to contribute, here's how you can get started:

* Read the Roadmap wiki page (https://github.com/jswebtools/language-ecmascript/wiki/Roadmap) to get an idea of where the project is heading and where the current efforts are focused.
* Head to the issues list (https://github.com/jswebtools/language-ecmascript/issues), read through the issues and pick an issue to work on. If someone is already working on it, contact them first to make sure you are not stepping on each other's toes.
* (Optional) Send an e-mail to the maintainer, Andrey Chudnov <oss@chudnov.com>, to let him know what you are planning to work on and ask any questions you have about the problem or the code base.
72 changes: 0 additions & 72 deletions WebBits.cabal

This file was deleted.

18 changes: 18 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
with (builtins.fromJSON (builtins.readFile ./nixpkgs.json));
{ pkgs ? import (builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz";
inherit sha256;
}) {}
, compiler ? "ghc881"
}:
let
overrides = self: super: { Diff = self.Diff_0_4_0; };
ghc = pkgs.haskell.packages.${compiler}.override { inherit overrides; };
language-ecmascript = ghc.callCabal2nix "language-ecmascript" ./. {};
in
with pkgs.haskell.lib;
{
inherit language-ecmascript;
inherit pkgs;
release = sdistTarball language-ecmascript;
}
110 changes: 110 additions & 0 deletions language-ecmascript.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
Name: language-ecmascript
Version: 0.19.1.0
Cabal-Version: >= 1.12
Copyright: (c) 2007-2012 Brown University, (c) 2008-2010 Claudiu Saftoiu,
(c) 2012-2015 Stevens Institute of Technology, (c) 2016 Eyal Lotem, (c) 2016-2020 Andrey Chudnov
License: BSD3
License-file: LICENSE
Author: Andrey Chudnov, Arjun Guha, Spiridon Aristides Eliopoulos,
Joe Gibbs Politz, Claudiu Saftoiu
Maintainer: Andrey Chudnov <oss@chudnov.com>
Homepage: http://github.com/jswebtools/language-ecmascript
Bug-reports: http://github.com/jswebtools/language-ecmascript/issues
Stability: experimental
Tested-with: GHC==8.8.1
Extra-Source-Files: test/parse-pretty/*.js, test/diff/left/*.js, test/diff/right/*.js, test/diff/expects/*.diff, CHANGELOG
Category: Language
Build-Type: Simple
Synopsis: JavaScript parser and pretty-printer library
Description:
Tools for working with ECMAScript 3 (popularly known as JavaScript).
Includes a parser, pretty-printer, tools for working with source tree
annotations and an arbitrary instance. See CHANGELOG for a summary of
changes. The package follows the Haskell Package Versioning Policy since version 0.17.0.1.

Source-repository head
type: git
location: git://github.com/jswebtools/language-ecmascript.git

Source-repository this
type: git
location: git://github.com/jswebtools/language-ecmascript.git
tag: 0.19.0.1

Library
Hs-Source-Dirs:
src
Build-Depends:
base >= 4 && < 4.19,
mtl >= 1 && < 3,
parsec > 3 && < 3.2.0,
ansi-wl-pprint >= 0.6 && < 1,
containers == 0.*,
uniplate >= 1.6 && <1.7,
data-default-class >= 0.0.1 && < 0.2,
QuickCheck >= 2.5 && < 3,
template-haskell >= 2.7 && < 3,
Diff == 0.4.*,
charset >= 0.3
ghc-options:
-fwarn-incomplete-patterns
Exposed-Modules:
Language.ECMAScript3
Language.ECMAScript3.Lexer
Language.ECMAScript3.Parser
Language.ECMAScript3.PrettyPrint
Language.ECMAScript3.Syntax
Language.ECMAScript3.Syntax.Annotations
Language.ECMAScript3.Syntax.CodeGen
Language.ECMAScript3.Syntax.QuasiQuote
Language.ECMAScript3.Analysis.Environment
Language.ECMAScript3.Analysis.LabelSets
Language.ECMAScript3.SourceDiff
Other-Modules:
Language.ECMAScript3.Parser.Type
Language.ECMAScript3.Parser.State
Default-Extensions:
DeriveDataTypeable, ScopedTypeVariables, DeriveFunctor, DeriveFoldable, DeriveTraversable, FlexibleContexts
Default-Language: Haskell2010

Test-Suite test
Hs-Source-Dirs: src test
Type: exitcode-stdio-1.0
Main-Is: TestMain.hs
Other-Modules:
Language.ECMAScript3.Lexer
Language.ECMAScript3.Parser
Language.ECMAScript3.Parser.State
Language.ECMAScript3.Parser.Type
Language.ECMAScript3.PrettyPrint
Language.ECMAScript3.SourceDiff
Language.ECMAScript3.Syntax
Language.ECMAScript3.Syntax.Annotations
Language.ECMAScript3.Syntax.Arbitrary
Test.Diff
Test.Unit
Test.Pretty
Test.Arbitrary
Build-Depends:
base,
mtl,
parsec,
ansi-wl-pprint,
charset >= 0.3,
containers,
directory >= 1.2 && < 1.4,
filepath >= 1.3 && < 1.5,
HUnit >= 1.2 && < 1.7,
QuickCheck >= 2.5 && < 3,
data-default-class,
testing-feat >= 0.4.0.2 && < 1.2,
test-framework >= 0.8 && < 0.9,
test-framework-hunit >= 0.3.0 && < 0.4,
test-framework-quickcheck2 >= 0.3.0.1 && < 0.4,
uniplate,
Diff,
language-ecmascript
Default-Extensions: DeriveDataTypeable, ScopedTypeVariables, DeriveFunctor, DeriveFoldable, DeriveTraversable, FlexibleContexts
Default-Language: Haskell2010
ghc-options:
-fwarn-incomplete-patterns
3 changes: 3 additions & 0 deletions nixpkgs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{ "rev" : "8130f3c1c2bb0e533b5e150c39911d6e61dcecc2"
, "sha256" : "154nrhmm3dk5kmga2w5f7a2l6j79dvizrg4wzbrcwlbvdvapdgkb"
}
Loading