module BrownPLT.JavaScript.Syntax(Expression(..),CaseClause(..),Statement(..),
InfixOp(..),CatchClause(..),VarDecl(..),JavaScript(..),
AssignOp(..),Id(..),PrefixOp(..),PostfixOp(..),Prop(..),
ForInit(..),ForInInit(..),unId) where
import Text.ParserCombinators.Parsec(SourcePos)
import Data.Generics(Data,Typeable)
data JavaScript a
= Script a [Statement a]
deriving (Show,Data,Typeable,Eq,Ord)
data Id a = Id a String deriving (Show,Eq,Ord,Data,Typeable)
unId :: Id a -> String
unId (Id _ s) = s
data InfixOp = OpLT | OpLEq | OpGT | OpGEq | OpIn | OpInstanceof | OpEq | OpNEq
| OpStrictEq | OpStrictNEq | OpLAnd | OpLOr
| OpMul | OpDiv | OpMod | OpSub | OpLShift | OpSpRShift
| OpZfRShift | OpBAnd | OpBXor | OpBOr | OpAdd
deriving (Show,Data,Typeable,Eq,Ord,Enum)
data AssignOp = OpAssign | OpAssignAdd | OpAssignSub | OpAssignMul | OpAssignDiv
| OpAssignMod | OpAssignLShift | OpAssignSpRShift | OpAssignZfRShift
| OpAssignBAnd | OpAssignBXor | OpAssignBOr
deriving (Show,Data,Typeable,Eq,Ord)
data PrefixOp = PrefixInc | PrefixDec | PrefixLNot | PrefixBNot | PrefixPlus
| PrefixMinus | PrefixTypeof | PrefixVoid | PrefixDelete
deriving (Show,Data,Typeable,Eq,Ord)
data PostfixOp
= PostfixInc | PostfixDec
deriving (Show,Data,Typeable,Eq,Ord)
data Prop a
= PropId a (Id a) | PropString a String | PropNum a Integer
deriving (Show,Data,Typeable,Eq,Ord)
data Expression a
= StringLit a String
| RegexpLit a String Bool Bool
| NumLit a Double
| IntLit a Int
| BoolLit a Bool
| NullLit a
| ArrayLit a [Expression a]
| ObjectLit a [(Prop a, Expression a)]
| ThisRef a
| VarRef a (Id a)
| DotRef a (Expression a) (Id a)
| BracketRef a (Expression a) (Expression a)
| NewExpr a (Expression a) [Expression a]
| PostfixExpr a PostfixOp (Expression a)
| PrefixExpr a PrefixOp (Expression a)
| InfixExpr a InfixOp (Expression a) (Expression a)
| CondExpr a (Expression a) (Expression a) (Expression a)
| AssignExpr a AssignOp (Expression a) (Expression a)
| ParenExpr a (Expression a)
| ListExpr a [Expression a]
| CallExpr a (Expression a) [Expression a]
| FuncExpr a [(Id a)] (Statement a)
deriving (Show,Data,Typeable,Eq,Ord)
data CaseClause a
= CaseClause a (Expression a) [Statement a]
| CaseDefault a [Statement a]
deriving (Show,Data,Typeable,Eq,Ord)
data CatchClause a
= CatchClause a (Id a) (Statement a)
deriving (Show,Data,Typeable,Eq,Ord)
data VarDecl a
= VarDecl a (Id a) (Maybe (Expression a))
deriving (Show,Data,Typeable,Eq,Ord)
data ForInit a
= NoInit
| VarInit [VarDecl a]
| ExprInit (Expression a)
deriving (Show,Data,Typeable,Eq,Ord)
data ForInInit a
= ForInVar (Id a)
| ForInNoVar (Id a)
deriving (Show,Data,Typeable,Eq,Ord)
data Statement a
= BlockStmt a [Statement a]
| EmptyStmt a
| ExprStmt a (Expression a)
| IfStmt a (Expression a) (Statement a) (Statement a)
| IfSingleStmt a (Expression a) (Statement a)
| SwitchStmt a (Expression a) [CaseClause a]
| WhileStmt a (Expression a) (Statement a)
| DoWhileStmt a (Statement a) (Expression a)
| BreakStmt a (Maybe (Id a))
| ContinueStmt a (Maybe (Id a))
| LabelledStmt a (Id a) (Statement a)
| ForInStmt a (ForInInit a) (Expression a) (Statement a)
| ForStmt a (ForInit a)
(Maybe (Expression a))
(Maybe (Expression a))
(Statement a)
| TryStmt a (Statement a) [CatchClause a]
(Maybe (Statement a))
| ThrowStmt a (Expression a)
| ReturnStmt a (Maybe (Expression a))
| WithStmt a (Expression a) (Statement a)
| VarDeclStmt a [VarDecl a]
| FunctionStmt a (Id a) [(Id a)] (Statement a)
deriving (Show,Data,Typeable,Eq,Ord)