diff options
author | ArjunGuha <> | 2013-05-24 11:18:44 (GMT) |
---|---|---|
committer | hdiff <hdiff@hdiff.luite.com> | 2013-05-24 11:18:44 (GMT) |
commit | bf8a839d0b3c8dc4ab77bc37c8edecf9ed4a4651 (patch) | |
tree | 3ea294295e794861488bb949f600bdd6e741935d | |
parent | 720ebc4cb5e3bbeec357ed43a968ba9c84ddad09 (diff) |
version 0.130.13
-rw-r--r-- | language-ecmascript.cabal | 4 | ||||
-rw-r--r-- | src/Language/ECMAScript3/PrettyPrint.hs | 39 |
2 files changed, 40 insertions, 3 deletions
diff --git a/language-ecmascript.cabal b/language-ecmascript.cabal index 82c89ef..b0814b5 100644 --- a/language-ecmascript.cabal +++ b/language-ecmascript.cabal @@ -1,5 +1,5 @@ Name: language-ecmascript -Version: 0.12 +Version: 0.13 Cabal-Version: >= 1.10 Copyright: (c) 2007-2012 Brown University, (c) 2008-2010 Claudiu Saftoiu, (c) 2012-2013 Stevens Institute of Technology @@ -30,7 +30,7 @@ Source-repository head Source-repository this type: git location: git://github.com/jswebtools/language-ecmascript.git - tag: 0.12 + tag: 0.13 Library Hs-Source-Dirs: diff --git a/src/Language/ECMAScript3/PrettyPrint.hs b/src/Language/ECMAScript3/PrettyPrint.hs index be82b6b..7b74dd7 100644 --- a/src/Language/ECMAScript3/PrettyPrint.hs +++ b/src/Language/ECMAScript3/PrettyPrint.hs @@ -1,15 +1,52 @@ --- |Pretty-printing JavaScript. +{-# LANGUAGE FlexibleInstances #-} + +-- | Pretty-printing JavaScript. module Language.ECMAScript3.PrettyPrint ( javaScript , renderStatements , renderExpression + , PP (..) ) where import Text.PrettyPrint.HughesPJ import Language.ECMAScript3.Syntax import Prelude hiding (maybe) +------------------------------------------------------------------------------ + +class PP a where + pp :: a -> Doc + +instance PP [Statement a] where + pp = stmtList + +instance PP (Expression a) where + pp = ppExpression True + +instance PP (Statement a) where + pp = ppStatement + +instance PP (ForInit a) where + pp = forInit + +instance PP (LValue a) where + pp = ppLValue + +instance PP InfixOp where + pp = infixOp + +instance PP AssignOp where + pp = assignOp + +instance PP PrefixOp where + pp = prefixOp + + +---------------------------------------------------------------------------- + + + -- | Renders a list of statements as a 'String' renderStatements :: [Statement a] -> String renderStatements = render . stmtList |