purescript-0.4.5: src/Language/PureScript/CodeGen/JS/AST.hs
-----------------------------------------------------------------------------
--
-- Module : Language.PureScript.CodeGen.JS.AST
-- Copyright : (c) Phil Freeman 2013
-- License : MIT
--
-- Maintainer : Phil Freeman <paf31@cantab.net>
-- Stability : experimental
-- Portability :
--
-- |
-- Data types for the intermediate simplified-Javascript AST
--
-----------------------------------------------------------------------------
{-# LANGUAGE DeriveDataTypeable #-}
module Language.PureScript.CodeGen.JS.AST where
import Data.Data
-- |
-- Built-in unary operators
--
data UnaryOperator
-- |
-- Numeric negation
--
= Negate
-- |
-- Boolean negation
--
| Not
-- |
-- Bitwise negation
--
| BitwiseNot
-- |
-- Numeric unary \'plus\'
--
| Positive deriving (Show, Eq, Data, Typeable)
-- |
-- Built-in binary operators
--
data BinaryOperator
-- |
-- Numeric addition
--
= Add
-- |
-- Numeric subtraction
--
| Subtract
-- |
-- Numeric multiplication
--
| Multiply
-- |
-- Numeric division
--
| Divide
-- |
-- Remainder
--
| Modulus
-- |
-- Generic equality test
--
| EqualTo
-- |
-- Generic inequality test
--
| NotEqualTo
-- |
-- Numeric less-than
--
| LessThan
-- |
-- Numeric less-than-or-equal
--
| LessThanOrEqualTo
-- |
-- Numeric greater-than
--
| GreaterThan
-- |
-- Numeric greater-than-or-equal
--
| GreaterThanOrEqualTo
-- |
-- Boolean and
--
| And
-- |
-- Boolean or
--
| Or
-- |
-- Bitwise and
--
| BitwiseAnd
-- |
-- Bitwise or
--
| BitwiseOr
-- |
-- Bitwise xor
--
| BitwiseXor
-- |
-- Bitwise left shift
--
| ShiftLeft
-- |
-- Bitwise right shift
--
| ShiftRight
-- |
-- Bitwise right shift with zero-fill
--
| ZeroFillShiftRight deriving (Show, Eq, Data, Typeable)
-- |
-- Data type for simplified Javascript expressions
--
data JS
-- |
-- A numeric literal
--
= JSNumericLiteral (Either Integer Double)
-- |
-- A string literal
--
| JSStringLiteral String
-- |
-- A boolean literal
--
| JSBooleanLiteral Bool
-- |
-- A unary operator application
--
| JSUnary UnaryOperator JS
-- |
-- A binary operator application
--
| JSBinary BinaryOperator JS JS
-- |
-- An array literal
--
| JSArrayLiteral [JS]
-- |
-- An array indexer expression
--
| JSIndexer JS JS
-- |
-- An object literal
--
| JSObjectLiteral [(String, JS)]
-- |
-- An object property accessor expression
--
| JSAccessor String JS
-- |
-- A function introduction (optional name, arguments, body)
--
| JSFunction (Maybe String) [String] JS
-- |
-- Function application
--
| JSApp JS [JS]
-- |
-- Variable
--
| JSVar String
-- |
-- Conditional expression
--
| JSConditional JS JS JS
-- |
-- A block of expressions in braces
--
| JSBlock [JS]
-- |
-- A variable introduction and optional initialization
--
| JSVariableIntroduction String (Maybe JS)
-- |
-- A variable assignment
--
| JSAssignment JS JS
-- |
-- While loop
--
| JSWhile JS JS
-- |
-- For loop
--
| JSFor String JS JS JS
-- |
-- ForIn loop
--
| JSForIn String JS JS
-- |
-- If-then-else statement
--
| JSIfElse JS JS (Maybe JS)
-- |
-- Return statement
--
| JSReturn JS
-- |
-- Throw statement
--
| JSThrow JS
-- |
-- Type-Of operator
--
| JSTypeOf JS
-- |
-- Labelled statement
--
| JSLabel String JS
-- |
-- Break statement
--
| JSBreak String
-- |
-- Continue statement
--
| JSContinue String
-- |
-- Raw Javascript (generated when parsing fails for an inline foreign import declaration)
--
| JSRaw String deriving (Show, Eq, Data, Typeable)