WebBits 2.0 → 2.2
raw patch · 7 files changed
Files
- LICENSE +1/−1
- WebBits.cabal +19/−11
- src/BrownPLT/JavaScript/Environment.hs +2/−2
- src/BrownPLT/JavaScript/Lexer.hs +1/−0
- src/BrownPLT/JavaScript/Parser.hs +44/−19
- src/BrownPLT/JavaScript/PrettyPrint.hs +6/−4
- src/BrownPLT/JavaScript/Syntax.hs +1/−1
LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2009, Arjun Guha, Claudiu Saftoiu, and Spiridon Eliopoulos+Copyright (c) 2007--2011, Brown University and Claudiu Saftoiu All Rights Reserved. Redistribution and use in source and binary forms, with or without
WebBits.cabal view
@@ -1,20 +1,28 @@ Name: WebBits-Version: 2.0-Cabal-Version: >= 1.2.3-Copyright: Copyright (c) 2007-2009 Arjun Guha, Claudiu Saftoiu, - and Spiridon Eliopoulos+Version: 2.2+Cabal-Version: >= 1.6+Copyright: Copyright (c) 2007-2011 Brown University, Claudiu Saftoiu, Arjun Guha, Spiridon Eliopoulos, Copyright (c) 2012 Arjun Guha and Andrey Chudnov License: BSD3 License-file: LICENSE-Author: Arjun Guha, Claudiu Saftoiu, and Spiridon Eliopoulos-Maintainer: Arjun Guha <arjun@cs.brown.edu>-Homepage: http://www.cs.brown.edu/research/plt/+Author: Arjun Guha, Claudiu Saftoiu, Spiridon Eliopoulos and Andrey Chudnov+Maintainer: Andrey Chudnov <oss@chudnov.com>+Homepage: http://github.com/brownplt/webbits+Bug-reports: http://github.com/brownplt/webbits/issues Stability: provisional+Tested-with: GHC==7.0.4, GHC==7.4.1 Category: Language Build-Type: Custom Synopsis: JavaScript analysis tools-Description:+Description: WebBits is a collection of libraries for working with JavaScript, contains a parser, a pretty-printer and a lexical environment analyser. The original author of the package is the PLT group of Brown University (http:\/\/www.cs.brown.edu\/research\/plt\/). Changes since version 2.1: the syntax of the try-catch-finally statement has been changed in accordance to the ECMAScript specification -- now it only has at most one catch clause. The original test-suite needs updating to support the current test system: patches are welcome. - WebBits is a collection of libraries for working with JavaScript.+Source-repository head+ type: git+ location: git://github.com/brownplt/webbits.git++Source-repository this+ type: git+ location: git://github.com/brownplt/webbits.git+ tag: WebBits-2.2 Library Hs-Source-Dirs:@@ -22,14 +30,14 @@ Build-Depends: base >= 4 && < 5, mtl >= 1.1.0.1,- parsec < 3.0.0,+ parsec < 3.2.0, pretty >= 0.1, containers >= 0.1, syb >= 0.1 ghc-options: -fwarn-incomplete-patterns Extensions: - Generics DeriveDataTypeable+ DeriveDataTypeable Exposed-Modules: BrownPLT.JavaScript BrownPLT.JavaScript.Lexer
src/BrownPLT/JavaScript/Environment.hs view
@@ -114,8 +114,8 @@ ForInStmt _ fii e s -> unions [forInInit fii, expr e, stmt s] ForStmt _ fi me1 me2 s -> unions [forInit fi, maybe empty expr me1, maybe empty expr me2, stmt s]- TryStmt _ s catches ms ->- unions [stmt s, unions $ map catchClause catches, maybe empty stmt ms]+ TryStmt _ s catch ms ->+ unions [stmt s, maybe empty catchClause catch, maybe empty stmt ms] ThrowStmt _ e -> expr e ReturnStmt _ me -> maybe empty expr me WithStmt _ e s -> unions [expr e, stmt s]
src/BrownPLT/JavaScript/Lexer.hs view
@@ -34,6 +34,7 @@ "[", "]", "{", "}", "(", ")","</","instanceof"] True -- case-sensitive +lex :: T.TokenParser st lex = T.makeTokenParser javascriptDef -- everything but commaSep and semiSep
src/BrownPLT/JavaScript/Parser.hs view
@@ -35,6 +35,7 @@ type StatementParser state = CharParser state ParsedStatement type ExpressionParser state = CharParser state ParsedExpression +identifier :: CharParser st (Id SourcePos) identifier = liftM2 Id getPosition Lexer.identifier @@ -197,10 +198,10 @@ in do reserved "try" pos <- getPosition guarded <- parseStatement- catches <- many parseCatchClause+ catch <- optionMaybe parseCatchClause finally <- (reserved "finally" >> liftM Just parseStatement) <|> (return Nothing)- return (TryStmt pos guarded catches finally)+ return (TryStmt pos guarded catch finally) parseThrowStmt:: StatementParser st parseThrowStmt = do@@ -376,8 +377,10 @@ let parseFlags = do flags <- many (oneOf "mgi") return $ \f -> f ('g' `elem` flags) ('i' `elem` flags) - let parseEscape = char '\\' >> anyChar- let parseChar = noneOf "/"+ let parseEscape :: CharParser st Char+ parseEscape = char '\\' >> anyChar+ let parseChar :: CharParser st Char+ parseChar = noneOf "/" let parseRe = (char '/' >> return "") <|> (do char '\\' ch <- anyChar -- TOOD: too lenient@@ -542,22 +545,44 @@ exprTable:: [[Operator Char st ParsedExpression]] exprTable = - [- [makeInfixExpr "*" OpMul, makeInfixExpr "/" OpDiv, makeInfixExpr "%" OpMod],- [makeInfixExpr "+" OpAdd, makeInfixExpr "-" OpSub],- [makeInfixExpr "<<" OpLShift, makeInfixExpr ">>" OpSpRShift,- makeInfixExpr ">>>" OpZfRShift],- [makeInfixExpr "<" OpLT, makeInfixExpr "<=" OpLEq, makeInfixExpr ">" OpGT,- makeInfixExpr ">=" OpGEq, - makeInfixExpr "instanceof" OpInstanceof, makeInfixExpr "in" OpIn],- [makeInfixExpr "&" OpBAnd], - [makeInfixExpr "^" OpBXor], - [makeInfixExpr "|" OpBOr],- [makeInfixExpr "&&" OpLAnd],- [makeInfixExpr "||" OpLOr], - [makeInfixExpr "==" OpEq, makeInfixExpr "!=" OpNEq,- makeInfixExpr "===" OpStrictEq, makeInfixExpr "!==" OpStrictNEq]+ [ [ makeInfixExpr "==" OpEq+ , makeInfixExpr "!=" OpNEq+ , makeInfixExpr "===" OpStrictEq+ , makeInfixExpr "!==" OpStrictNEq ]++ , [ makeInfixExpr "||" OpLOr ]++ , [ makeInfixExpr "&&" OpLAnd ]+ + , [ makeInfixExpr "|" OpBOr ]++ , [ makeInfixExpr "^" OpBXor ]++ , [ makeInfixExpr "&" OpBAnd ]++ , [ makeInfixExpr "<" OpLT+ , makeInfixExpr "<=" OpLEq+ , makeInfixExpr ">" OpGT+ , makeInfixExpr ">=" OpGEq+ , makeInfixExpr "instanceof" OpInstanceof+ , makeInfixExpr "in" OpIn+ ]++ , [ makeInfixExpr "<<" OpLShift+ , makeInfixExpr ">>" OpSpRShift+ , makeInfixExpr ">>>" OpZfRShift+ ]++ , [ makeInfixExpr "+" OpAdd+ , makeInfixExpr "-" OpSub+ ]++ , [ makeInfixExpr "*" OpMul+ , makeInfixExpr "/" OpDiv+ , makeInfixExpr "%" OpMod+ ]+ ] parseExpression' = buildExpressionParser exprTable parsePrefixedExpr <?> "simple expression"
src/BrownPLT/JavaScript/PrettyPrint.hs view
@@ -57,8 +57,10 @@ text "default:" $$ (nest 2 (semiSep ss)) -catchClause :: CatchClause a -> Doc-catchClause (CatchClause _ id s) = text "catch" <+> (parens.pp) id <+> inBlock s+catchClause :: Maybe (CatchClause a) -> Doc+catchClause Nothing = empty+catchClause (Just (CatchClause _ id s)) = + text "catch" <+> (parens.pp) id <+> inBlock s varDecl :: VarDecl a -> Doc@@ -93,8 +95,8 @@ text "for" <+> parens (forInit init <> semi <+> mexpr incr <> semi <+> mexpr test) $$ stmt body- TryStmt _ stmt catches finally ->- text "try" $$ inBlock stmt $$ (vcat (map catchClause catches)) $$+ TryStmt _ stmt catch finally ->+ text "try" $$ inBlock stmt $$ catchClause catch $$ ppFinally where ppFinally = case finally of Nothing -> empty
src/BrownPLT/JavaScript/Syntax.hs view
@@ -121,7 +121,7 @@ (Maybe (Expression a)) -- test (Maybe (Expression a)) -- increment (Statement a) -- body- | TryStmt a (Statement a) {-body-} [CatchClause a] {-catches-}+ | TryStmt a (Statement a) {-body-} (Maybe (CatchClause a)) (Maybe (Statement a)) {-finally-} | ThrowStmt a (Expression a) | ReturnStmt a (Maybe (Expression a))