Browse Source

Build with stack and LTS Haskell 4.2

master
Peter J. Jones 4 years ago
parent
commit
43c8f4bc8c
100 changed files with 46 additions and 10514 deletions
  1. 2
    4
      .gitignore
  2. 21
    0
      GNUmakefile
  3. 0
    0
      README.md
  4. 17
    0
      build/nixpkgs.nix
  5. 5
    0
      build/stack.yaml
  6. 1
    1
      pmade.cabal
  7. 0
    32
      vendor/hjsmin/.gitignore
  8. 0
    40
      vendor/hjsmin/.travis.yml
  9. 0
    30
      vendor/hjsmin/LICENSE
  10. 0
    76
      vendor/hjsmin/Readme.md
  11. 0
    2
      vendor/hjsmin/Setup.hs
  12. 0
    90
      vendor/hjsmin/TODO.txt
  13. 0
    48
      vendor/hjsmin/Text/Jasmine.hs
  14. 0
    354
      vendor/hjsmin/Text/Jasmine/Pretty.hs
  15. 0
    65
      vendor/hjsmin/hjsmin.cabal
  16. 0
    41
      vendor/hjsmin/hjsmin.hs
  17. 0
    335
      vendor/hjsmin/resources/JavaScript.grm
  18. 0
    9
      vendor/hjsmin/resources/README.txt
  19. 0
    370
      vendor/hjsmin/runtests.hs
  20. 0
    125
      vendor/hjsmin/test/inherit.html
  21. 0
    62
      vendor/hjsmin/test/jsminplus/changelog.txt
  22. 0
    1980
      vendor/hjsmin/test/jsminplus/jsminplus.php
  23. 0
    48
      vendor/hjsmin/test/jsminplus/run.php
  24. 0
    1
      vendor/hjsmin/test/minified/0_helloworld.js
  25. 0
    1
      vendor/hjsmin/test/minified/100_animals.js
  26. 0
    5
      vendor/hjsmin/test/minified/101_inheritance.js
  27. 0
    1
      vendor/hjsmin/test/minified/101a_in.js
  28. 0
    1
      vendor/hjsmin/test/minified/10_expressions.js
  29. 0
    1
      vendor/hjsmin/test/minified/11_funcs_factorial.js
  30. 0
    1
      vendor/hjsmin/test/minified/12_array.js
  31. 0
    1
      vendor/hjsmin/test/minified/12_funcs_ackermann.js
  32. 0
    1
      vendor/hjsmin/test/minified/12_iter.js
  33. 0
    1
      vendor/hjsmin/test/minified/13_cast.js
  34. 0
    1
      vendor/hjsmin/test/minified/14_new.js
  35. 0
    1
      vendor/hjsmin/test/minified/15_tostring.js
  36. 0
    1
      vendor/hjsmin/test/minified/16_funcs.js
  37. 0
    3
      vendor/hjsmin/test/minified/16_literals.js
  38. 0
    2
      vendor/hjsmin/test/minified/17_funcs_caller.js
  39. 0
    2
      vendor/hjsmin/test/minified/18_funcs_apply.js
  40. 0
    1
      vendor/hjsmin/test/minified/19_func_body.js
  41. 0
    1
      vendor/hjsmin/test/minified/21_print.js
  42. 0
    1
      vendor/hjsmin/test/minified/23_switch.js
  43. 0
    1
      vendor/hjsmin/test/minified/24_switch.js
  44. 0
    1
      vendor/hjsmin/test/minified/25_regex.js
  45. 0
    1
      vendor/hjsmin/test/minified/26_regex.js
  46. 0
    2
      vendor/hjsmin/test/minified/34_throw.js
  47. 0
    2
      vendor/hjsmin/test/minified/35_throw.js
  48. 0
    3
      vendor/hjsmin/test/minified/36_throw.js
  49. 0
    1
      vendor/hjsmin/test/minified/56_arguments.js
  50. 0
    2
      vendor/hjsmin/test/minified/5_object.js
  51. 0
    2
      vendor/hjsmin/test/minified/67_method.js
  52. 0
    1
      vendor/hjsmin/test/minified/6_this.js
  53. 0
    1
      vendor/hjsmin/test/minified/79_throw.js
  54. 0
    1
      vendor/hjsmin/test/minified/90_class.js
  55. 0
    2
      vendor/hjsmin/test/minified/97_funcproto.js
  56. 0
    2
      vendor/hjsmin/test/minified/99_all.js
  57. 0
    3
      vendor/hjsmin/test/minified/9_functions.js
  58. 0
    36
      vendor/hjsmin/test/minified/ext-all-debug.js
  59. 0
    8
      vendor/hjsmin/test/minified/prototype.js
  60. 0
    16
      vendor/hjsmin/test/mkminified.sh
  61. 0
    4
      vendor/hjsmin/test/parsingonly/00_f.js
  62. 0
    6
      vendor/hjsmin/test/parsingonly/01_semi1.js
  63. 0
    13
      vendor/hjsmin/test/parsingonly/02_semicolon.js
  64. 0
    8
      vendor/hjsmin/test/parsingonly/02_sm.js
  65. 0
    11
      vendor/hjsmin/test/parsingonly/03_sm.js
  66. 0
    3
      vendor/hjsmin/test/parsingonly/04_if.js
  67. 0
    10
      vendor/hjsmin/test/parsingonly/05_comments_simple.js
  68. 0
    24
      vendor/hjsmin/test/parsingonly/05_regex.js
  69. 0
    7
      vendor/hjsmin/test/parsingonly/06_block.js
  70. 0
    8
      vendor/hjsmin/test/parsingonly/06_callexpr.js
  71. 0
    4
      vendor/hjsmin/test/parsingonly/06_newexpr.js
  72. 0
    7
      vendor/hjsmin/test/parsingonly/06_var.js
  73. 0
    14
      vendor/hjsmin/test/parsingonly/07_expr.js
  74. 0
    2
      vendor/hjsmin/test/parsingonly/07_expr2.js
  75. 0
    122
      vendor/hjsmin/test/parsingonly/101_inheritance.js
  76. 0
    38
      vendor/hjsmin/test/parsingonly/10_switch.js
  77. 0
    39
      vendor/hjsmin/test/parsingonly/110_perfect.js
  78. 0
    73
      vendor/hjsmin/test/parsingonly/120_js.js
  79. 0
    171
      vendor/hjsmin/test/parsingonly/121_jsdefs.js
  80. 0
    946
      vendor/hjsmin/test/parsingonly/122_jsexec.js
  81. 0
    946
      vendor/hjsmin/test/parsingonly/122_jsexec2.js
  82. 0
    997
      vendor/hjsmin/test/parsingonly/123_jsparse.js
  83. 0
    2725
      vendor/hjsmin/test/parsingonly/130_htojs.js
  84. 0
    85
      vendor/hjsmin/test/parsingonly/130_htojs2.js
  85. 0
    4
      vendor/hjsmin/test/parsingonly/130s.js
  86. 0
    33
      vendor/hjsmin/test/parsingonly/14_labelled_stmts.js
  87. 0
    16
      vendor/hjsmin/test/parsingonly/15_literals.js
  88. 0
    43
      vendor/hjsmin/test/parsingonly/16_literals.js
  89. 0
    1
      vendor/hjsmin/test/parsingonly/1_simple.js
  90. 0
    12
      vendor/hjsmin/test/parsingonly/20_continue_loop.js
  91. 0
    116
      vendor/hjsmin/test/parsingonly/20_statements.js
  92. 0
    52
      vendor/hjsmin/test/parsingonly/25_trycatch.js
  93. 0
    31
      vendor/hjsmin/test/parsingonly/40_functions.js
  94. 0
    1
      vendor/hjsmin/test/parsingonly/41_functions.js
  95. 0
    21
      vendor/hjsmin/test/parsingonly/5_comments.js
  96. 0
    68
      vendor/hjsmin/test/parsingonly/67_bob.js
  97. 0
    13
      vendor/hjsmin/test/parsingonly/errorline13.js
  98. 0
    8
      vendor/hjsmin/test/parsingonly/fn.js
  99. 0
    8
      vendor/hjsmin/test/parsingonly/js.html
  100. 0
    0
      vendor/hjsmin/test/pminified/00_f.js

+ 2
- 4
.gitignore View File

@@ -1,6 +1,4 @@
/.cabal-sandbox/
/.cache
/cabal.sandbox.config
/dist
/www
/default.nix
/.stack-work
/build/.stack-work

+ 21
- 0
GNUmakefile View File

@@ -0,0 +1,21 @@
################################################################################
export TMPDIR = $(HOME)/tmp

################################################################################
TMP_DUMMY = $(TMPDIR)/.dummy
STACK_OPTS = --stack-yaml=build/stack.yaml

################################################################################
all: $(TMP_DUMMY)
stack $(STACK_OPTS) setup
stack $(STACK_OPTS) build
stack $(STACK_OPTS) exec -- site rebuild

################################################################################
run: all
stack $(STACK_OPTS) exec -- site preview

################################################################################
$(TMP_DUMMY):
mkdir -p $(dir $@)
touch $@

+ 0
- 0
README.md View File


+ 17
- 0
build/nixpkgs.nix View File

@@ -0,0 +1,17 @@
with (import <nixpkgs> {});

stdenv.mkDerivation {
name = "pmade";

buildInputs = [
haskell.packages.lts-4_2.ghc
zlib
sassc
];

# Work around a bug in GHC:
# https://ghc.haskell.org/trac/ghc/ticket/11042
shellHook = ''
export LD_LIBRARY_PATH=${zlib}/lib
'';
}

+ 5
- 0
build/stack.yaml View File

@@ -0,0 +1,5 @@
resolver: lts-4.2

packages:
- ../
- ../vendor/devalot-hakyll/

+ 1
- 1
pmade.cabal View File

@@ -1,4 +1,4 @@
name: pmadedotcom
name: pmade
version: 0.1.0.0
homepage: http://www.pmade.com
license: AllRightsReserved

+ 0
- 32
vendor/hjsmin/.gitignore View File

@@ -1,32 +0,0 @@
/Text/HJsMin.hs~
/dist/*
/hjsmin.cabal~
/runtests.hs~
/.gitignore~
/TODO.txt~
/Text/HJsMin/Parse.hs~
/Text/Jasmine.hs~
/Text/Jasmine/Parse.hs~
/Text/Jasmine/Pretty.hs~
/buildall.sh~
/test/mkfinified.sh~
/test/mkminified.sh~
/Text/Jasmine/Token.hs~
/test/pminified/20_statements2.js~
/test/pminified/122_jsexec2.js~
/test/pminified/122_jsexec3.js~
/test/parsingonly/130_htojs2.js~
/test/pminified/130_htojs2.js~
/test/parsingonly/07_expr2.js~
/Text/Jasmine.hi
/Text/Jasmine.o
/Text/Jasmine/Parse.hi
/Text/Jasmine/Parse.o
/Text/Jasmine/Pretty.hi
/Text/Jasmine/Pretty.o
/Text/Jasmine/Token.hi
/Text/Jasmine/Token.o
/runbench.hs~
/runbench.o
cabal.sandbox.config
.cabal-sandbox

+ 0
- 40
vendor/hjsmin/.travis.yml View File

@@ -1,40 +0,0 @@
# language: haskell

# See http://www.reddit.com/r/haskell/comments/1os3f6/how_to_use_travisci_with_multiple_ghc_versions/

env:
# - GHCVER=6.12.3
# - GHCVER=7.0.1
# - GHCVER=7.0.2
# - GHCVER=7.0.3
# - GHCVER=7.0.4
# - GHCVER=7.2.1
# - GHCVER=7.2.2
# - GHCVER=7.4.1
# - GHCVER=7.4.2
# - GHCVER=7.6.1
# - GHCVER=7.6.2
- GHCVER=7.6.3
- GHCVER=7.8.4
- GHCVER=7.10.2

before_install:
- sudo add-apt-repository -y ppa:hvr/ghc
- sudo apt-get update
- sudo apt-get install cabal-install-1.22 ghc-$GHCVER
- export PATH=/opt/ghc/$GHCVER/bin:$PATH

install:
- cabal-1.22 update
- cabal-1.22 install happy
- cabal-1.22 install alex
- cabal-1.22 install --only-dependencies --enable-tests;

script:
- cabal-1.22 configure --enable-tests
- cabal-1.22 build
- dist/build/test-hjsmin/test-hjsmin
- cabal-1.22 check
- cabal-1.22 haddock
- cabal-1.22 sdist


+ 0
- 30
vendor/hjsmin/LICENSE View File

@@ -1,30 +0,0 @@
Copyright (c)2010, Alan Zimmerman

All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

* 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 Alan Zimmerman nor the names of other
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 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ 0
- 76
vendor/hjsmin/Readme.md View File

@@ -1,76 +0,0 @@
hjsmin
======

[![Build Status](https://secure.travis-ci.org/erikd/hjsmin.png?branch=master)](http://travis-ci.org/erikd/hjsmin)

Haskell implementation of a javascript minifier

It is intended to be used in conjunction with Hamlet, part of Yesod.

As such, much of the structure of the package is shamelessly copied from Hamlet.

See http://github.com/snoyberg/hamlet


How to build
------------

Library:

cabal clean && cabal configure && cabal build

Tests:

cabal clean && cabal configure --enable-tests && cabal build

Running the tests

dist/build/test-hjsmin/test-hjsmin

Changes
-------

0.1.5.1 - fix if/else/if minify issue

0.1.5.0 - fix tests to work with language-javascript >= 0.5.14

0.1.4.7 - remove upper bounds in cabal file

0.1.4.6 - relax upper bound in optparse-applicative

0.1.4.5 - relax upper bound in text to support 1.1
- introduce CLI wrapper for minifying files from the
commandline, courtesy of @CodeBlock

0.1.4.4 - relax upper bound in text to support 1.0

0.1.4.3 - make sure all missing cases are covered

0.1.4.2 - minify octal literals too

0.1.4.1 - Bump upper bound for containers to < 0.6 for the tests as well as the library

0.1.4 - Include test assets in cabal to allow cabal test to pass. Courtesy of @snoyberg

0.1.3 - Update version ranges for GHC 7.6.1, courtesy of @mietek

0.1.2 - More general fix to the space after 'new' keyword, for issue #8 & #9

0.1.1 - Fixed problem with missing space after 'new' keyword, in issue #8.

0.1.0 - Major update to work with language-javascript 0.5.1. All changes should be internal.
Update of build process to make use of Cabal testing support, and Travis CI.

0.0.15 - Fix GHC 7.4.1 compile compatibility. Patch accepted from github.com/luite

0.0.14 - Allow unicode characters in comments

0.0.13 - Error in parsing numbers with zeros before decimal point

0.0.12 - Worked in Michael Snoyman's fix for unicode output

0.0.11 - Worked in language-javascript 0.4.*, with source locations in the AST
Worked in processing of property get/set in object literals
0.0.10 - Removed attoparsec dependency and historical Parse/Token



+ 0
- 2
vendor/hjsmin/Setup.hs View File

@@ -1,2 +0,0 @@
import Distribution.Simple
main = defaultMain

+ 0
- 90
vendor/hjsmin/TODO.txt View File

@@ -1,91 +0,0 @@
Testing:

The following Lint has a strict parser
http://www.javascriptlint.com/online_lint.php

This one does not
http://www.jslint.com/

---

Language reference https://developer.mozilla.org/en/JavaScript/Reference
http://msdn.microsoft.com/en-us/library/ttyab5c8.aspx

---

Look at

http://dean.edwards.name/download/#packer

http://code.google.com/p/minify/

Examples of parsers

JSon parser in Parsec
http://snippets.dzone.com/posts/show/3660

GOLD Parser, using the Javascript.grm from
http://www.devincook.com/GOLDParser/grammars/index.htm

http://oss.org.cn/ossdocs/web/js/js20/formal/parser-grammar.html

-------------------------

- Generate output using standard pretty print library, so it can be
used with various backends


- Sort out semicolon insertion, as per http://oss.org.cn/ossdocs/web/js/js20/rationale/syntax.html
Also: http://inimino.org/~inimino/blog/javascript_semicolons

Grammatical Semicolon Insertion

Semicolons before a closing } and the end of the program are
optional in both JavaScript 1.5 and 2.0. In addition, the
JavaScript 2.0 parser allows semicolons to be omitted before the
else of an if-else statement and before the while of a do-while
statement.

Line-Break Semicolon Insertion

If the first through the nth tokens of a JavaScript program form
are grammatically valid but the first through the n+1st tokens are
not and there is a line break between the nth tokens and the n+1st
tokens, then the parser tries to parse the program again after
inserting a VirtualSemicolon token between the nth and the n+1st
tokens.

- remove un-needed semicolons in pretty printer

- put in tests for all cases of elementList


------------

Integrating language-haskell.
-----------------------------

Baseline before starting, on my laptop (intel Core2 Duo SU7300)

$ time ./dist/build/runtests/runtests

real 0m1.625s
user 0m1.616s
sys 0m0.016s

Baseline 2010-12-20, after getting all tests to pass at last

real 0m0.209s
user 0m0.196s
sys 0m0.004s

After working in unicode, in language-javascript-0.0.3 [2010-12-28]

real 0m0.236s
user 0m0.224s
sys 0m0.012s



EOF

+ 0
- 48
vendor/hjsmin/Text/Jasmine.hs View File

@@ -1,48 +0,0 @@
module Text.Jasmine
( minify
, minifym
, minifyBb
, minifyFile
) where

import Control.Applicative ((<$>))
import Data.Text.Lazy (unpack)
import Data.Text.Lazy.Encoding (decodeUtf8With)
import Data.Text.Encoding.Error (lenientDecode)
import Language.JavaScript.Parser (readJs, parse, JSNode(..))

import qualified Blaze.ByteString.Builder as BB
import qualified Data.ByteString.Lazy as LB
import qualified Data.ByteString.Lazy.Char8 as S8

import Text.Jasmine.Pretty


minifym :: LB.ByteString -> Either String LB.ByteString
minifym s =
case myParse s of
Left msg -> Left (show msg)
Right p -> Right $ BB.toLazyByteString $ renderJS p


minifyBb :: LB.ByteString -> Either String BB.Builder
minifyBb s =
case myParse s of
Left msg -> Left (show msg)
Right p -> Right (renderJS p)


minify :: LB.ByteString -> LB.ByteString
minify s = BB.toLazyByteString . renderJS . readJs $ lbToStr s


minifyFile :: FilePath -> IO LB.ByteString
minifyFile filename = minify <$> LB.readFile filename


myParse :: S8.ByteString -> Either String JSNode
myParse input = parse (lbToStr input) "src"


lbToStr :: S8.ByteString -> String
lbToStr = unpack . decodeUtf8With lenientDecode

+ 0
- 354
vendor/hjsmin/Text/Jasmine/Pretty.hs View File

@@ -1,399 +0,0 @@
module Text.Jasmine.Pretty
(
renderJS
) where

import Data.Char
import Data.Monoid (Monoid, mappend, mempty, mconcat)
import Language.JavaScript.Parser (JSNode(..),Node(..),tokenPosnEmpty)
import qualified Blaze.ByteString.Builder as BB
import qualified Blaze.ByteString.Builder.Char.Utf8 as BS
import qualified Data.ByteString.Lazy as LB


(<>) :: BB.Builder -> BB.Builder -> BB.Builder
(<>) a b = mappend a b

(<+>) :: BB.Builder -> BB.Builder -> BB.Builder
(<+>) a b = mconcat [a, (text " "), b]

hcat :: (Monoid a) => [a] -> a
hcat xs = mconcat xs

empty :: BB.Builder
empty = mempty

text :: String -> BB.Builder
text s = BS.fromString s

char :: Char -> BB.Builder
char c = BS.fromChar c




renderJS :: JSNode -> BB.Builder
renderJS (NN node ) = rn node
renderJS (NT node _ _) = rn node

rn :: Node -> BB.Builder
--rn (JSEmpty l) = (renderJS l)

rn (JSIdentifier s) = text s
rn (JSDecimal i) = text i
rn (JSOctal o) = text o

rn (JSLiteral "new") = (text "new ")
rn (JSLiteral l) = (text l)

rn (JSHexInteger i) = (text $ show i) -- TODO: need to tweak this
rn (JSStringLiteral s l) = empty <> (char s) <> (text l) <> (char s)
rn (JSRegEx s) = (text s)

rn (JSOperator x) = renderJS x
rn (JSExpression xs) = rJS xs


--rn (JSSourceElements xs) = rJS (fixSourceElements $ map fixBlock xs)

--rn (JSSourceElementsTop xs)= rJS (fixTop $ map fixBlock $ fixSourceElements xs)
rn (JSSourceElementsTop xs)= rJS (fixTop $ fixSourceElements $ map fixBlock xs)


--rn (JSFunction s p xs) = (text "function") <+> (renderJS s) <> (text "(") <> (rJS p) <> (text ")") <> (renderJS xs)
rn (JSFunction _f s _lb p _rb x) = (text "function") <+> (renderJS s) <> (text "(") <> (rJS p) <> (text ")") <> (renderJS $ fixFnBlock x)


--rn (JSFunctionExpression [] p xs) = (text "function") <> (text "(") <> (rJS p) <> (text ")") <> (renderJS xs)
--rn (JSFunctionExpression s p xs) = (text "function") <+> (rJS s) <> (text "(") <> (rJS p) <> (text ")") <> (renderJS xs)
rn (JSFunctionExpression _f [] _lb p _rb x) = (text "function") <> (text "(") <> (rJS p) <> (text ")") <> (renderJS $ fixFnBlock x)
rn (JSFunctionExpression _f s _lb p _rb x) = (text "function") <+> (rJS s) <> (text "(") <> (rJS p) <> (text ")") <> (renderJS $ fixFnBlock x)

--rn (JSArguments xs ) = (text "(") <> (rJSList $ map fixLiterals xs) <> (text ")")
rn (JSArguments _lb xs _rb) = (text "(") <> (rJS $ fixLiterals xs) <> (text ")")

rn (JSBlock lb xs rb) = (rJS lb) <> (rJS xs) <> (rJS rb)



rn (JSIf _i _lb c _rb [(NT (JSLiteral ";") _ _)] []) = (text "if") <> (text "(") <> (renderJS c) <> (text ")")

rn (JSIf _i _lb c _rb t []) = (text "if") <> (text "(") <> (renderJS c) <> (text ")")
<> (rJS $ fixSourceElements $ map fixBlock t)

rn (JSIf _i _lb c _rb t [_e,(NT (JSLiteral ";") _ _)]) = (text "if") <> (text "(") <> (renderJS c) <> (text ")")
<> (rJS $ fixIfBlock t) <> (text "else")

rn (JSIf _i _lb c _rb [NT (JSLiteral ";") _ _] [_e,e]) = (text "if") <> (text "(") <> (renderJS c) <> (text ")")
<> text ";"
<> (text "else") <> (spaceOrBlock $ fixBlock e)

rn (JSIf _i _lb c _rb t [_e,e]) = (text "if") <> (text "(") <> (renderJS c) <> (text ")")
<> (rJS $ fixIfElse $ fixSourceElements t)
<> (text "else") <> (spaceOrBlock $ fixBlock e)
rn (JSIf _i _lb _c _rb _t _xs) = error $ "malformed JSIf, else clause should be either [] or [else,expr]"




rn (JSMemberDot xs _d y) = (rJS $ fixLiterals xs) <> (text ".") <> (renderJS y)
rn (JSMemberSquare xs _lb x _rb) = (rJS $ fixLiterals xs) <> (text "[") <> (renderJS x) <> (text "]")
rn (JSUnary l _s ) = text l
rn (JSArrayLiteral _lb xs _rb) = (text "[") <> (rJS xs) <> (text "]")

rn (JSBreak _b [] _as) = (text "break") -- <> (renderJS as)
rn (JSBreak _b is _as) = (text "break") <+> (rJS $ fixSourceElements $ map fixFnBlock is) -- <> (renderJS as)

rn (JSCallExpression "()" _os xs _cs) = (rJS xs)
rn (JSCallExpression t _os xs _cs) = (char $ head t) <> (rJS xs) <> (if ((length t) > 1) then (char $ last t) else empty)


--rn (JSCase (JSExpression [JSStringLiteral sepa s]) xs) = (text "case") <> (renderJS (JSStringLiteral sepa s))
rn (JSCase _ca (NN (JSExpression [(NT (JSStringLiteral sepa s) s1 c1)])) _c xs) =
(text "case") <> (renderJS (NT (JSStringLiteral sepa s) s1 c1)) <> (char ':') <> (rJS $ fixSourceElements $ map fixFnBlock xs)

rn (JSCase _ca e _c xs) = (text "case") <+> (renderJS e) <> (char ':') <> (rJS $ fixSourceElements $ map fixFnBlock xs) -- <> (text ";");


rn (JSCatch _c _lb i [] _rb s) = (text "catch") <> (char '(') <> (renderJS i) <> (char ')') <> (renderJS $ fixFnBlock s)
rn (JSCatch _c _lb i c _rb s) = (text "catch") <> (char '(') <> (renderJS i) <>
(text " if ") <> (rJS $ tail c) <> (char ')') <> (renderJS $ fixFnBlock s)

rn (JSContinue _c is@[NT (JSIdentifier _) _ _] _as) = (text "continue") <+> (rJS is)
rn (JSContinue _c is _as) = (text "continue") <> (rJS is) -- <> (char ';')
rn (JSDefault _d _c xs) = (text "default") <> (char ':') <> (rJS $ fixSourceElements xs)

rn (JSDoWhile _d s _w _lb e _rb _as) = (text "do") <> (renderJS $ fixFnBlock s) <> (text "while") <> (char '(') <> (renderJS e) <> (char ')') -- <> (renderJS as)


--rn (JSElementList xs) = rJS xs
--rn (JSElision xs) = (char ',') <> (rJS xs)
rn (JSElision x) = renderJS x

rn (JSExpressionBinary o e1 _op e2) = (rJS e1) <> (text o) <> (rJS e2)
rn (JSExpressionParen _lp e _rp) = (char '(') <> (renderJS e) <> (char ')')
rn (JSExpressionPostfix o e _op) = (rJS e) <> (text o)
rn (JSExpressionTernary c _q v1 _c v2) = (rJS c) <> (char '?') <> (rJS v1) <> (char ':') <> (rJS v2)
rn (JSFinally _f b) = (text "finally") <> (renderJS $ fixFnBlock b)

rn (JSFor _f _lb e1 _s1 e2 _s2 e3 _rb s) = (text "for") <> (char '(') <> (rJS e1) <> (char ';')
<> (rJS e2) <> (char ';') <> (rJS e3) <> (char ')') <> (renderJS $ fixBlock s)

rn (JSForIn _f _lb e1 _i e2 _rb s) = (text "for") <> (char '(') <> (rJS e1) <+> (text "in")
<+> (renderJS e2) <> (char ')') <> (renderJS $ fixBlock s)
rn (JSForVar _f _lb _v e1 _s1 e2 _s3 e3 _rb s) = (text "for") <> (char '(') <> (text "var") <+> (rJS e1) <> (char ';')
<> (rJS e2) <> (char ';') <> (rJS e3) <> (char ')') <> (renderJS $ fixBlock s)
rn (JSForVarIn _f _lb _v e1 _i e2 _rb s) = (text "for") <> (char '(') <> (text "var") <+> (renderJS e1) <+> (text "in")
<+> (renderJS e2) <> (char ')') <> (renderJS $ fixBlock s)

rn (JSLabelled l _c v) = (renderJS l) <> (text ":") <> (rJS $ fixSourceElements [fixBlock v])

rn (JSObjectLiteral _lb xs _rb) = (text "{") <> (rJS xs) <> (text "}")
rn (JSPropertyAccessor s n _lb1 ps _rb1 b) = (renderJS s) <+> (renderJS n) <> (char '(') <> (rJS ps) <> (text ")") <> (renderJS $ fixFnBlock b)
rn (JSPropertyNameandValue n _c vs) = (renderJS n) <> (text ":") <> (rJS vs)

rn (JSReturn _r [] _as) = (text "return")
rn (JSReturn _r [(NT (JSLiteral ";") _ _)] _as) = (text "return;++foobar+will_never_happen++") -- ++AZ++ get rid of this
rn (JSReturn _r xs _as) = (text "return") <> (if (spaceNeeded xs) then (text " ") else (empty)) <> (rJS $ fixSourceElements xs) -- <> (renderJS as)

rn (JSThrow _t e) = (text "throw") <+> (renderJS $ fixBlock e)

rn (JSSwitch _s _lb e _rb x) = (text "switch") <> (char '(') <> (renderJS e) <> (char ')') <> (renderJS $ fixFnBlock x)

rn (JSTry _t e xs) = (text "try") <> (renderJS $ fixFnBlock e) <> (rJS xs)

rn (JSVarDecl i []) = (renderJS i)
rn (JSVarDecl i xs) = (renderJS i) <> (rJS xs)

rn (JSVariables kw xs _as) = (renderJS kw) <+> (rJS xs)

rn (JSWhile _w _lb e _rb (NT (JSLiteral ";") _ _)) = (text "while") <> (char '(') <> (renderJS e) <> (char ')') -- <> (renderJS s)
rn (JSWhile _w _lb e _rb s) = (text "while") <> (char '(') <> (renderJS e) <> (char ')') <> (renderJS $ fixFnBlock s)

rn (JSWith _w _lb e _rb s) = (text "with") <> (char '(') <> (renderJS e) <> (char ')') <> (rJS s)

rJS :: [JSNode] -> BB.Builder
rJS xs = hcat $ map renderJS xs


extractNode :: JSNode -> Node
extractNode (NT x _ _) = x
extractNode (NN x ) = x

--commaListList :: [[JSNode]] -> BB.Builder
--commaListList xs = (hcat $ punctuate comma $ map rJS xs)


spaceOrBlock :: JSNode -> BB.Builder
spaceOrBlock (NN (JSBlock lb xs rb)) = rn (JSBlock lb xs rb)
--spaceOrBlock (NN (JSStatementBlock lb xs rb)) = rn (JSStatementBlock lb xs rb)
spaceOrBlock x = (text " ") <> (renderJS x)


{-

TODO: Collapse this into JSLiteral ";"

JSStatementBlock (JSStatementList [JSStatementBlock (JSStatementList [])])
-}


fixTop :: [JSNode] -> [JSNode]
fixTop [] = []
fixTop xs = if (n == (JSLiteral ";")) then (init xs) else (xs)
where
n = extractNode $ last xs

{-
fixNew :: [JSNode] -> [JSNode]
fixNew [] = []
fixNew ((NT (JSLiteral "new") p cs):xs) = (NT (JSLiteral "new ") p cs) : fixNew xs
fixNew (x :xs) = x : fixNew xs
-}


fixSourceElements :: [JSNode] -> [JSNode]
fixSourceElements xs = fixSemis $ myFix xs

myFix :: [JSNode] -> [JSNode]
myFix [] = []


--myFix ((NN (JSIf i lb c rb (NN (JSStatementBlock _lb (NN (JSStatementList []) ) _rb) ) e)):xs) = (NN (JSIf i lb c rb (NT (JSLiteral "") tokenPosnEmpty []) e) ) : myFix (xs)

myFix [x] = [x]

myFix (x:(NN (JSFunction v1 v2 v3 v4 v5 v6) ):xs) = x : (NT (JSLiteral "\n") tokenPosnEmpty []) : myFix ((NN (JSFunction v1 v2 v3 v4 v5 v6) ) : xs)

myFix ((NN (JSExpression x) ):(NN (JSExpression y) ):xs) = (NN (JSExpression x) ):(NT (JSLiteral ";") tokenPosnEmpty []):myFix ((NN (JSExpression y) ):xs)
myFix ((NN (JSExpression x) ):(NN (JSBlock l y r) ):xs) = (NN (JSExpression x) ):(NT (JSLiteral ";") tokenPosnEmpty []):myFix ((NN (JSBlock l y r) ):xs)
myFix ((NN (JSBlock x1 x2 x3) ) :(NN (JSBlock y1 y2 y3) ):xs) = (NN (JSBlock x1 x2 x3) ) :(NT (JSLiteral ";") tokenPosnEmpty []):myFix ((NN (JSBlock y1 y2 y3) ):xs)
myFix ((NN (JSBlock x1 x2 x3) ) :(NN (JSExpression y) ):xs) = (NN (JSBlock x1 x2 x3) ) :(NT (JSLiteral ";") tokenPosnEmpty []):myFix ((NN (JSExpression y) ):xs)


myFix ((NN (JSVariables t1 x1s a1) ):(NT (JSLiteral l) s2 c2):(NN (JSVariables t2 x2s a2) ):xs)
| extractNode t1 == extractNode t2 = myFix ((NN (JSVariables t1 (x1s++[(NT (JSLiteral ",") tokenPosnEmpty [])]++x2s) a2) ):xs)
| otherwise = (NN (JSVariables t1 x1s a1) ):myFix ((NT (JSLiteral l) s2 c2):(NN (JSVariables t2 x2s a2) ):xs)

myFix ((NN (JSVariables t1 x1s a1) ):(NN (JSVariables t2 x2s a2) ):xs)
| extractNode t1 == extractNode t2 = myFix ((NN (JSVariables t1 (x1s++[(NT (JSLiteral ",") tokenPosnEmpty [])]++x2s) a2) ):xs)
| otherwise = (NN (JSVariables t1 x1s a1) ):myFix ((NN (JSVariables t2 x2s a2) ):xs)

myFix ((NT (JSLiteral ";") s1 c1):(NT (JSLiteral ";") _s2 _c2):xs) = myFix ((NT (JSLiteral ";") s1 c1):xs)
myFix ((NT (JSLiteral ";") s1 c1):(NT (JSLiteral "" ) _s2 _c2):xs) = myFix ((NT (JSLiteral "" ) s1 c1):xs)


myFix (x:xs) = x : myFix xs

fixLiterals :: [JSNode] -> [JSNode]
fixLiterals [] = []
fixLiterals ((NT (JSStringLiteral d1 s1) ss1 c1):(NN (JSExpressionBinary "+" [(NT (JSStringLiteral d2 s2) ss2 c2)] op r) ):xs)
| d1 == d2 = fixLiterals ((NT (JSStringLiteral d1 (s1++s2)) ss1 c1):(r++xs))
| otherwise = (NT (JSStringLiteral d1 s1) ss1 c1):fixLiterals ((NN (JSExpressionBinary "+" [(NT (JSStringLiteral d2 s2) ss2 c2)] op r) ):xs)

fixLiterals ((NN (JSExpressionBinary "+" [(NT (JSStringLiteral d1 s1) ss2 c2)] o1 [(NT (JSStringLiteral d2 s2) ss3 c3)]) ):xs)
| d1 == d2 = fixLiterals ((NT (JSStringLiteral d1 (s1++s2)) ss2 c2):xs)
| otherwise = (NN (JSExpressionBinary "+" [(NT (JSStringLiteral d1 s1) ss2 c2)] o1 [(NT (JSStringLiteral d2 s2) ss3 c3)]) ):fixLiterals xs

fixLiterals (x:xs) = x:fixLiterals xs

fixSemis :: [JSNode] -> [JSNode]
--fixSemis xs = fixSemis' $ filter (\x -> x /= JSLiteral ";" && x /= JSLiteral "") xs
fixSemis xs = fixSemis' $ stripSemis xs

stripSemis :: [JSNode] -> [JSNode]
stripSemis xs = filter (\x -> (extractNode x) /= JSLiteral ";" && (extractNode x) /= JSLiteral "") xs

fixSemis' :: [JSNode] -> [JSNode]
fixSemis' [] = []
fixSemis' [(NN (JSContinue c [(NT (JSLiteral ";") _ _)] as) )] = [(NN (JSContinue c [] as) )]
fixSemis' [x] = [x]

fixSemis' ((NN (JSIf i lb c rb [NN (JSBlock [NT (JSLiteral "{") p1 cs1] [] [NT (JSLiteral "}") p2 cs2])] []) ):xs) =
(NN (JSIf i lb c rb [NN (JSBlock [NT (JSLiteral "{") p1 cs1] [] [NT (JSLiteral "}") p2 cs2])] []) ):(fixSemis' xs)

fixSemis' ((NN (JSIf i lb c rb [(NT (JSLiteral ";") s1 c1)] []) ):xs) =
(NN (JSIf i lb c rb [(NT (JSLiteral ";") s1 c1)] []) ):(fixSemis' xs)

fixSemis' ((NN (JSIf i lb c rb [(NN (JSReturn r [(NT (JSLiteral ";") s1 c1)] as) )] e) ):xs) =
(NN (JSIf i lb c rb [(NN (JSReturn r [(NT (JSLiteral ";") s1 c1)] as) )] e) ):(fixSemis' xs)

fixSemis' ((NN (JSIf i lb c rb [(NN (JSContinue co [(NT (JSLiteral ";") s1 c1)] as) )] e) ):xs) =
(NN (JSIf i lb c rb [(NN (JSContinue co [(NT (JSLiteral ";") s1 c1)] as) )] e) ):(fixSemis' xs)

fixSemis' (x:(NT (JSLiteral "\n") s1 c1):xs) = x:(NT (JSLiteral "\n") s1 c1):(fixSemis' xs) -- TODO: is this needed?

fixSemis' ((NN (JSCase ca1 e1 c1 [] ) ):(NN (JSCase ca2 e2 c2 x) ):xs) =
(NN (JSCase ca1 e1 c1 [] ) ):fixSemis' ((NN (JSCase ca2 e2 c2 x) ):xs)

fixSemis' (x:xs) = x:(NT (JSLiteral ";") tokenPosnEmpty []):fixSemis' xs

fixIfElse :: [JSNode] -> [JSNode]
fixIfElse [(NN (JSBlock lb xs rb))] = [(NN (JSBlock lb (fixSourceElements xs) rb))]
fixIfElse [x] = [(NN (JSBlock [(NT (JSLiteral "{") tokenPosnEmpty [])] (fixSourceElements [x]) [(NT (JSLiteral "}") tokenPosnEmpty [])]))]
fixIfElse xs = xs

fixFnBlock :: JSNode -> JSNode
fixFnBlock (NN (JSBlock lb xs rb)) = (NN (JSBlock lb (fixSourceElements xs) rb))
fixFnBlock x = fixBlock x

fixIfBlock :: [JSNode] -> [JSNode]
fixIfBlock xs =
case xs' of
[(NT (JSLiteral ";") _p _cs)] -> [] -- rely on fixSemis to add this again [(NT (JSLiteral ";") p cs)]
[(NN (JSBlock _lb [] _rb))] -> [] -- rely on fixSemis to add this again [(NT (JSLiteral ";") tokenPosnEmpty [])]
-- [(NN (JSBlock lb [y] rb))] -> [fixBlock y]
[(NN (JSBlock lb x2s rb))] -> [(NN (JSBlock lb ((fixSourceElements $ map fixBlock x2s)) rb))]
[x] -> fixSourceElements [x]
[] -> []
xs'' -> fixSourceElements xs''
where xs' = stripSemis xs

fixBlock :: JSNode -> JSNode

fixBlock (NN (JSBlock lb xs rb)) =
case xs' of
[] -> (NT (JSLiteral ";") tokenPosnEmpty [])
-- [(NN (JSExpression [y]))] -> fixBlock (NN (JSExpression [y]))
-- [(NN (JSExpression xs))] -> (NN (JSBlock lb (fixSourceElements $ map fixBlock xs') rb))
[x] -> fixBlock x
_ -> (NN (JSBlock lb (fixSourceElements $ map fixBlock xs') rb))
where xs' = stripSemis xs

fixBlock x = x

spaceNeeded :: [JSNode] -> Bool
spaceNeeded xs =
let
-- str = show $ rJS xs
str = LB.unpack $ BB.toLazyByteString $ rJS xs
in
head str /= (fromIntegral $ ord '(')


_r :: JSNode -> [Char]
_r js = map (\x -> chr (fromIntegral x)) $ LB.unpack $ BB.toLazyByteString $ renderJS js

--readJs "{{{}}}"
_case0 :: JSNode
_case0 = undefined --

_case1 :: JSNode
_case1 = undefined --

_case11 :: [JSNode]
_case11 = undefined -- [NN (JSIf (NN (JSExpression [NS (JSIdentifier "x") (SpanPoint {span_filename = "", span_row = 1, span_column = 4})]) (SpanPoint {span_filename = "", span_row = 1, span_column = 4})) (NN (JSStatementBlock (NN (JSStatementList []) (SpanPoint {span_filename = "", span_row = 1, span_column = 6}))) (SpanPoint {span_filename = "", span_row = 1, span_column = 6}))) (SpanPoint {span_filename = "", span_row = 1, span_column = 1}),NN (JSStatementBlock (NN (JSStatementList [NS (JSExpression [NS (JSIdentifier "a") (SpanPoint {span_filename = "", span_row = 1, span_column = 9}),NS (JSOperator "=") (SpanPoint {span_filename = "", span_row = 1, span_column = 10}),NS (JSDecimal "2") (SpanPoint {span_filename = "", span_row = 1, span_column = 11})]) (SpanPoint {span_filename = "", span_row = 1, span_column = 9})]) (SpanPoint {span_filename = "", span_row = 1, span_column = 9}))) (SpanPoint {span_filename = "", span_row = 1, span_column = 8})]

_case12 :: JSNode
_case12 = undefined -- (NN (JSIf (NN (JSExpression [NS (JSIdentifier "x") (SpanPoint {span_filename = "", span_row = 1, span_column = 4})]) (SpanPoint {span_filename = "", span_row = 1, span_column = 4})) (NT (JSLiteral "") (SpanPoint {span_filename = "", span_row = 1, span_column = 6}))) (SpanPoint {span_filename = "", span_row = 1, span_column = 6}))

_case2 :: JSNode
_case2 = undefined -- NS (JSSourceElementsTop [NS (JSLabelled (NS (JSIdentifier "bob") (SpanPoint {span_filename = "", span_row = 1, span_column = 1})) (NN (JSIf (NN (JSExpression [NS (JSIdentifier "x") (SpanPoint {span_filename = "", span_row = 1, span_column = 8})]) (SpanPoint {span_filename = "", span_row = 1, span_column = 8})) (NN (JSStatementBlock (NN (JSStatementList []) (SpanPoint {span_filename = "", span_row = 1, span_column = 10}))) (SpanPoint {span_filename = "", span_row = 1, span_column = 10}))) (SpanPoint {span_filename = "", span_row = 1, span_column = 5}))) (SpanPoint {span_filename = "", span_row = 1, span_column = 1}),NN (JSStatementBlock (NN (JSStatementList [NS (JSExpression [NS (JSIdentifier "a") (SpanPoint {span_filename = "", span_row = 2, span_column = 2})]) (SpanPoint {span_filename = "", span_row = 2, span_column = 2})]) (SpanPoint {span_filename = "", span_row = 2, span_column = 2}))) (SpanPoint {span_filename = "", span_row = 2, span_column = 1})]) (SpanPoint {span_filename = "", span_row = 1, span_column = 1})




+ 0
- 65
vendor/hjsmin/hjsmin.cabal View File

@@ -1,65 +0,0 @@
name: hjsmin
version: 0.1.5.1
license: BSD3
license-file: LICENSE
author: Alan Zimmerman <alan.zimm@gmail.com>
maintainer: Erik de Castro Lopo <erikd@mega-nerd.com>
synopsis: Haskell implementation of a javascript minifier
description:
Reduces size of javascript files by stripping out extraneous whitespace and
other syntactic elements, without changing the semantics.
category: Web
stability: unstable
cabal-version: >= 1.9.2
build-type: Simple
homepage: http://github.com/erikd/hjsmin
bug-reports: http://github.com/erikd/hjsmin/issues

Extra-source-files:
TODO.txt
, Readme.md
, test/pminified/*.js
, test/parsingonly/*.js


library
build-depends: base >= 4
, bytestring >= 0.9
, blaze-builder >= 0.2
, text >= 0.8
, containers >= 0.2
, language-javascript >= 0.5.14 && < 0.6
exposed-modules: Text.Jasmine
other-modules: Text.Jasmine.Pretty
ghc-options: -Wall

executable hjsmin
main-is: hjsmin.hs

ghc-options: -Wall -threaded
build-depends: base >= 4 && < 5
, bytestring >= 0.9
, blaze-builder >= 0.2
, text >= 0.8
, containers >= 0.2
, language-javascript >= 0.5.14
, optparse-applicative >= 0.7

Test-Suite test-hjsmin
Type: exitcode-stdio-1.0
Main-is: runtests.hs
build-depends: Cabal >= 1.9.2
, QuickCheck >= 2
, HUnit
, test-framework
, test-framework-hunit
, base >= 4 && < 5
, bytestring >= 0.9
, blaze-builder >= 0.2
, text >= 0.8
, containers >= 0.2
, language-javascript >= 0.5.14

source-repository head
type: git
location: https://github.com/erikd/hjsmin.git

+ 0
- 41
vendor/hjsmin/hjsmin.hs View File

@@ -1,41 +0,0 @@
module Main where

import Options.Applicative
import Text.Jasmine

import qualified Data.ByteString.Lazy as B
import qualified Data.ByteString.Lazy.Char8 as C8


data Options = Options
{ inputFile :: String
, outputFile :: Maybe String
}

main :: IO ()
main =
execParser opts >>= minify'
where
opts = info (helper <*> options)
( fullDesc
<> progDesc "Minify JavaScript files."
<> header "hjsmin - a simple command-line interface to the 'hjsmin' library"
)

options :: Parser Options
options = Options
<$> argument str (metavar "INPUT_FILE"
<> help "The unminified, original JavaScript file")
<*> optional
( strOption (long "output-file"
<> short 'o'
<> metavar "OUTPUT_FILE"
<> help "The minified output file. Default: stdout")
)

minify' :: Options -> IO ()
minify' o = do
minified <- minifyFile (inputFile o)
case outputFile o of
Nothing -> C8.putStrLn minified
Just f -> B.writeFile f minified

+ 0
- 335
vendor/hjsmin/resources/JavaScript.grm View File

@@ -1,335 +0,0 @@
"Name" = 'JavaScript Grammar'
"Author" = 'M.Schnoor-Matriciani'
"Version" = '0.9'
"About" = 'JavaScript Grammar, Subset of ECMA Edition 3'
"Start Symbol" = <Program>
"Case Sensitive" = 'True'
! ------------------------------------------------- Sets
{ID Head} = {Letter} + [_] + [$]
{ID Tail} = {Alphanumeric} + [_] + [$]
{String Chars1} = {Printable} + {HT} - ["\]
{String Chars2} = {Printable} + {HT} - [\'']
{Hex Digit} = {Digit} + [ABCDEF] + [abcdef]
{RegExp Chars} = {Letter}+{Digit}+['^']+['$']+['*']+['+']+['?']+['{']+['}']+['|']+['-']+['.']+[',']+['#']+['[']+[']']+['_']+['<']+['>']
{Non Terminator} = {String Chars1} - {CR} - {LF}
{Non Zero Digits}={Digit}-[0]
! ------------------------------------------------- Terminals
Identifier = {ID Head}{ID Tail}*
StringLiteral = '"' ( {String Chars1} | '\' {Printable} )* '"' | '' ( {String Chars2} | '\' {Printable} )* ''
HexIntegerLiteral = '0x' {Hex Digit}+
RegExp = '/' ({RegExp Chars} | '\' {Non Terminator})+ '/' ( 'g' | 'i' | 'm' )*
DecimalLiteral= {Non Zero Digits}+ '.' {Digit}* ('e' | 'E' ) {Non Zero Digits}+ {Digit}* | {Non Zero Digits}+ '.' {Digit}* | '0' '.' {Digit}+ ('e' | 'E' ) {Non Zero Digits}+ {Digit}* | {Non Zero Digits}+ {Digit}* | '0' | '0' '.' {Digit}+
Comment Start = '/*'
Comment End = '*/'
Comment Line = '//'
! ------------------------------------------------- Rules
<Literal> ::= <Null Literal>
| <Boolean Literal>
| <Numeric Literal>
| StringLiteral
<Null Literal> ::= null
<Boolean Literal> ::= 'true'
| 'false'
<Numeric Literal> ::= DecimalLiteral
| HexIntegerLiteral
<Regular Expression Literal> ::= RegExp
<Primary Expression> ::= 'this'
| Identifier
| <Literal>
| <Array Literal>
| <Object Literal>
| '(' <Expression> ')'
| <Regular Expression Literal>
<Array Literal> ::= '[' ']'
| '[' <Elision> ']'
| '[' <Element List> ']'
| '[' <Element List> ',' <Elision> ']'
<Elision> ::= ','
| <Elision> ','
<Element List> ::= <Elision> <Assignment Expression>
| <Element List> ',' <Elision> <Assignment Expression>
| <Element List> ',' <Assignment Expression>
| <Assignment Expression>
<Object Literal> ::= '{' <Property Name and Value List> '}'
<Property Name and Value List> ::= <Property Name> ':' <Assignment Expression>
| <Property Name and Value List> ',' <Property Name> ':' <Assignment Expression>
<Property Name> ::= Identifier
| StringLiteral
| <Numeric Literal>
<Member Expression > ::= <Primary Expression>
| <Function Expression>
| <Member Expression> '[' <Expression> ']'
| <Member Expression> '.' Identifier
| 'new' <Member Expression> <Arguments>
<New Expression> ::= <Member Expression>
| new <New Expression>
<Call Expression> ::= <Member Expression> <Arguments>
| <Call Expression> <Arguments>
| <Call Expression> '[' <Expression> ']'
| <Call Expression> '.' Identifier
<Arguments> ::= '(' ')'
| '(' <Argument List> ')'
<Argument List> ::= <Assignment Expression>
| <Argument List> ',' <Assignment Expression>
<Left Hand Side Expression> ::= <New Expression>
| <Call Expression>
<Postfix Expression> ::= <Left Hand Side Expression>
| <Postfix Expression> '++'
| <Postfix Expression> '--'
<Unary Expression> ::= <Postfix Expression>
| 'delete' <Unary Expression>
| 'void' <Unary Expression>
| 'typeof' <Unary Expression>
| '++' <Unary Expression>
| '--' <Unary Expression>
| '+' <Unary Expression>
| '-' <Unary Expression>
| '~' <Unary Expression>
| '!' <Unary Expression>
<Multiplicative Expression> ::= <Unary Expression>
| <Unary Expression> '*' <Multiplicative Expression>
| <Unary Expression> '/' <Multiplicative Expression>
| <Unary Expression> '%' <Multiplicative Expression>
<Additive Expression> ::= <Additive Expression>'+'<Multiplicative Expression>
| <Additive Expression>'-'<Multiplicative Expression>
| <Multiplicative Expression>
<Shift Expression> ::= <Shift Expression> '<<' <Additive Expression>
| <Shift Expression> '>>' <Additive Expression>
| <Shift Expression> '>>>' <Additive Expression>
| <Additive Expression>
<Relational Expression>::= <Shift Expression>
| <Relational Expression> '<' <Shift Expression>
| <Relational Expression> '>' <Shift Expression>
| <Relational Expression> '<=' <Shift Expression>
| <Relational Expression> '>=' <Shift Expression>
| <Relational Expression> 'instanceof' <Shift Expression>
<Equality Expression> ::= <Relational Expression>
| <Equality Expression> '==' <Relational Expression>
| <Equality Expression> '!=' <Relational Expression>
| <Equality Expression> '===' <Relational Expression>
| <Equality Expression> '!==' <Relational Expression>
<Bitwise And Expression> ::= <Equality Expression>
| <Bitwise And Expression> '&' <Equality Expression>
<Bitwise XOr Expression> ::= <Bitwise And Expression>
| <Bitwise XOr Expression> '^' <Bitwise And Expression>
<Bitwise Or Expression> ::= <Bitwise XOr Expression>
| <Bitwise Or Expression> '|' <Bitwise XOr Expression>
<Logical And Expression> ::= <Bitwise Or Expression>
| <Logical And Expression> '&&' <Bitwise Or Expression>
<Logical Or Expression> ::= <Logical And Expression>
| <Logical Or Expression> '||' <Logical And Expression>
<Conditional Expression> ::= <Logical Or Expression>
| <Logical Or Expression> '?' <Assignment Expression> ':' <Assignment Expression>
<Assignment Expression> ::= <Conditional Expression>
| <Left Hand Side Expression> <Assignment Operator> <Assignment Expression>
<Assignment Operator> ::= '=' | '*=' | '/=' | '%=' | '+=' | '-=' | '<<=' | '>>=' | '>>>=' | '&=' | '^=' | '|='
<Expression> ::= <Assignment Expression>
| <Expression> ',' <Assignment Expression>
<Statement> ::= <Block>
| <Variable Statement>
| <Empty Statement>
| <If Statement>
| <If Else Statement>
| <Iteration Statement>
| <Continue Statement>
| <Break Statement>
| <Return Statement>
| <With Statement>
| <Labelled Statement>
| <Switch Statement>
| <Throw Statement>
| <Try Statement>
| <Expression>
<Block > ::= '{' '}'
| '{' <Statement List> '}'
<Statement List> ::= <Statement>
| <Statement List> <Statement>
<Variable Statement> ::= var <Variable Declaration List> ';'
<Variable Declaration List> ::= <Variable Declaration>
| <Variable Declaration List> ',' <Variable Declaration>
<Variable Declaration> ::= Identifier
| Identifier <Initializer>
<Initializer> ::= '=' <Assignment Expression>
<Empty Statement> ::= ';'
<If Statement> ::= 'if' '(' <Expression> ')' <Statement>
<If Else Statement> ::= 'if' '(' <Expression> ')' <Statement> 'else' <Statement>
<Iteration Statement> ::= 'do' <Statement> 'while' '(' <Expression> ')' ';'
| 'while' '(' <Expression> ')' <Statement>
| 'for' '(' <Expression> ';' <Expression> ';' <Expression> ')' <Statement>
| 'for' '(' 'var' <Variable Declaration List> ';' <Expression> ';' <Expression> ')' <Statement>
| 'for' '(' <Left Hand Side Expression> in <Expression> ')' <Statement>
| 'for' '(' 'var' <Variable Declaration> in <Expression> ')' <Statement>
<Continue Statement> ::= 'continue' ';'
| 'continue' Identifier ';'
<Break Statement> ::= 'break' ';'
| 'break' Identifier ';'
<Return Statement> ::= 'return' ';'
| 'return' <Expression> ';'
<With Statement> ::= 'with' '(' <Expression> ')' <Statement> ';'
<Switch Statement> ::= 'switch' '(' <Expression> ')' <Case Block>
<Case Block> ::= '{' '}'
| '{' <Case Clauses> '}'
| '{' <Case Clauses> <Default Clause> '}'
| '{' <Case Clauses> <Default Clause> <Case Clauses> '}'
| '{' <Default Clause> <Case Clauses> '}'
| '{' <Default Clause> '}'
<Case Clauses> ::= <Case Clause>
| <Case Clauses> <Case Clause>
<Case Clause> ::= 'case' <Expression> ':' <Statement List>
| 'case' <Expression> ':'
<Default Clause> ::= 'default' ':'
| 'default' ':' <Statement List>
<Labelled Statement> ::= Identifier ':' <Statement>
<Throw Statement> ::= 'throw' <Expression>
<Try Statement> ::= 'try' <Block> <Catch>
| 'try' <Block> <Finally>
| 'try' <Block> <Catch> <Finally>
<Catch> ::= 'catch' '(' Identifier ')' <Block>
<Finally> ::= 'finally' <Block>
<Function Declaration> ::= 'function' Identifier '(' <Formal Parameter List> ')' '{' <Function Body> '}'
| 'function' Identifier '(' ')' '{' <Function Body> '}'
<Function Expression> ::= 'function' '(' ')' '{' <Function Body> '}'
| 'function' '(' <Formal Parameter List> ')' '{' <Function Body> '}'
<Formal Parameter List> ::= Identifier
| <Formal Parameter List> ',' Identifier
<Function Body> ::= <Source Elements>
|
<Program> ::= <Source Elements>
<Source Elements> ::= <Source Element>
| <Source Elements> <Source Element>
<Source Element> ::= <Statement>
| <Function Declaration>

+ 0
- 9
vendor/hjsmin/resources/README.txt View File

@@ -1,9 +0,0 @@
This file originates from

http://www.devincook.com/GOLDParser/grammars/files/JavaScript.zip

on page

http://www.devincook.com/GOLDParser/grammars/index.htm

It is used as a model for the parser

+ 0
- 370
vendor/hjsmin/runtests.hs View File

@@ -1,373 +0,0 @@

import Data.Char
import Language.JavaScript.Parser
import Test.Framework (defaultMain, testGroup, Test)
import Test.Framework.Providers.HUnit
import Test.HUnit hiding (Test)

import qualified Data.ByteString.Lazy as LB
import qualified Data.Text as T
import qualified Data.Text.Encoding as E

import Text.Jasmine
import Text.Jasmine.Pretty

main :: IO ()
main = defaultMain
[ testSuite
, testSuiteMin
, testSuiteFiles
, testSuiteFilesUnminified
]

testSuite :: Test
testSuite = testGroup "Text.Jasmine.Parse"
[ testCase "helloWorld" caseHelloWorld
, testCase "helloWorld2" caseHelloWorld2
, testCase "simpleAssignment" caseSimpleAssignment
, testCase "emptyFor" caseEmptyFor
, testCase "fullFor" caseFullFor
, testCase "forVarFull" caseForVarFull
, testCase "ifelse1" caseIfElse1
, testCase "ifelse2" caseIfElse2
, testCase "0_f.js" case0_f
, testCase "01_semi1.js" case01_semi1
, testCase "min_100_animals" case_min_100_animals
, testCase "mergeStrings" caseMergeStrings
, testCase "TrailingCommas" caseTrailingCommas
, testCase "GetSet" caseGetSet
, testCase "Unicode" caseUnicode
, testCase "Issue3" caseIssue3
, testCase "Issue4" caseIssue4
, testCase "Switch1" caseSwitch1
, testCase "If1" caseIf1
, testCase "If2" caseIf2
, testCase "If3" caseIf3
, testCase "BootstrapDropdown" caseBootstrapDropdown
, testCase "Issue8" caseIssue8
, testCase "Issue9" caseIssue9
, testCase "Issue14" caseIssue14
]

testSuiteMin :: Test
testSuiteMin = testGroup "Text.Jasmine.Pretty Min"
[ testCase "helloWorld" caseMinHelloWorld
, testCase "helloWorld2" caseMinHelloWorld2
, testCase "simpleAssignment" caseMinSimpleAssignment
, testCase "ifelse1" caseMinIfElse1
, testCase "ifelse2" caseMinIfElse2
, testCase "ifelse3" caseMinIfElse3
, testCase "0_f.js" caseMin0_f
, testCase "01_semi1.js" caseMin01_semi1
, testCase "min_100_animals" caseMin_min_100_animals
, testCase "minNestedSquare" caseMinNestedSquare
, testCase "minMergeStrings" caseMinMergeStrings
, testCase "EitherLeft" caseEitherLeft
, testCase "EitherRight" caseEitherRight
, testCase "TrailingCommas" caseMinTrailingCommas
, testCase "GetSet" caseMinGetSet
, testCase "Unicode" caseMinUnicode
, testCase "MinIssue3" caseMinIssue3
, testCase "MinIssue4" caseMinIssue4
, testCase "MinSwitch1" caseMinSwitch1
, testCase "MinIf1" caseMinIf1
, testCase "MinIf2" caseMinIf2
, testCase "MinIf3" caseMinIf3
, testCase "MinBootstrapDropdown" caseMinBootstrapDropdown
, testCase "MinIssue8" caseMinIssue8
, testCase "MinIssue9" caseMinIssue9
, testCase "MinIssue14" caseMinIssue14

]

testSuiteFiles :: Test
testSuiteFiles = testGroup "Text.Jasmine.Pretty files"
[ testCase "00_f.js" (testFile "./test/pminified/00_f.js")
, testCase "01_semi1.js" (testFile "./test/pminified/01_semi1.js")
, testCase "02_sm.js" (testFile "./test/pminified/02_sm.js")
, testCase "03_sm.js" (testFile "./test/pminified/03_sm.js")
, testCase "04_if.js" (testFile "./test/pminified/04_if.js")
, testCase "05_comments_simple.js" (testFile "./test/pminified/05_comments_simple.js")
, testCase "05_regex.js" (testFile "./test/pminified/05_regex.js")
, testCase "06_callexpr.js" (testFile "./test/pminified/06_callexpr.js")
, testCase "06_newexpr.js" (testFile "./test/pminified/06_newexpr.js")
, testCase "06_var.js" (testFile "./test/pminified/06_var.js")
, testCase "07_expr.js" (testFile "./test/pminified/07_expr.js")
, testCase "10_switch.js" (testFile "./test/pminified/10_switch.js")
, testCase "14_labelled_stmts.js" (testFile "./test/pminified/14_labelled_stmts.js")
, testCase "15_literals.js" (testFile "./test/pminified/15_literals.js")
, testCase "16_literals.js" (testFile "./test/pminified/16_literals.js")
, testCase "20_statements.js" (testFile "./test/pminified/20_statements.js")
, testCase "20_continue_loop.js" (testFile "./test/pminified/20_continue_loop.js")
, testCase "25_trycatch.js" (testFile "./test/pminified/25_trycatch.js")
, testCase "40_functions.js" (testFile "./test/pminified/40_functions.js")
, testCase "67_bob.js" (testFile "./test/pminified/67_bob.js")
, testCase "110_perfect.js" (testFile "./test/pminified/110_perfect.js")
, testCase "120_js.js" (testFile "./test/pminified/120_js.js")
, testCase "121_jsdefs.js" (testFile "./test/pminified/121_jsdefs.js")
, testCase "122_jsexec.js" (testFile "./test/pminified/122_jsexec.js")
, testCase "122_jsexec2.js" (testFile "./test/pminified/122_jsexec2.js")
, testCase "122_jsexec3.js" (testFile "./test/pminified/122_jsexec3.js")
-- , testCase "123_jsparse.js" (testFile "./test/pminified/123_jsparse.js")

-- TODO: something strange here, assigning code block to variable?
-- See http://msdn.microsoft.com/en-us/library/77kz8hy0.aspx, get/set keywords for object accessors

--, testCase "130_htojs2.js" (testFile "./test/parsingonly/130_htojs2.js")
--, testCase "" (testFile "./test/pminified/")
]

testSuiteFilesUnminified :: Test
testSuiteFilesUnminified = testGroup "Text.Jasmine.Pretty filesUnminified"
[ testCase "00_f.js" (testFileUnminified "00_f.js")
, testCase "01_semi1.js" (testFileUnminified "01_semi1.js")
, testCase "02_sm.js" (testFileUnminified "02_sm.js")
, testCase "03_sm.js" (testFileUnminified "03_sm.js")
, testCase "04_if.js" (testFileUnminified "04_if.js")
, testCase "05_comments_simple.js" (testFileUnminified "05_comments_simple.js")
, testCase "05_regex.js" (testFileUnminified "05_regex.js")
, testCase "06_callexpr.js" (testFileUnminified "06_callexpr.js")
, testCase "06_newexpr.js" (testFileUnminified "06_newexpr.js")
, testCase "06_var.js" (testFileUnminified "06_var.js")
, testCase "07_expr.js" (testFileUnminified "07_expr.js")
, testCase "10_switch.js" (testFileUnminified "10_switch.js")
, testCase "14_labelled_stmts.js" (testFileUnminified "14_labelled_stmts.js")
, testCase "15_literals.js" (testFileUnminified "15_literals.js")
, testCase "16_literals.js" (testFileUnminified "16_literals.js")
, testCase "20_statements.js" (testFileUnminified "20_statements.js")
, testCase "25_trycatch.js" (testFileUnminified "25_trycatch.js")
, testCase "40_functions.js" (testFileUnminified "40_functions.js")
, testCase "67_bob.js" (testFileUnminified "67_bob.js")
, testCase "110_perfect.js" (testFileUnminified "110_perfect.js")
, testCase "120_js.js" (testFileUnminified "120_js.js")
, testCase "121_jsdefs.js" (testFileUnminified "121_jsdefs.js")
, testCase "122_jsexec.js" (testFileUnminified "122_jsexec.js")

--, testCase "122_jsexec2.js" (testFileUnminified "122_jsexec2.js")
]

srcHelloWorld = "function Hello(a) {}"
caseHelloWorld =
"Right (JSSourceElementsTop [JSFunction (JSIdentifier \"Hello\") [JSIdentifier \"a\"] (JSBlock ([])),JSLiteral \"\"])"
@=? showStrippedMaybe (parseProgram srcHelloWorld)
caseMinHelloWorld =
-- "function Hello(a){}" @=? (minify (U.fromString srcHelloWorld))
testMinify "function Hello(a){}" srcHelloWorld

srcHelloWorld2 = "function Hello(a) {b=1}"
caseHelloWorld2 =
"Right (JSSourceElementsTop [JSFunction (JSIdentifier \"Hello\") [JSIdentifier \"a\"] (JSBlock ([JSExpression [JSIdentifier \"b\",JSOperator JSLiteral \"=\",JSDecimal \"1\"]])),JSLiteral \"\"])"
@=? showStrippedMaybe (parseProgram srcHelloWorld2)
caseMinHelloWorld2 =
-- "function Hello(a){b=1}" @=? (minify (U.fromString srcHelloWorld2))
testMinify "function Hello(a){b=1}" srcHelloWorld2

srcSimpleAssignment = "a=1;"
caseSimpleAssignment =
"Right (JSSourceElementsTop [JSExpression [JSIdentifier \"a\",JSOperator JSLiteral \"=\",JSDecimal \"1\"],JSLiteral \";\",JSLiteral \"\"])"
@=? showStrippedMaybe (parseProgram srcSimpleAssignment)
caseMinSimpleAssignment =
testMinify "a=1" srcSimpleAssignment

srcEmptyFor = "for (i = 0;;){}"
caseEmptyFor =
"Right (JSSourceElementsTop [JSFor [JSExpression [JSIdentifier \"i\",JSOperator JSLiteral \"=\",JSDecimal \"0\"]] [] [] (JSBlock ([])),JSLiteral \"\"])"
@=? showStrippedMaybe (parseProgram srcEmptyFor)
srcFullFor = "for (i = 0;i<10;i++){}"
caseFullFor =
"Right (JSSourceElementsTop [JSFor [JSExpression [JSIdentifier \"i\",JSOperator JSLiteral \"=\",JSDecimal \"0\"]] [JSExpression [JSExpressionBinary \"<\" [JSIdentifier \"i\"] [JSDecimal \"10\"]]] [JSExpression [JSExpressionPostfix \"++\" [JSIdentifier \"i\"]]] (JSBlock ([])),JSLiteral \"\"])"
@=? showStrippedMaybe (parseProgram srcFullFor)

srcForVarFull = "for(var i=0,j=tokens.length;i<j;i++){}"
caseForVarFull =
"Right (JSSourceElementsTop [JSForVar [JSVarDecl (JSIdentifier \"i\") [JSLiteral \"=\",JSDecimal \"0\"],JSLiteral \",\",JSVarDecl (JSIdentifier \"j\") [JSLiteral \"=\",JSMemberDot [JSIdentifier \"tokens\"] (JSIdentifier \"length\")]] [JSExpression [JSExpressionBinary \"<\" [JSIdentifier \"i\"] [JSIdentifier \"j\"]]] [JSExpression [JSExpressionPostfix \"++\" [JSIdentifier \"i\"]]] (JSBlock ([])),JSLiteral \"\"])"
@=? showStrippedMaybe (parseProgram srcForVarFull)

srcIfElse1 = "if(a){b=1}else c=2";
caseIfElse1 =
"Right (JSSourceElementsTop [JSIf (JSExpression [JSIdentifier \"a\"]) ([JSBlock ([JSExpression [JSIdentifier \"b\",JSOperator JSLiteral \"=\",JSDecimal \"1\"]])]) ([JSLiteral \"else\",JSExpression [JSIdentifier \"c\",JSOperator JSLiteral \"=\",JSDecimal \"2\"]]),JSLiteral \"\"])"
@=? showStrippedMaybe (parseProgram srcIfElse1)
caseMinIfElse1 =
testMinify "if(a){b=1}else c=2" srcIfElse1

srcIfElse2 = "if(a){b=1}else {c=2;d=4}";
caseIfElse2 =
"Right (JSSourceElementsTop [JSIf (JSExpression [JSIdentifier \"a\"]) ([JSBlock ([JSExpression [JSIdentifier \"b\",JSOperator JSLiteral \"=\",JSDecimal \"1\"]])]) ([JSLiteral \"else\",JSBlock ([JSExpression [JSIdentifier \"c\",JSOperator JSLiteral \"=\",JSDecimal \"2\"],JSLiteral \";\",JSExpression [JSIdentifier \"d\",JSOperator JSLiteral \"=\",JSDecimal \"4\"]])]),JSLiteral \"\"])"
@=? showStrippedMaybe (parseProgram srcIfElse2)
caseMinIfElse2 =
testMinify "if(a){b=1}else{c=2;d=4}" srcIfElse2

srcIfElse3 = "if (1)\n;\nelse if(2)\n{3;}"
caseMinIfElse3 =
testMinify "if(1);else if(2)3" srcIfElse3

src0_f = "function Hello(a) {ExprArray(1,1);}"
case0_f =
"Right (JSSourceElementsTop [JSFunction (JSIdentifier \"Hello\") [JSIdentifier \"a\"] (JSBlock ([JSExpression [JSIdentifier \"ExprArray\",JSArguments [JSDecimal \"1\",JSLiteral \",\",JSDecimal \"1\"]],JSLiteral \";\"])),JSLiteral \"\"])"
-- @=? (show $ parseString program src0_f)
@=? showStrippedMaybe (parseProgram src0_f)
caseMin0_f =
testMinify "function Hello(a){ExprArray(1,1)}" src0_f

src01_semi1 = "{zero.one1;zero}\none1\ntwo;three\n{{}} four;\n// five\nfive"
case01_semi1 =
"Right (JSSourceElementsTop [JSBlock ([JSExpression [JSMemberDot [JSIdentifier \"zero\"] (JSIdentifier \"one1\")],JSLiteral \";\",JSExpression [JSIdentifier \"zero\"]]),JSExpression [JSIdentifier \"one1\"],JSExpression [JSIdentifier \"two\"],JSLiteral \";\",JSExpression [JSIdentifier \"three\"],JSBlock ([JSBlock ([])]),JSExpression [JSIdentifier \"four\"],JSLiteral \";\",JSExpression [JSIdentifier \"five\"],JSLiteral \"\"])"
@=? showStrippedMaybe (parseProgram src01_semi1)
caseMin01_semi1 =
testMinify "{zero.one1;zero};one1;two;three;four;five" src01_semi1

src_min_100_animals = "function Animal(name){if(!name)throw new Error('Must specify an animal name');this.name=name};Animal.prototype.toString=function(){return this.name};o=new Animal(\"bob\");o.toString()==\"bob\""
case_min_100_animals =
"Right (JSSourceElementsTop [JSFunction (JSIdentifier \"Animal\") [JSIdentifier \"name\"] (JSBlock ([JSIf (JSExpression [JSUnary \"!\",JSIdentifier \"name\"]) ([JSThrow (JSExpression [JSLiteral \"new\",JSIdentifier \"Error\",JSArguments [JSStringLiteral '\\'' \"Must specify an animal name\"]]),JSLiteral \";\"]) ([]),JSExpression [JSMemberDot [JSLiteral \"this\"] (JSIdentifier \"name\"),JSOperator JSLiteral \"=\",JSIdentifier \"name\"]])),JSLiteral \";\",JSExpression [JSMemberDot [JSMemberDot [JSIdentifier \"Animal\"] (JSIdentifier \"prototype\")] (JSIdentifier \"toString\"),JSOperator JSLiteral \"=\",JSFunctionExpression [] [] (JSBlock ([JSReturn [JSExpression [JSMemberDot [JSLiteral \"this\"] (JSIdentifier \"name\")]] JSLiteral \"\"]))],JSLiteral \";\",JSExpression [JSIdentifier \"o\",JSOperator JSLiteral \"=\",JSLiteral \"new\",JSIdentifier \"Animal\",JSArguments [JSStringLiteral '\"' \"bob\"]],JSLiteral \";\",JSExpression [JSExpressionBinary \"==\" [JSMemberDot [JSIdentifier \"o\"] (JSIdentifier \"toString\"),JSArguments []] [JSStringLiteral '\"' \"bob\"]],JSLiteral \"\"])"
@=? showStrippedMaybe (parseProgram src_min_100_animals)
caseMin_min_100_animals =
testMinify src_min_100_animals src_min_100_animals

srcMergeStrings = "throw new TypeError(\"Function.prototype.apply called on\"+\" uncallable object\");"
caseMergeStrings =
"Right (JSSourceElementsTop [JSThrow (JSExpression [JSLiteral \"new\",JSIdentifier \"TypeError\",JSArguments [JSExpressionBinary \"+\" [JSStringLiteral '\"' \"Function.prototype.apply called on\"] [JSStringLiteral '\"' \" uncallable object\"]]]),JSLiteral \";\",JSLiteral \"\"])"
@=? showStrippedMaybe (parseProgram srcMergeStrings)
caseMinMergeStrings =
testMinify "throw new TypeError(\"Function.prototype.apply called on uncallable object\")" srcMergeStrings

srcNestedSquare = "this.cursor+=match[0].length;"
caseNestedSquare =
"Right (JSSourceElementsTop [JSExpression [JSMemberDot [JSLiteral \"this\"] (JSIdentifier \"cursor\"),JSOperator \"+=\",JSMemberDot [JSMemberSquare [JSIdentifier \"match\"] (JSExpression [JSDecimal \"0\"])] (JSIdentifier \"length\")],JSLiteral \";\"])"
@=? showStrippedMaybe (parseProgram srcNestedSquare)
caseMinNestedSquare =
testMinify "this.cursor+=match[0].length" srcNestedSquare

caseEitherLeft =
-- Left "UnexpectedToken (MulToken {tokenSpan = (AlexPn 2 1 3,'=',\"*SYNTAX*ERROR*\")})"
-- Left "\"MulToken {tokenSpan = TokenPn 2 1 3, tokenComment = [NoComment]}\""
Left "\"MulToken {tokenSpan = TokenPn 2 1 3, tokenComment = [NoComment]}\""
@=? minifym (LB.fromChunks [E.encodeUtf8 (T.pack "a=*SYNTAX*ERROR*")])

caseEitherRight =
Right (LB.fromChunks [E.encodeUtf8 (T.pack "a=\"no syntax error\"")]) @=? minifym (LB.fromChunks [E.encodeUtf8 (T.pack "a=\"no syntax error\";")])

srcTrailingCommas = "x={a:1,};y=[d,e,];"
caseTrailingCommas =
"Right (JSSourceElementsTop [JSExpression [JSIdentifier \"x\",JSOperator JSLiteral \"=\",JSObjectLiteral [JSPropertyNameandValue (JSIdentifier \"a\") [JSDecimal \"1\"],JSLiteral \",\"]],JSLiteral \";\",JSExpression [JSIdentifier \"y\",JSOperator JSLiteral \"=\",JSArrayLiteral [JSIdentifier \"d\",JSElision JSLiteral \",\",JSIdentifier \"e\",JSLiteral \",\"]],JSLiteral \";\",JSLiteral \"\"])"
@=? showStrippedMaybe (parseProgram srcTrailingCommas)
caseMinTrailingCommas =
testMinify "x={a:1,};y=[d,e,]" srcTrailingCommas

srcGetSet = "x={get foo() {return 1},set foo(a) {x=a}}"
caseGetSet =
"Right (JSSourceElementsTop [JSExpression [JSIdentifier \"x\",JSOperator JSLiteral \"=\",JSObjectLiteral [JSPropertyAccessor NT (JSLiteral \"get\") (TokenPn 3 1 4) [NoComment] (JSIdentifier \"foo\") [] (JSBlock ([JSReturn [JSExpression [JSDecimal \"1\"]] JSLiteral \"\"])),JSLiteral \",\",JSPropertyAccessor NT (JSLiteral \"set\") (TokenPn 24 1 25) [NoComment] (JSIdentifier \"foo\") [JSIdentifier \"a\"] (JSBlock ([JSExpression [JSIdentifier \"x\",JSOperator JSLiteral \"=\",JSIdentifier \"a\"]]))]],JSLiteral \"\"])"
@=? showStrippedMaybe (parseProgram srcGetSet)
caseMinGetSet =
testMinify "x={get foo(){return 1},set foo(a){x=a}}" srcGetSet

srcUnicode = "var x = \"שלום\";"
caseUnicode =
"Right (JSSourceElementsTop [JSVariables JSLiteral \"var\" [JSVarDecl (JSIdentifier \"x\") [JSLiteral \"=\",JSStringLiteral '\"' \"\\1513\\1500\\1493\\1501\"]],JSLiteral \"\"])"
@=? showStrippedMaybe (parseProgram srcUnicode)
caseMinUnicode =
testMinify "var x=\"שלום\"" srcUnicode

srcIssue3 = "var myLatlng = new google.maps.LatLng(56.8379100, 60.5806664);"
caseIssue3 =
"Right (JSSourceElementsTop [JSVariables JSLiteral \"var\" [JSVarDecl (JSIdentifier \"myLatlng\") [JSLiteral \"=\",JSLiteral \"new\",JSMemberDot [JSMemberDot [JSIdentifier \"google\"] (JSIdentifier \"maps\")] (JSIdentifier \"LatLng\"),JSArguments [JSDecimal \"56.8379100\",JSLiteral \",\",JSDecimal \"60.5806664\"]]],JSLiteral \"\"])"
@=? showStrippedMaybe (parseProgram srcIssue3)
caseMinIssue3 =
testMinify "var myLatlng=new google.maps.LatLng(56.8379100,60.5806664)" srcIssue3

srcIssue4 = "/* * geolocation. пытаемся определить свое местоположение * если не получается то используем defaultLocation * @Param {object} map экземпляр карты * @Param {object LatLng} defaultLocation Координаты центра по умолчанию * @Param {function} callbackAfterLocation Фу-ия которая вызывается после * геолокации. Т.к запрос геолокации асинхронен */x"
caseIssue4 =
"Right (JSSourceElementsTop [JSExpression [JSIdentifier \"x\"],JSLiteral \"\"])"
@=? showStrippedMaybe (parseProgram srcIssue4)
caseMinIssue4 =
testMinify "x" srcIssue4

srcSwitch1 = "switch(i){case 1:1;case 2:2}"
caseSwitch1 =
"Right (JSSourceElementsTop [JSSwitch (JSExpression [JSIdentifier \"i\"]) JSBlock ([JSCase (JSExpression [JSDecimal \"1\"]) ([JSExpression [JSDecimal \"1\"],JSLiteral \";\"]),JSCase (JSExpression [JSDecimal \"2\"]) ([JSExpression [JSDecimal \"2\"]])]),JSLiteral \"\"])"
@=? showStrippedMaybe (parseProgram srcSwitch1)
caseMinSwitch1 =
testMinify "switch(i){case 1:1;case 2:2}" srcSwitch1

srcIf1="if(i>0)consts+=\", \";var t=tokens[i];"
caseIf1 =
"Right (JSSourceElementsTop [JSIf (JSExpression [JSExpressionBinary \">\" [JSIdentifier \"i\"] [JSDecimal \"0\"]]) ([JSExpression [JSIdentifier \"consts\",JSOperator JSLiteral \"+=\",JSStringLiteral '\"' \", \"],JSLiteral \";\"]) ([]),JSVariables JSLiteral \"var\" [JSVarDecl (JSIdentifier \"t\") [JSLiteral \"=\",JSMemberSquare [JSIdentifier \"tokens\"] (JSExpression [JSIdentifier \"i\"])]],JSLiteral \"\"])"
@=? showStrippedMaybe (parseProgram srcIf1)
caseMinIf1 =
testMinify "if(i>0)consts+=\", \";var t=tokens[i]" srcIf1

srcIf2 = "if (getValue)\n execute;\nelse {\n execute;\n}"
caseIf2 =
"Right (JSSourceElementsTop [JSIf (JSExpression [JSIdentifier \"getValue\"]) ([JSExpression [JSIdentifier \"execute\"],JSLiteral \";\"]) ([JSLiteral \"else\",JSBlock ([JSExpression [JSIdentifier \"execute\"],JSLiteral \";\"])]),JSLiteral \"\"])"
@=? showStrippedMaybe (parseProgram srcIf2)
caseMinIf2 =
testMinify "if(getValue){execute}else execute" srcIf2

srcIf3 = "if(getValue){execute}else execute"
caseIf3 =
"Right (JSSourceElementsTop [JSIf (JSExpression [JSIdentifier \"getValue\"]) ([JSExpression [JSIdentifier \"execute\"],JSLiteral \";\"]) ([JSLiteral \"else\",JSBlock ([JSExpression [JSIdentifier \"execute\"],JSLiteral \";\"])]),JSLiteral \"\"])"
@=? showStrippedMaybe (parseProgram srcIf2)
caseMinIf3 =
testMinify "if(getValue){execute}else execute" srcIf3

srcBootstrapDropdown = "clearMenus()\n!isActive && $parent.toggleClass('open')"
caseBootstrapDropdown =
"Right (JSSourceElementsTop [JSExpression [JSIdentifier \"clearMenus\",JSArguments []],JSExpression [JSExpressionBinary \"&&\" [JSUnary \"!\",JSIdentifier \"isActive\"] [JSMemberDot [JSIdentifier \"$parent\"] (JSIdentifier \"toggleClass\"),JSArguments [JSStringLiteral '\\'' \"open\"]]],JSLiteral \"\"])"
@=? showStrippedMaybe (parseProgram srcBootstrapDropdown)
caseMinBootstrapDropdown =
testMinify "clearMenus();!isActive&&$parent.toggleClass('open')" srcBootstrapDropdown


srcIssue8 = "(function(){new nicEditor({fullPanel:true}).panelInstance('h4')})();"
caseIssue8 =
"Right (JSSourceElementsTop [JSExpression [JSExpressionParen (JSExpression [JSFunctionExpression [] [] (JSBlock ([JSExpression [JSMemberDot [JSLiteral \"new\",JSIdentifier \"nicEditor\",JSArguments [JSObjectLiteral [JSPropertyNameandValue (JSIdentifier \"fullPanel\") [JSLiteral \"true\"]]]] (JSIdentifier \"panelInstance\"),JSArguments [JSStringLiteral '\\'' \"h4\"]]]))]),JSArguments []],JSLiteral \";\",JSLiteral \"\"])"
@=? showStrippedMaybe (parseProgram srcIssue8)
caseMinIssue8 =
testMinify "(function(){new nicEditor({fullPanel:true}).panelInstance('h4')})()" srcIssue8

srcIssue9 = "var x = [new friend(5)];"

caseIssue9 =
"Right (JSSourceElementsTop [JSVariables JSLiteral \"var\" [JSVarDecl (JSIdentifier \"x\") [JSLiteral \"=\",JSArrayLiteral [JSLiteral \"new\",JSIdentifier \"friend\",JSArguments [JSDecimal \"5\"]]]],JSLiteral \"\"])"
@=? showStrippedMaybe (parseProgram srcIssue9)

caseMinIssue9 =
testMinify "var x=[new friend(5)]" srcIssue9


srcIssue14 = "var settings = {start : new Date(2012, 01, 27)};"

caseIssue14 =
"Right (JSSourceElementsTop [JSVariables JSLiteral \"var\" [JSVarDecl (JSIdentifier \"settings\") [JSLiteral \"=\",JSObjectLiteral [JSPropertyNameandValue (JSIdentifier \"start\") [JSLiteral \"new\",JSIdentifier \"Date\",JSArguments [JSDecimal \"2012\",JSLiteral \",\",JSOctal \"01\",JSLiteral \",\",JSDecimal \"27\"]]]]],JSLiteral \"\"])"
@=? showStrippedMaybe (parseProgram srcIssue14)

caseMinIssue14 =
testMinify "var settings={start:new Date(2012,01,27)}" srcIssue14



testMinify expected src = LB.fromChunks [E.encodeUtf8 (T.pack expected)] @=? minify (LB.fromChunks [E.encodeUtf8 (T.pack src)])

testFile :: FilePath -> IO ()
testFile filename = do
x <- readFile filename
let x' = trim x
testMinify x' x'


testFileUnminified :: FilePath -> IO ()
testFileUnminified filename = do
x <- readFile ("./test/pminified/" ++ filename)
y <- readFile ("./test/parsingonly/" ++ filename)
let x' = trim x
testMinify x' y


trim :: String -> String
trim =
let f = reverse . dropWhile isSpace
in f . f

parseProgram src = parse src "src"

+ 0
- 125
vendor/hjsmin/test/inherit.html View File

@@ -1,125 +0,0 @@
<script language=javascript>
/* Copyright (c) 2006 Charlie Savage
License: BSD:
http://www.opensource.org/licenses/bsd-license.php
As posted on http://cfis.savagexi.com/articles/2006/08/25/new-and-improved-javascript-inheritance
*/
Function.prototype.inherits = function(superConstructor)
{
/* Borrowed from Kevin Lindsey - create a dummy
constructor to create prototypes. This is useful
because it means that we don't have to modify
the real constructors to have if-statements to
guard against initialization if we are creating
a prototype (versus a regular instance).*/
function CreatePrototype() {}
CreatePrototype.prototype = superConstructor.prototype
/* Reset the current constructor. This is an ugly hack required
by the JavaScript prototype-chain implementation. */
this.prototype = new CreatePrototype()
this.prototype.constructor = this
// Save a reference to the superClass constructor
this.superConstructor = superConstructor
this.prototype.callSuper = function()
{
/* In IE and Firefox we can get the caller argument via
arguments.callee.caller. However, for some reason this
has been deprecated in JavaScript and is not supported
by Safari or Opera. So we have to pass it in as
a parameter. Yuck.*/
var caller = arguments.callee.caller
var caller = arguments[0]
var args = new Array()
for (var i=1; i<arguments.length; i++)
args.push(arguments[i])
/* Figure out where we are in the inheritance hierarchy and
the name of the method that was invoked. */
var currentConstructor = this.constructor
var methodName = null
while (methodName == null && currentConstructor != null)
{
// Shortcut - Is a constructor being called?
if (caller === currentConstructor)
return currentConstructor.superConstructor.apply(this, args)
methodName = figureMethodName(currentConstructor.prototype, caller)
currentConstructor = currentConstructor.superConstructor
}
if (!methodName)
throw new Error("Could not find method: " + methodName + ".")
if (!currentConstructor)
throw new Error("Prototype does not have an ancestor: "
+ currentConstructor + ".")
// Finally - execute the method
return currentConstructor.prototype[methodName].apply(this, args)
}
}
function figureMethodName(prototype, method)
{
for (var key in prototype)
{
if (prototype.hasOwnProperty(key) &&
prototype[key] === method)
return key
}
return null
}
// ----- Example ---
// -- Animal --
function Animal(name)
{
if (!name)
throw new Error('Must specify an animal name')
this.name = name
}
Animal.prototype.toString = function()
{
return 'My name is ' + this.name
}
// -- Pet --
function Pet(owner, name)
{
this.owner = owner
this.callSuper(arguments.callee, name)
}
Pet.inherits(Animal)
Pet.prototype.toString = function()
{
return this.callSuper(arguments.callee) + "\n" +
"My owner is " + this.owner
}
// -- Cat --
function Cat(owner, name)
{
this.callSuper(arguments.callee, owner, name)
}
Cat.inherits(Pet)
Cat.prototype.toString = function()
{
return this.callSuper(arguments.callee) + '\n' +
'I eat mice'
}
var cat = new Cat('charlie', 'oba')
alert("me " + cat.toString() ); //.toString())
</script>

+ 0
- 62
vendor/hjsmin/test/jsminplus/changelog.txt View File

@@ -1,62 +0,0 @@
================================================================================
JSMin+
================================================================================
A javascript minification tool written in PHP
by Tweakers.net / Tino Zijdel <crisp@tweakers.net>
Weblog: http://crisp.tweakblogs.net/blog/cat/716
License: MPL 1.1/GPL 2.0/LGPL 2.1 (see sourcecode)
================================================================================
VERSION HISTORY
================================================================================
17-05-2009 - version 1.3
- Fixed loop-constructs and if with empty body
- Fixed hook:colon precedence issues (https://bugzilla.mozilla.org/show_bug.cgi?id=492445)
- Combine concats of strings with same quotestyle
- Combine var-statements
--------------------------------------------------------------------------------
18-04-2009 - version 1.2
- Fixed crash in PHP 5.2.9 when matching large comments or strings
(due to PCRE backtracking bug)
- Don't add curly braces around statements for a CASE label
- Always put statements for IF between curly braces when followed by an ELSE
- Save some more bytes by omitting the space between RETURN and the return
expression in certain cases
--------------------------------------------------------------------------------
12-04-2009 - version 1.1
- Improved tokenizer performance by reading smaller chunks for matching
- Bugfix: jumplabels for break/continue statements were not written to output
- Improved stringmatching: cases like '\' and '<newline>' now throw unterminated
string literal error
- Fixed linenumber offset bug caused by JScript conditional compilation blocks
- nest() always calls Statement() so no need to use call_user_func() with a parm
--------------------------------------------------------------------------------
09-04-2009 - version 1.0
Initial version
================================================================================
KNOWN ISSUES
================================================================================
- JScript conditional compilation support is incomplete
================================================================================
DOWNLOAD LOCATION
================================================================================
Latest version:
version 1.3 : http://files.tweakers.net/jsminplus/jsminplus.zip
Previous versions:
version 1.2 : http://files.tweakers.net/jsminplus/jsminplus-1.2.zip
version 1.1 : http://files.tweakers.net/jsminplus/jsminplus-1.1.zip
version 1.0 : http://files.tweakers.net/jsminplus/jsminplus-1.0.zip

+ 0
- 1980
vendor/hjsmin/test/jsminplus/jsminplus.php
File diff suppressed because it is too large
View File


+ 0
- 48
vendor/hjsmin/test/jsminplus/run.php View File

@@ -1,48 +0,0 @@
#!/usr/bin/php -q
<?php

include "jsminplus.php";

//$minified = JSMinPlus::minify($script [, $filename])

//$script="{x=1;y=1;}";
/*
$script = <<<EOD

// -- Animal --
function Animal(name)
{
if (!name)
throw new Error('Must specify an animal name')
this.name = name
}

Animal.prototype.toString = function()
{
return this.name
}

o = new Animal("bob")

o.toString() == "bob";

EOD;
*/
/*
echo "Test Arguments:\n";
echo $_SERVER["argc"]."\n";
echo $_SERVER["argv"][0]."\n";
echo $_SERVER["argv"][1]."\n";
*/

//$filename = '../0_helloworld.js';
$filename = $_SERVER["argv"][1];

$script = file_get_contents($filename);

//echo $script

echo (JSMinPlus::minify($script, "foo"));
echo "\n";

?>

+ 0
- 1
vendor/hjsmin/test/minified/0_helloworld.js View File

@@ -1 +0,0 @@
print("Hello world")

+ 0
- 1
vendor/hjsmin/test/minified/100_animals.js View File

@@ -1 +0,0 @@
function Animal(name){if(!name)throw new Error('Must specify an animal name');this.name=name};Animal.prototype.toString=function(){return this.name};o=new Animal("bob");o.toString()=="bob"

+ 0
- 5
vendor/hjsmin/test/minified/101_inheritance.js View File

@@ -1,5 +0,0 @@
Function.prototype.inherits=function(superConstructor){function CreatePrototype(){};CreatePrototype.prototype=superConstructor.prototype;this.prototype=new CreatePrototype();this.prototype.constructor=this;this.superConstructor=superConstructor;this.prototype.callSuper=function(){var caller=arguments.callee.caller,args=new Array();for(var i=1;i<arguments.length;i++)args.push(arguments[i]);var currentConstructor=this.constructor,methodName=null;while(methodName==null&&currentConstructor!=null){if(caller===currentConstructor)return currentConstructor.superConstructor.apply(this,args);methodName=figureMethodName(currentConstructor.prototype,caller);currentConstructor=currentConstructor.superConstructor};if(!methodName)throw new Error("Could not find method: "+methodName+".");if(!currentConstructor)throw new Error("Prototype does not have an ancestor: "+currentConstructor+".");return currentConstructor.prototype[methodName].apply(this,args)}}
function figureMethodName(prototype,method){for(var key in prototype)if(prototype.hasOwnProperty(key)&&prototype[key]===method)return key;return null}
function Animal(name){if(!name)throw new Error('Must specify an animal name');this.name=name};Animal.prototype.toString=function(){return'My name is '+this.name}
function Pet(owner,name){this.owner=owner;this.callSuper(arguments.callee,name)};Pet.inherits(Animal);Pet.prototype.toString=function(){return this.callSuper(arguments.callee)+"\nMy owner is "+this.owner}
function Cat(owner,name){this.callSuper(arguments.callee,owner,name)};Cat.inherits(Pet);Cat.prototype.toString=function(){return this.callSuper(arguments.callee)+'\nI eat mice'};p=new Pet("bob","fido");t1=p.owner=="bob"&&p.name=="fido";var cat=new Cat('charlie','oba');t2=cat.owner=="charlie"&&cat.name=="oba";print(cat.toString());t1&&t2

+ 0
- 1
vendor/hjsmin/test/minified/101a_in.js View File

@@ -1 +0,0 @@
a=1;b=2;a==1&&b==2

+ 0
- 1
vendor/hjsmin/test/minified/10_expressions.js View File

@@ -1 +0,0 @@
{i=10;i++;if(i){x=i++}else x=20;do{x++;i=i-1}while(i);if(!zz){zz=99}else x=1};i==0&&zz==99

+ 0
- 1
vendor/hjsmin/test/minified/11_funcs_factorial.js View File

@@ -1 +0,0 @@
function fac(y){if(y){return(fac(y-1)*y)}else return 1};fac(3)==6

+ 0
- 1
vendor/hjsmin/test/minified/12_array.js View File

@@ -1 +0,0 @@
bob=[1,2,"fred"];for(i=0;i<bob.length;i++)bob[i]=i*2;t1=bob[0]==0&&bob[2]==4&&bob.length==3;bob=new Array(1,2,3);bob[0]++;bob.push(4,5);t2=bob[0]==bob[1]&&bob[2]==3&&bob[3]==4&&bob[4]==5;t1&&t2

+ 0
- 1
vendor/hjsmin/test/minified/12_funcs_ackermann.js View File

@@ -1 +0,0 @@
function acker(m,n){if(m==0)return n+1;if(n==0)return acker(m-1,1);return acker(m-1,acker(m,n-1))};acker(3,2)==29

+ 0
- 1
vendor/hjsmin/test/minified/12_iter.js View File

@@ -1 +0,0 @@
i=1;do{i++;if(i==2)continue;i++;if(i==4)break}while(i<10);for(var j=0;j<4;j++)i++;print(i," ",j);o=new Object();o.prop1=1;o.prop2=2;for(var key in o){v=o[key];if(typeof v=="number")i+=v};i==11

+ 0
- 1
vendor/hjsmin/test/minified/13_cast.js View File

@@ -1 +0,0 @@
bob=new Array();fred=[];bob==12;bob!=null;s1=1+" one";s2="one "+3;s=new String("a string");s3=s+" more "

+ 0
- 1
vendor/hjsmin/test/minified/14_new.js View File

@@ -1 +0,0 @@
function Animal(){this.name="an animal"};o1=new Object();o1.name="bob";o2=new Animal();o2.name=="an animal";o1.name=="bob"&&o2.name=="an animal"

+ 0
- 1
vendor/hjsmin/test/minified/15_tostring.js View File

@@ -1 +0,0 @@
function Pet(){};Pet.prototype.toString=function(){return"[pet]"};s=new String("a string");o=new Object();p=new Pet();x=s.toString();y=o.toString();z=p.toString();x=="a string"&&y=="[object]"&&z=="[pet]"

+ 0
- 1
vendor/hjsmin/test/minified/16_funcs.js View File

@@ -1 +0,0 @@
function makeFactorialFunc(){return function(x){if(x<=1)return 1;return x*arguments.callee(x-1)}};var result=makeFactorialFunc()(5);result==120

+ 0
- 3
vendor/hjsmin/test/minified/16_literals.js View File

@@ -1,3 +0,0 @@
const GLOBAL=this;var tokens=["END","\n",";"],opTypeNames={'\n':"NEWLINE",';':"SEMICOLON",',':"COMMA"},assignOps=['|','^','&','<<','>>','>>>','+','-','*','/','%']
function eval(s){a=-1};var global={NaN:NaN,Infinity:Infinity,undefined:undefined,snarf:snarf,evaluate:evaluate,load:function load(s){if(typeof s!="string")return s;evaluate(snarf(s),s,1)},print:print,version:null}
function eval(s){};opTypeNames[";"]=="SEMICOLON"

+ 0
- 2
vendor/hjsmin/test/minified/17_funcs_caller.js View File

@@ -1,2 +0,0 @@
function myFunc(){if(myFunc.caller==null){return("The function was called from the top!")}else return("This function's caller was "+myFunc.caller.name)}
function otherFunc(){return myFunc()};x=myFunc();y=otherFunc();x=="The function was called from the top!"&&y=="This function's caller was otherFunc"

+ 0
- 2
vendor/hjsmin/test/minified/18_funcs_apply.js View File

@@ -1,2 +0,0 @@
function product(name,value){this.name=name;if(value>1000){this.value=999}else this.value=value}
function prod_dept(name,value,dept){this.dept=dept;product.apply(this,arguments)};prod_dept.prototype=new product();cheese=new prod_dept("feta",5,"food");car=new prod_dept("honda",5000,"auto");cheese.value==5&&car.value==999

+ 0
- 1
vendor/hjsmin/test/minified/19_func_body.js View File

@@ -1 +0,0 @@
function HSFun(name,arity,body){this._n=name;this._r=(arity==0);this._x=arity;this._d=this;this._y=0;this._u=null;this._b=body};f=new HSFun("myfunc",1,function(){return 99});f._b.apply()==99

+ 0
- 1
vendor/hjsmin/test/minified/21_print.js View File

@@ -1 +0,0 @@
print("Line 1");print("Line 2")

+ 0
- 1
vendor/hjsmin/test/minified/23_switch.js View File

@@ -1 +0,0 @@
x=2;switch(x){case 1:i=1;break;case 2:i=2;case 3:i=3};i==3

+ 0
- 1
vendor/hjsmin/test/minified/24_switch.js View File

@@ -1 +0,0 @@
function select(fruit){switch(fruit){case"Oranges":s="Oranges are $0.59 a pound.<br>";break;case"Apples":s="Apples are $0.32 a pound.<br>";break;case"Bananas":s="Bananas are $0.48 a pound.<br>";break;case"Cherries":s="Cherries are $3.00 a pound.<br>";break;case"Mangoes":case"Papayas":return"Mangoes and papayas are $2.79 a pound.<br>";break;default:s="Sorry, we are out of "+fruit};return s};t1=select("Oranges")=="Oranges are $0.59 a pound.<br>";t2=select("Nuts")=="Sorry, we are out of Nuts";t3=select("Mangoes")=="Mangoes and papayas are $2.79 a pound.<br>";t1&&t2&&t3

+ 0
- 1
vendor/hjsmin/test/minified/25_regex.js View File

@@ -1 +0,0 @@
function verifyZipCode(zip){pattern=/[0-9]{5}([- ]?[0-9]{4})?/;return pattern.test(zip)};a=verifyZipCode(95060);b=verifyZipCode(9560);c=verifyZipCode("a");d=verifyZipCode("95060");e=verifyZipCode("95060 1234");a&&!b&&!c&&d&&e

+ 0
- 1
vendor/hjsmin/test/minified/26_regex.js View File

@@ -1 +0,0 @@
function verifyZipCode(zip){zip=new String(zip);pattern=/[0-9]{5}([- ]?[0-9]{4})?/;if(pattern.test(zip)){return zip.match(pattern)[0]}else return""};a=verifyZipCode(95060)

+ 0
- 2
vendor/hjsmin/test/minified/34_throw.js View File

@@ -1,2 +0,0 @@
function UserException(message){this.message=message;this.name="UserException"}
function getMonthName(mo){mo=mo-1;var months=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");if(months[mo]!=null){return months[mo]}else{myUserException=new UserException("InvalidMonthNo");throw myUserException}};try{monthName=getMonthName(14)}catch(e){monthName="unknown";x=e.name};monthName=="unknown"&&x=="UserException"

+ 0
- 2
vendor/hjsmin/test/minified/35_throw.js View File

@@ -1,2 +0,0 @@
function bob(n){try{throw n}catch(e){if(e<=50){return true}else throw (e)}}
function fred(n){try{return bob(n)}catch(e){return false}};bob(11)&&!fred(1234)

+ 0
- 3
vendor/hjsmin/test/minified/36_throw.js View File

@@ -1,3 +0,0 @@
function ZipCode(zip){zip=new String(zip);pattern=/[0-9]{5}([- ]?[0-9]{4})?/;if(pattern.test(zip)){this.value=zip.match(pattern)[0];this.valueOf=function(){return this.value};this.toString=function(){return String(this.value)}}else throw new ZipCodeFormatException(zip)}
function ZipCodeFormatException(value){this.value=value;this.message="does not conform to the expected format for a zip code";this.toString=function(){return this.value+this.message}};var ZIPCODE_INVALID=-1,ZIPCODE_UNKNOWN_ERROR=-2
function verifyZipCode(z){try{z=new ZipCode(z)}catch(e){if(e instanceof ZipCodeFormatException){return ZIPCODE_INVALID}else return ZIPCODE_UNKNOWN_ERROR};return z};a=verifyZipCode(95060);b=verifyZipCode(9560);c=verifyZipCode("a");d=verifyZipCode("95060");e=verifyZipCode("95060 1234")

+ 0
- 1
vendor/hjsmin/test/minified/56_arguments.js View File

@@ -1 +0,0 @@
function bob(){total=0;for(i=0;i<arguments.length;i++)total+=arguments[i];return total};x=bob(1,2,3,4,5,6);print("x= ",x);x==21

+ 0
- 2
vendor/hjsmin/test/minified/5_object.js View File

@@ -1,2 +0,0 @@
o=new Object();o.prop1=1;o.prop2=2;o.prop3=66
function bob(){o.prop3=3;return 1;o.prop3=6};y=bob();x=o.propertyNames();f=o.hasOwnProperty("prop1")&&!o.hasOwnProperty("fred");o.prop1+o.prop2+o.prop3==6&&f

+ 0
- 2
vendor/hjsmin/test/minified/67_method.js View File

@@ -1,2 +0,0 @@
function figureMethodName(prototype,method){for(var key in prototype)if(prototype.hasOwnProperty(key)&&prototype[key]===method)return key;return null}
function Pet(){this.name="cat"}

+ 0
- 1
vendor/hjsmin/test/minified/6_this.js View File

@@ -1 +0,0 @@
o=new Object();o.othername="fred";o.f=function doit(n){this.name=this.othername};o.f("bob");o.name=="fred"

+ 0
- 1
vendor/hjsmin/test/minified/79_throw.js View File

@@ -1 +0,0 @@
myerror1="";try{throw "Simple throw"}catch(er){myerror1=er};myerror2="";try{throw new Error("Throw in an error object")}catch(er){myerror2=er.message};myerror1=="Simple throw"&&myerror2=="Throw in an error object"

+ 0
- 1
vendor/hjsmin/test/minified/90_class.js View File

@@ -1 +0,0 @@
function Animal(){this.name="unknown"};Animal.prototype.toString=function(){"an Animal"};Animal.prototype.toString()=="an Animal"

+ 0
- 2
vendor/hjsmin/test/minified/97_funcproto.js