-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | JavaScript analysis tools
--
-- WebBits is a collection of libraries for working with JavaScript
-- embeded in HTML files. Highlights include:
--
--
-- - WebBits.JavaScript.Crawl returns all JavaScript in an
-- HTML page, including JavaScript from imported script files
-- (<script src=...>).
-- - WebBits.JavaScript.Environment annotates JavaScript
-- syntax with its static environment and returns a list of free
-- identifiers.
-- - WebBits.JavaScript.Parser is a JavaScript parser that is
-- largely based on JavaScript 1.5.
-- - WebBits.Html.Parser is a permissive HTML parser.
--
@package WebBits
@version 0.11.0
module WebBits.JavaScript.Lexer
lexeme :: CharParser st a -> CharParser st a
identifier :: CharParser st String
reserved :: String -> CharParser st ()
operator :: CharParser st String
reservedOp :: String -> CharParser st ()
charLiteral :: CharParser st Char
stringLiteral :: CharParser st String
natural :: CharParser st Integer
integer :: CharParser st Integer
float :: CharParser st Double
naturalOrFloat :: CharParser st (Either Integer Double)
decimal :: CharParser st Integer
hexadecimal :: CharParser st Integer
octal :: CharParser st Integer
symbol :: String -> CharParser st String
whiteSpace :: CharParser st ()
parens :: CharParser st a -> CharParser st a
braces :: CharParser st a -> CharParser st a
brackets :: CharParser st a -> CharParser st a
squares :: CharParser st a -> CharParser st a
semi :: CharParser st String
comma :: CharParser st String
colon :: CharParser st String
dot :: CharParser st String
identifierStart :: GenParser Char st Char
-- | JavaScript's syntax.
module WebBits.JavaScript.Syntax
data Expression a
StringLit :: a -> String -> Expression a
RegexpLit :: a -> String -> Bool -> Bool -> Expression a
NumLit :: a -> Double -> Expression a
BoolLit :: a -> Bool -> Expression a
NullLit :: a -> Expression a
ArrayLit :: a -> [Expression a] -> Expression a
ObjectLit :: a -> [(Prop a, Expression a)] -> Expression a
ThisRef :: a -> Expression a
VarRef :: a -> (Id a) -> Expression a
DotRef :: a -> (Expression a) -> (Id a) -> Expression a
BracketRef :: a -> (Expression a) -> (Expression a) -> Expression a
NewExpr :: a -> (Expression a) -> [Expression a] -> Expression a
PostfixExpr :: a -> PostfixOp -> (Expression a) -> Expression a
PrefixExpr :: a -> PrefixOp -> (Expression a) -> Expression a
InfixExpr :: a -> InfixOp -> (Expression a) -> (Expression a) -> Expression a
CondExpr :: a -> (Expression a) -> (Expression a) -> (Expression a) -> Expression a
AssignExpr :: a -> AssignOp -> (Expression a) -> (Expression a) -> Expression a
ParenExpr :: a -> (Expression a) -> Expression a
ListExpr :: a -> [Expression a] -> Expression a
CallExpr :: a -> (Expression a) -> [Expression a] -> Expression a
FuncExpr :: a -> [(Id a)] -> (Statement a) -> Expression a
data CaseClause a
CaseClause :: a -> (Expression a) -> [Statement a] -> CaseClause a
CaseDefault :: a -> [Statement a] -> CaseClause a
data Statement a
BlockStmt :: a -> [Statement a] -> Statement a
EmptyStmt :: a -> Statement a
ExprStmt :: a -> (Expression a) -> Statement a
IfStmt :: a -> (Expression a) -> (Statement a) -> (Statement a) -> Statement a
IfSingleStmt :: a -> (Expression a) -> (Statement a) -> Statement a
SwitchStmt :: a -> (Expression a) -> [CaseClause a] -> Statement a
WhileStmt :: a -> (Expression a) -> (Statement a) -> Statement a
DoWhileStmt :: a -> (Statement a) -> (Expression a) -> Statement a
BreakStmt :: a -> (Maybe (Id a)) -> Statement a
ContinueStmt :: a -> (Maybe (Id a)) -> Statement a
LabelledStmt :: a -> (Id a) -> (Statement a) -> Statement a
ForInStmt :: a -> (ForInInit a) -> (Expression a) -> (Statement a) -> Statement a
ForStmt :: a -> (ForInit a) -> (Maybe (Expression a)) -> (Maybe (Expression a)) -> (Statement a) -> Statement a
TryStmt :: a -> (Statement a) -> [CatchClause a] -> (Maybe (Statement a)) -> Statement a
ThrowStmt :: a -> (Expression a) -> Statement a
ReturnStmt :: a -> (Maybe (Expression a)) -> Statement a
WithStmt :: a -> (Expression a) -> (Statement a) -> Statement a
VarDeclStmt :: a -> [VarDecl a] -> Statement a
FunctionStmt :: a -> (Id a) -> [(Id a)] -> (Statement a) -> Statement a
data InfixOp
OpLT :: InfixOp
OpLEq :: InfixOp
OpGT :: InfixOp
OpGEq :: InfixOp
OpIn :: InfixOp
OpInstanceof :: InfixOp
OpEq :: InfixOp
OpNEq :: InfixOp
OpStrictEq :: InfixOp
OpStrictNEq :: InfixOp
OpLAnd :: InfixOp
OpLOr :: InfixOp
OpMul :: InfixOp
OpDiv :: InfixOp
OpMod :: InfixOp
OpSub :: InfixOp
OpLShift :: InfixOp
OpSpRShift :: InfixOp
OpZfRShift :: InfixOp
OpBAnd :: InfixOp
OpBXor :: InfixOp
OpBOr :: InfixOp
OpAdd :: InfixOp
data CatchClause a
CatchClause :: a -> (Id a) -> (Statement a) -> CatchClause a
data VarDecl a
VarDecl :: a -> (Id a) -> (Maybe (Expression a)) -> VarDecl a
data JavaScript a
-- | A script in script ... /script tags. This may seem a
-- little silly, but the Flapjax analogue has an inline variant and
-- attribute-inline variant.
Script :: a -> [Statement a] -> JavaScript a
data AssignOp
OpAssign :: AssignOp
OpAssignAdd :: AssignOp
OpAssignSub :: AssignOp
OpAssignMul :: AssignOp
OpAssignDiv :: AssignOp
OpAssignMod :: AssignOp
OpAssignLShift :: AssignOp
OpAssignSpRShift :: AssignOp
OpAssignZfRShift :: AssignOp
OpAssignBAnd :: AssignOp
OpAssignBXor :: AssignOp
OpAssignBOr :: AssignOp
data Id a
Id :: a -> String -> Id a
data PrefixOp
PrefixInc :: PrefixOp
PrefixDec :: PrefixOp
PrefixLNot :: PrefixOp
PrefixBNot :: PrefixOp
PrefixPlus :: PrefixOp
PrefixMinus :: PrefixOp
PrefixTypeof :: PrefixOp
PrefixVoid :: PrefixOp
PrefixDelete :: PrefixOp
data PostfixOp
PostfixInc :: PostfixOp
PostfixDec :: PostfixOp
data Prop a
PropId :: a -> (Id a) -> Prop a
PropString :: a -> String -> Prop a
PropNum :: a -> Integer -> Prop a
data ForInit a
NoInit :: ForInit a
VarInit :: [VarDecl a] -> ForInit a
ExprInit :: (Expression a) -> ForInit a
data ForInInit a
ForInVar :: (Id a) -> ForInInit a
ForInNoVar :: (Id a) -> ForInInit a
instance Typeable1 Statement
instance Typeable1 ForInInit
instance Typeable1 ForInit
instance Typeable1 VarDecl
instance Typeable1 CatchClause
instance Typeable1 CaseClause
instance Typeable1 Expression
instance Typeable1 Prop
instance Typeable PostfixOp
instance Typeable PrefixOp
instance Typeable AssignOp
instance Typeable InfixOp
instance Typeable1 Id
instance Typeable1 JavaScript
instance (Show a) => Show (Statement a)
instance (Data a) => Data (Statement a)
instance (Eq a) => Eq (Statement a)
instance (Ord a) => Ord (Statement a)
instance (Show a) => Show (ForInInit a)
instance (Data a) => Data (ForInInit a)
instance (Eq a) => Eq (ForInInit a)
instance (Ord a) => Ord (ForInInit a)
instance (Show a) => Show (ForInit a)
instance (Data a) => Data (ForInit a)
instance (Eq a) => Eq (ForInit a)
instance (Ord a) => Ord (ForInit a)
instance (Show a) => Show (VarDecl a)
instance (Data a) => Data (VarDecl a)
instance (Eq a) => Eq (VarDecl a)
instance (Ord a) => Ord (VarDecl a)
instance (Show a) => Show (CatchClause a)
instance (Data a) => Data (CatchClause a)
instance (Eq a) => Eq (CatchClause a)
instance (Ord a) => Ord (CatchClause a)
instance (Show a) => Show (CaseClause a)
instance (Data a) => Data (CaseClause a)
instance (Eq a) => Eq (CaseClause a)
instance (Ord a) => Ord (CaseClause a)
instance (Show a) => Show (Expression a)
instance (Data a) => Data (Expression a)
instance (Eq a) => Eq (Expression a)
instance (Ord a) => Ord (Expression a)
instance (Show a) => Show (Prop a)
instance (Data a) => Data (Prop a)
instance (Eq a) => Eq (Prop a)
instance (Ord a) => Ord (Prop a)
instance Show PostfixOp
instance Data PostfixOp
instance Eq PostfixOp
instance Ord PostfixOp
instance Show PrefixOp
instance Data PrefixOp
instance Eq PrefixOp
instance Ord PrefixOp
instance Show AssignOp
instance Data AssignOp
instance Eq AssignOp
instance Ord AssignOp
instance Show InfixOp
instance Data InfixOp
instance Eq InfixOp
instance Ord InfixOp
instance Enum InfixOp
instance (Show a) => Show (Id a)
instance (Eq a) => Eq (Id a)
instance (Ord a) => Ord (Id a)
instance (Data a) => Data (Id a)
instance (Show a) => Show (JavaScript a)
instance (Data a) => Data (JavaScript a)
instance (Eq a) => Eq (JavaScript a)
instance (Ord a) => Ord (JavaScript a)
-- | Instances of Foldable and Traversable for JavaScript's
-- syntax.
module WebBits.JavaScript.Instances
instance Traversable Statement
instance Traversable ForInInit
instance Traversable ForInit
instance Traversable VarDecl
instance Traversable CatchClause
instance Traversable CaseClause
instance Traversable Expression
instance Traversable Prop
instance Traversable Id
instance Foldable Statement
instance Foldable ForInInit
instance Foldable ForInit
instance Foldable VarDecl
instance Foldable CatchClause
instance Foldable CaseClause
instance Foldable Expression
instance Foldable Prop
instance Foldable Id
instance Functor Statement
instance Functor ForInInit
instance Functor ForInit
instance Functor VarDecl
instance Functor CatchClause
instance Functor CaseClause
instance Functor Expression
instance Functor Prop
instance Functor JavaScript
instance Functor Id
module WebBits.JavaScript.Parser
parseScript :: CharParser state (JavaScript SourcePos)
parseExpression :: ExpressionParser st
parseString :: String -> [Statement SourcePos]
parseScriptFromString :: String -> String -> Either ParseError (JavaScript SourcePos)
emptyParsedJavaScript :: JavaScript a
type ParsedStatement = Statement SourcePos
type ParsedExpression = Expression SourcePos
parseJavaScriptFromFile :: (MonadIO m) => String -> m [Statement SourcePos]
parseSimpleExpr' :: GenParser Char st ParsedExpression
parseBlockStmt :: StatementParser st
parseStatement :: StatementParser st
type StatementParser state = CharParser state ParsedStatement
type ExpressionParser state = CharParser state ParsedExpression
parseAssignExpr :: ExpressionParser st
-- | Defines commonly used datatypes and functions.
module WebBits.Common
-- | PrettyPrintable makes writing pretty-printing code for large,
-- recursive data structures shorter.
class PrettyPrintable a
pp :: (PrettyPrintable a) => a -> Doc
-- | The isPrefixOf function takes two lists and returns True
-- iff the first list is a prefix of the second.
isPrefixOf :: (Eq a) => [a] -> [a] -> Bool
data SourcePos :: *
sourceName :: SourcePos -> SourceName
instance Data SourcePos
instance Typeable SourcePos
instance (PrettyPrintable a) => PrettyPrintable (Maybe a)
module WebBits.JavaScript.Combinators
scriptStatements :: JavaScript a -> [Statement a]
isParenExpr :: Expression t -> Bool
syntaxAt :: (Data a, Typeable a, Data (t SourcePos), Typeable (t SourcePos), Foldable t) => SourcePos -> a -> [t SourcePos]
expressionsAt :: (Data a, Typeable a) => SourcePos -> a -> [Expression SourcePos]
statementsAt :: (Data a, Typeable a) => SourcePos -> a -> [Statement SourcePos]
-- | Pretty-printing JavaScript. This module doesn't export any names, but
-- importing it declares PrettyPrintable instances for JavaScript.Syntax.
module WebBits.JavaScript.PrettyPrint
instance PrettyPrintable (JavaScript a)
instance PrettyPrintable (Expression a)
instance PrettyPrintable AssignOp
instance PrettyPrintable PostfixOp
instance PrettyPrintable PrefixOp
instance PrettyPrintable InfixOp
instance PrettyPrintable (Prop a)
instance PrettyPrintable (Statement a)
instance PrettyPrintable (VarDecl a)
instance PrettyPrintable (CatchClause a)
instance PrettyPrintable (CaseClause a)
instance PrettyPrintable (ForInInit a)
instance PrettyPrintable (ForInit a)
instance PrettyPrintable (Id a)
-- | Datatypes for HTML parameterized over an annotation type and a script
-- type.
module WebBits.Html.Syntax
type HtmlId = String
type AttributeValue = String
data Attribute a s
Attribute :: HtmlId -> AttributeValue -> a -> Attribute a s
AttributeExpr :: a -> HtmlId -> s -> String -> Attribute a s
data Html a sc
Element :: HtmlId -> [Attribute a sc] -> [Html a sc] -> a -> Html a sc
Text :: String -> a -> Html a sc
Comment :: String -> a -> Html a sc
-- | must be a non-empty list
HtmlSeq :: [Html a sc] -> Html a sc
ProcessingInstruction :: String -> a -> Html a sc
InlineScript :: sc -> a -> String -> Html a sc
Script :: sc -> a -> Html a sc
-- | A type t of the Script class can be parsed using
-- Parsec. t is of kind '* -> *', as the parsed AST
-- should be annotated with souce locations (see SourcePos).
--
-- The big deal here is that we can embed a parser for some scripting
-- language, (e.g. Javascript) into this HTML parser with ease, while
-- preserving source locations. The Html datatype is parameterized over a
-- script parser (an instance of Script).
class Script t
parseScriptBlock :: (Script t) => [Attribute SourcePos t] -> CharParser a t
parseInlineScript :: (Script t) => Maybe (CharParser a t)
parseAttributeScript :: (Script t) => Maybe (CharParser a t)
-- | Returns the value of the attribute in the list, or Nothing if
-- it doesn't exist of the value is an inline-expression.
attributeValue :: HtmlId -> [Attribute a s] -> Maybe String
attributeUpdate :: HtmlId -> (String -> String) -> [Attribute a s] -> [Attribute a s]
attributeSet :: HtmlId -> String -> [Attribute a s] -> [Attribute a s]
isAttributeExpr :: Attribute t t1 -> Bool
instance Typeable2 Html
instance Typeable2 Attribute
instance (Show a, Show sc) => Show (Html a sc)
instance (Eq a, Eq sc) => Eq (Html a sc)
instance (Data a, Data sc) => Data (Html a sc)
instance (Show a, Show s) => Show (Attribute a s)
instance (Eq a, Eq s) => Eq (Attribute a s)
instance (Data a, Data s) => Data (Attribute a s)
-- | A structure-recovering parser for malformed documents.
--
-- Copyright 2007-2008 Arjun Guha. Based on HtmlPrag 0.16 Copyright (C)
-- 2003 - 2005 Neil W. Van Dyke.
--
-- This program is Free Software; you can redistribute it and/or modify
-- it under the terms of the GNU Lesser General Public License as
-- published by the Free Software Foundation; either version 2.1 of the
-- License, or (at your option) any later version. This program is
-- distributed in the hope that it will be useful, but without any
-- warranty; without even the implied warranty of merchantability or
-- fitness for a particular purpose. See
-- http://www.gnu.org/copyleft/lesser.html for details. For other
-- license options and consulting, contact the author.
module WebBits.Html.PermissiveParser
html :: (Script s) => CharParser [Warning] (Html SourcePos s)
parseHtmlFromFile :: (Script s) => String -> IO (Either ParseError (Html SourcePos s, [Warning]))
parseHtmlFromString :: (Script s) => String -> String -> Either ParseError (Html SourcePos s, [Warning])
tokens :: (Script s) => CharParser [Warning] [Token s]
data (Script s) => Token s
instance (Script s) => Show (Token s)
instance Show Warning
-- | Pretty-printer for HTML. This modules exports no names. It only
-- defines instances of PrettyPrintable for HTML.
module WebBits.Html.PrettyPrint
instance (PrettyPrintable s) => PrettyPrintable (Html a s)
instance (PrettyPrintable s) => PrettyPrintable (Attribute a s)
module WebBits.Html.Instances
instance Traversable (Html a)
instance Traversable (Attribute a)
instance Foldable (Html a)
instance Foldable (Attribute a)
instance Functor (Html a)
instance Functor (Attribute a)
module WebBits.JavaScript.HtmlEmbedding
type JsHtml a = Html SourcePos (JavaScript a)
type ParsedJavaScript = JavaScript SourcePos
type ParsedJsHtml = JsHtml SourcePos
instance Script ParsedJavaScript
-- | Re-exports commonly used modules.
module WebBits.JavaScript.JavaScript
-- | Crawls an HTML page for JavaScript
module WebBits.JavaScript.Crawl
getPageJavaScript :: ParsedJsHtml -> IO [ParsedStatement]
-- | Rexports various modules of the HTML library. It's best to use this in
-- lieu of selectively importing the following libraries.
module WebBits.Html.Html
html :: (Script s) => CharParser [Warning] (Html SourcePos s)
parseHtmlFromFile :: (Script s) => String -> IO (Either ParseError (Html SourcePos s, [Warning]))
parseHtmlFromString :: (Script s) => String -> String -> Either ParseError (Html SourcePos s, [Warning])
module WebBits.Html.RawScript
data RawScript
RawScript :: String -> RawScript
parseFromFile :: Parser a -> SourceName -> IO (Either ParseError a)
parseFromString :: String -> RawHtml
type RawHtml = Html SourcePos RawScript
instance Typeable RawScript
instance Show RawScript
instance Eq RawScript
instance Data RawScript
instance PrettyPrintable RawScript
instance Script RawScript
-- | A zipper for Data.Tree.
module WebBits.Data.Zipper
-- | Multi-way trees, also known as rose trees.
data Tree a :: * -> *
Node :: a -> Forest a -> Tree a
-- | label value
rootLabel :: Tree a -> a
-- | zero or more child trees
subForest :: Tree a -> Forest a
data Location a
toLocation :: Tree a -> Location a
fromLocation :: Location a -> Tree a
dfsFold :: (w -> v -> w) -> w -> Tree v -> Tree w
-- | Similar to dfsFold, but the transformation is done in the monad
-- m. The sequence of operations is depth-first, left-to-right.
dfsFoldM :: (Monad m) => (w -> v -> m w) -> w -> Tree v -> m (Tree w)
showTree :: (Show a) => Tree a -> String
empty :: a -> Tree a
up :: Location a -> Location a
down :: Location a -> Location a
left :: Location a -> Location a
right :: Location a -> Location a
replace :: Location a -> Tree a -> Location a
change :: Location a -> a -> Location a
insertDown :: Location a -> Tree a -> Location a
insertLeft :: Location a -> Tree a -> Location a
insertRight :: Location a -> Tree a -> Location a
isTop :: Location a -> Bool
isChild :: Location a -> Bool
getValue :: Location a -> a
subTree :: Location a -> Tree a
-- | Traverses to the top of the tree.
--
--
-- up.top = undefined
-- top.top = top
--
top :: Location a -> Location a
canGoLeft :: Location a -> Bool
canGoRight :: Location a -> Bool
canGoUp :: Location a -> Bool
canGoDown :: Location a -> Bool
type ZipperT v m a = StateT (Location v) m a
-- | Creates a new node as the right-most child of the current node.
nest :: (Monad m) => v -> ZipperT v m a -> ZipperT v m a
getNode :: (Monad m) => ZipperT v m v
setNode :: (Monad m) => v -> ZipperT v m ()
runZipperT :: (Monad m) => ZipperT v m a -> Location v -> m (a, Tree v)
evalZipperT :: (Monad m) => ZipperT v m a -> Location v -> m a
execZipperT :: (Monad m) => ZipperT v m a -> Location v -> m (Tree v)
shiftLeft :: (Monad m) => ZipperT v m ()
shiftRight :: (Monad m) => ZipperT v m ()
-- | Silently fails to shift left if there is no left-child.
shiftLeft' :: (Monad m) => ZipperT v m ()
-- | Silently fails to shift right if there is no right-child.
shiftRight' :: (Monad m) => ZipperT v m ()
withCurrentChild :: (Monad m) => ZipperT v m a -> ZipperT v m a
module WebBits.JavaScript.Environment
-- | Annotates each expression with its static environment. In addition, a
-- map of free identifiers is returned, along with the next valid label.
staticEnvironment :: [Statement SourcePos] -> ([Statement Ann], Env, Env, Int)
type Ann = (Env, Int, SourcePos)
type LabelledStatement = Statement Ann
type LabelledExpression = Expression Ann
type Env = Map String Int
-- | Re-exports commonly used modules.
module WebBits.JavaScript