Language.JavaScript.Parser.AST

language-javascript-0.6.0.3: Parser for JavaScript

Safe Haskell | Safe
Language | Haskell98

Language.JavaScript.Parser.AST

Synopsis

- data JSExpression
  - = JSIdentifier !JSAnnot !String
  - | JSDecimal !JSAnnot !String
  - | JSLiteral !JSAnnot !String
  - | JSHexInteger !JSAnnot !String
  - | JSOctal !JSAnnot !String
  - | JSStringLiteral !JSAnnot !String
  - | JSRegEx !JSAnnot !String
  - | JSArrayLiteral !JSAnnot ![JSArrayElement] !JSAnnot
  - | JSAssignExpression !JSExpression !JSAssignOp !JSExpression
  - | JSCallExpression !JSExpression !JSAnnot !(JSCommaList JSExpression) !JSAnnot
  - | JSCallExpressionDot !JSExpression !JSAnnot !JSExpression
  - | JSCallExpressionSquare !JSExpression !JSAnnot !JSExpression !JSAnnot
  - | JSCommaExpression !JSExpression !JSAnnot !JSExpression
  - | JSExpressionBinary !JSExpression !JSBinOp !JSExpression
  - | JSExpressionParen !JSAnnot !JSExpression !JSAnnot
  - | JSExpressionPostfix !JSExpression !JSUnaryOp
  - | JSExpressionTernary !JSExpression !JSAnnot !JSExpression !JSAnnot !JSExpression
  - | JSFunctionExpression !JSAnnot !JSIdent !JSAnnot !(JSCommaList JSIdent) !JSAnnot !JSBlock
  - | JSMemberDot !JSExpression !JSAnnot !JSExpression
  - | JSMemberExpression !JSExpression !JSAnnot !(JSCommaList JSExpression) !JSAnnot
  - | JSMemberNew !JSAnnot !JSExpression !JSAnnot !(JSCommaList JSExpression) !JSAnnot
  - | JSMemberSquare !JSExpression !JSAnnot !JSExpression !JSAnnot
  - | JSNewExpression !JSAnnot !JSExpression
  - | JSObjectLiteral !JSAnnot !JSObjectPropertyList !JSAnnot
  - | JSUnaryExpression !JSUnaryOp !JSExpression
  - | JSVarInitExpression !JSExpression !JSVarInitializer
- data JSAnnot
  - = JSAnnot !TokenPosn ![CommentAnnotation]
  - | JSNoAnnot
- data JSBinOp
  - = JSBinOpAnd !JSAnnot
  - | JSBinOpBitAnd !JSAnnot
  - | JSBinOpBitOr !JSAnnot
  - | JSBinOpBitXor !JSAnnot
  - | JSBinOpDivide !JSAnnot
  - | JSBinOpEq !JSAnnot
  - | JSBinOpGe !JSAnnot
  - | JSBinOpGt !JSAnnot
  - | JSBinOpIn !JSAnnot
  - | JSBinOpInstanceOf !JSAnnot
  - | JSBinOpLe !JSAnnot
  - | JSBinOpLsh !JSAnnot
  - | JSBinOpLt !JSAnnot
  - | JSBinOpMinus !JSAnnot
  - | JSBinOpMod !JSAnnot
  - | JSBinOpNeq !JSAnnot
  - | JSBinOpOr !JSAnnot
  - | JSBinOpPlus !JSAnnot
  - | JSBinOpRsh !JSAnnot
  - | JSBinOpStrictEq !JSAnnot
  - | JSBinOpStrictNeq !JSAnnot
  - | JSBinOpTimes !JSAnnot
  - | JSBinOpUrsh !JSAnnot
- data JSUnaryOp
  - = JSUnaryOpDecr !JSAnnot
  - | JSUnaryOpDelete !JSAnnot
  - | JSUnaryOpIncr !JSAnnot
  - | JSUnaryOpMinus !JSAnnot
  - | JSUnaryOpNot !JSAnnot
  - | JSUnaryOpPlus !JSAnnot
  - | JSUnaryOpTilde !JSAnnot
  - | JSUnaryOpTypeof !JSAnnot
  - | JSUnaryOpVoid !JSAnnot
- data JSSemi
  - = JSSemi !JSAnnot
  - | JSSemiAuto
- data JSAssignOp
  - = JSAssign !JSAnnot
  - | JSTimesAssign !JSAnnot
  - | JSDivideAssign !JSAnnot
  - | JSModAssign !JSAnnot
  - | JSPlusAssign !JSAnnot
  - | JSMinusAssign !JSAnnot
  - | JSLshAssign !JSAnnot
  - | JSRshAssign !JSAnnot
  - | JSUrshAssign !JSAnnot
  - | JSBwAndAssign !JSAnnot
  - | JSBwXorAssign !JSAnnot
  - | JSBwOrAssign !JSAnnot
- data JSTryCatch
  - = JSCatch !JSAnnot !JSAnnot !JSExpression !JSAnnot !JSBlock
  - | JSCatchIf !JSAnnot !JSAnnot !JSExpression !JSAnnot !JSExpression !JSAnnot !JSBlock
- data JSTryFinally
  - = JSFinally !JSAnnot !JSBlock
  - | JSNoFinally
- data JSStatement
  - = JSStatementBlock !JSAnnot ![JSStatement] !JSAnnot !JSSemi
  - | JSBreak !JSAnnot !JSIdent !JSSemi
  - | JSConstant !JSAnnot !(JSCommaList JSExpression) !JSSemi
  - | JSContinue !JSAnnot !JSIdent !JSSemi
  - | JSDoWhile !JSAnnot !JSStatement !JSAnnot !JSAnnot !JSExpression !JSAnnot !JSSemi
  - | JSFor !JSAnnot !JSAnnot !(JSCommaList JSExpression) !JSAnnot !(JSCommaList JSExpression) !JSAnnot !(JSCommaList JSExpression) !JSAnnot !JSStatement
  - | JSForIn !JSAnnot !JSAnnot !JSExpression !JSBinOp !JSExpression !JSAnnot !JSStatement
  - | JSForVar !JSAnnot !JSAnnot !JSAnnot !(JSCommaList JSExpression) !JSAnnot !(JSCommaList JSExpression) !JSAnnot !(JSCommaList JSExpression) !JSAnnot !JSStatement
  - | JSForVarIn !JSAnnot !JSAnnot !JSAnnot !JSExpression !JSBinOp !JSExpression !JSAnnot !JSStatement
  - | JSFunction !JSAnnot !JSIdent !JSAnnot !(JSCommaList JSIdent) !JSAnnot !JSBlock !JSSemi
  - | JSIf !JSAnnot !JSAnnot !JSExpression !JSAnnot !JSStatement
  - | JSIfElse !JSAnnot !JSAnnot !JSExpression !JSAnnot !JSStatement !JSAnnot !JSStatement
  - | JSLabelled !JSIdent !JSAnnot !JSStatement
  - | JSEmptyStatement !JSAnnot
  - | JSExpressionStatement !JSExpression !JSSemi
  - | JSAssignStatement !JSExpression !JSAssignOp !JSExpression !JSSemi
  - | JSMethodCall !JSExpression !JSAnnot !(JSCommaList JSExpression) !JSAnnot !JSSemi
  - | JSReturn !JSAnnot !(Maybe JSExpression) !JSSemi
  - | JSSwitch !JSAnnot !JSAnnot !JSExpression !JSAnnot !JSAnnot ![JSSwitchParts] !JSAnnot !JSSemi
  - | JSThrow !JSAnnot !JSExpression !JSSemi
  - | JSTry !JSAnnot !JSBlock ![JSTryCatch] !JSTryFinally
  - | JSVariable !JSAnnot !(JSCommaList JSExpression) !JSSemi
  - | JSWhile !JSAnnot !JSAnnot !JSExpression !JSAnnot !JSStatement
  - | JSWith !JSAnnot !JSAnnot !JSExpression !JSAnnot !JSStatement !JSSemi
- data JSBlock = JSBlock !JSAnnot ![JSStatement] !JSAnnot
- data JSSwitchParts
  - = JSCase !JSAnnot !JSExpression !JSAnnot ![JSStatement]
  - | JSDefault !JSAnnot !JSAnnot ![JSStatement]
- data JSAST
  - = JSAstProgram ![JSStatement] !JSAnnot
  - | JSAstStatement !JSStatement !JSAnnot
  - | JSAstExpression !JSExpression !JSAnnot
  - | JSAstLiteral !JSExpression !JSAnnot
- data JSObjectProperty
  - = JSPropertyAccessor !JSAccessor !JSPropertyName !JSAnnot ![JSExpression] !JSAnnot !JSBlock
  - | JSPropertyNameandValue !JSPropertyName !JSAnnot ![JSExpression]
- data JSPropertyName
  - = JSPropertyIdent !JSAnnot !String
  - | JSPropertyString !JSAnnot !String
  - | JSPropertyNumber !JSAnnot !String
- type JSObjectPropertyList = JSCommaTrailingList JSObjectProperty
- data JSAccessor
  - = JSAccessorGet !JSAnnot
  - | JSAccessorSet !JSAnnot
- data JSIdent
  - = JSIdentName !JSAnnot !String
  - | JSIdentNone
- data JSVarInitializer
  - = JSVarInit !JSAnnot !JSExpression
  - | JSVarInitNone
- data JSArrayElement
  - = JSArrayElement !JSExpression
  - | JSArrayComma !JSAnnot
- data JSCommaList a
  - = JSLCons !(JSCommaList a) !JSAnnot !a
  - | JSLOne !a
  - | JSLNil
- data JSCommaTrailingList a
  - = JSCTLComma !(JSCommaList a) !JSAnnot
  - | JSCTLNone !(JSCommaList a)
- showStripped :: JSAST -> String

# Documentation

data JSExpression

Constructors

JSIdentifier !JSAnnot !String | Terminals
JSDecimal !JSAnnot !String |
JSLiteral !JSAnnot !String |
JSHexInteger !JSAnnot !String |
JSOctal !JSAnnot !String |
JSStringLiteral !JSAnnot !String |
JSRegEx !JSAnnot !String |
JSArrayLiteral !JSAnnot ![JSArrayElement] !JSAnnot | lb, contents, rb
JSAssignExpression !JSExpression !JSAssignOp !JSExpression | lhs, assignop, rhs
JSCallExpression !JSExpression !JSAnnot !(JSCommaList JSExpression) !JSAnnot | expr, bl, args, rb
JSCallExpressionDot !JSExpression !JSAnnot !JSExpression | expr, dot, expr
JSCallExpressionSquare !JSExpression !JSAnnot !JSExpression !JSAnnot | expr, [, expr, ]
JSCommaExpression !JSExpression !JSAnnot !JSExpression | expression components
JSExpressionBinary !JSExpression !JSBinOp !JSExpression | lhs, op, rhs
JSExpressionParen !JSAnnot !JSExpression !JSAnnot | lb,expression,rb
JSExpressionPostfix !JSExpression !JSUnaryOp | expression, operator
JSExpressionTernary !JSExpression !JSAnnot !JSExpression !JSAnnot !JSExpression | cond, ?, trueval, :, falseval
JSFunctionExpression !JSAnnot !JSIdent !JSAnnot !(JSCommaList JSIdent) !JSAnnot !JSBlock | fn,name,lb, parameter list,rb,block`
JSMemberDot !JSExpression !JSAnnot !JSExpression | firstpart, dot, name
JSMemberExpression !JSExpression !JSAnnot !(JSCommaList JSExpression) !JSAnnot |
JSMemberNew !JSAnnot !JSExpression !JSAnnot !(JSCommaList JSExpression) !JSAnnot | new, name, lb, args, rb
JSMemberSquare !JSExpression !JSAnnot !JSExpression !JSAnnot | firstpart, lb, expr, rb
JSNewExpression !JSAnnot !JSExpression | new, expr
JSObjectLiteral !JSAnnot !JSObjectPropertyList !JSAnnot | lbrace contents rbrace
JSUnaryExpression !JSUnaryOp !JSExpression |
JSVarInitExpression !JSExpression !JSVarInitializer | identifier, initializer

Instances

Eq JSExpression |
Data JSExpression |
Show JSExpression |

data JSAnnot

Constructors

JSAnnot !TokenPosn ![CommentAnnotation] | Annotation: position and comment/whitespace information
JSNoAnnot | No annotation

Instances

Eq JSAnnot |
Data JSAnnot |
Show JSAnnot |

data JSBinOp

Constructors

JSBinOpAnd !JSAnnot |
JSBinOpBitAnd !JSAnnot |
JSBinOpBitOr !JSAnnot |
JSBinOpBitXor !JSAnnot |
JSBinOpDivide !JSAnnot |
JSBinOpEq !JSAnnot |
JSBinOpGe !JSAnnot |
JSBinOpGt !JSAnnot |
JSBinOpIn !JSAnnot |
JSBinOpInstanceOf !JSAnnot |
JSBinOpLe !JSAnnot |
JSBinOpLsh !JSAnnot |
JSBinOpLt !JSAnnot |
JSBinOpMinus !JSAnnot |
JSBinOpMod !JSAnnot |
JSBinOpNeq !JSAnnot |
JSBinOpOr !JSAnnot |
JSBinOpPlus !JSAnnot |
JSBinOpRsh !JSAnnot |
JSBinOpStrictEq !JSAnnot |
JSBinOpStrictNeq !JSAnnot |
JSBinOpTimes !JSAnnot |
JSBinOpUrsh !JSAnnot |

Instances

Eq JSBinOp |
Data JSBinOp |
Show JSBinOp |

data JSUnaryOp

Constructors

JSUnaryOpDecr !JSAnnot |
JSUnaryOpDelete !JSAnnot |
JSUnaryOpIncr !JSAnnot |
JSUnaryOpMinus !JSAnnot |
JSUnaryOpNot !JSAnnot |
JSUnaryOpPlus !JSAnnot |
JSUnaryOpTilde !JSAnnot |
JSUnaryOpTypeof !JSAnnot |
JSUnaryOpVoid !JSAnnot |

Instances

Eq JSUnaryOp |
Data JSUnaryOp |
Show JSUnaryOp |

data JSSemi

Constructors

JSSemi !JSAnnot |
JSSemiAuto |

Instances

Eq JSSemi |
Data JSSemi |
Show JSSemi |

data JSAssignOp

Constructors

JSAssign !JSAnnot |
JSTimesAssign !JSAnnot |
JSDivideAssign !JSAnnot |
JSModAssign !JSAnnot |
JSPlusAssign !JSAnnot |
JSMinusAssign !JSAnnot |
JSLshAssign !JSAnnot |
JSRshAssign !JSAnnot |
JSUrshAssign !JSAnnot |
JSBwAndAssign !JSAnnot |
JSBwXorAssign !JSAnnot |
JSBwOrAssign !JSAnnot |

Instances

Eq JSAssignOp |
Data JSAssignOp |
Show JSAssignOp |

data JSTryCatch

Constructors

JSCatch !JSAnnot !JSAnnot !JSExpression !JSAnnot !JSBlock | catch,lb,ident,rb,block
JSCatchIf !JSAnnot !JSAnnot !JSExpression !JSAnnot !JSExpression !JSAnnot !JSBlock | catch,lb,ident,if,expr,rb,block

Instances

Eq JSTryCatch |
Data JSTryCatch |
Show JSTryCatch |

data JSTryFinally

Constructors

JSFinally !JSAnnot !JSBlock | finally,block
JSNoFinally |

Instances

Eq JSTryFinally |
Data JSTryFinally |
Show JSTryFinally |

data JSStatement

Constructors

JSStatementBlock !JSAnnot ![JSStatement] !JSAnnot !JSSemi | lbrace, stmts, rbrace, autosemi
JSBreak !JSAnnot !JSIdent !JSSemi | break,optional identifier, autosemi
JSConstant !JSAnnot !(JSCommaList JSExpression) !JSSemi | const, decl, autosemi
JSContinue !JSAnnot !JSIdent !JSSemi | continue, optional identifier,autosemi
JSDoWhile !JSAnnot !JSStatement !JSAnnot !JSAnnot !JSExpression !JSAnnot !JSSemi | do,stmt,while,lb,expr,rb,autosemi
JSFor !JSAnnot !JSAnnot !(JSCommaList JSExpression) !JSAnnot !(JSCommaList JSExpression) !JSAnnot !(JSCommaList JSExpression) !JSAnnot !JSStatement | for,lb,expr,semi,expr,semi,expr,rb.stmt
JSForIn !JSAnnot !JSAnnot !JSExpression !JSBinOp !JSExpression !JSAnnot !JSStatement | for,lb,expr,in,expr,rb,stmt
JSForVar !JSAnnot !JSAnnot !JSAnnot !(JSCommaList JSExpression) !JSAnnot !(JSCommaList JSExpression) !JSAnnot !(JSCommaList JSExpression) !JSAnnot !JSStatement | for,lb,var,vardecl,semi,expr,semi,expr,rb,stmt
JSForVarIn !JSAnnot !JSAnnot !JSAnnot !JSExpression !JSBinOp !JSExpression !JSAnnot !JSStatement | for,lb,var,vardecl,in,expr,rb,stmt
JSFunction !JSAnnot !JSIdent !JSAnnot !(JSCommaList JSIdent) !JSAnnot !JSBlock !JSSemi | fn,name, lb,parameter list,rb,block,autosemi
JSIf !JSAnnot !JSAnnot !JSExpression !JSAnnot !JSStatement | if,(,expr,),stmt
JSIfElse !JSAnnot !JSAnnot !JSExpression !JSAnnot !JSStatement !JSAnnot !JSStatement | if,(,expr,),stmt,else,rest
JSLabelled !JSIdent !JSAnnot !JSStatement | identifier,colon,stmt
JSEmptyStatement !JSAnnot |
JSExpressionStatement !JSExpression !JSSemi |
JSAssignStatement !JSExpression !JSAssignOp !JSExpression !JSSemi | lhs, assignop, rhs, autosemi
JSMethodCall !JSExpression !JSAnnot !(JSCommaList JSExpression) !JSAnnot !JSSemi |
JSReturn !JSAnnot !(Maybe JSExpression) !JSSemi | optional expression,autosemi
JSSwitch !JSAnnot !JSAnnot !JSExpression !JSAnnot !JSAnnot ![JSSwitchParts] !JSAnnot !JSSemi | switch,lb,expr,rb,caseblock,autosemi
JSThrow !JSAnnot !JSExpression !JSSemi | throw val autosemi
JSTry !JSAnnot !JSBlock ![JSTryCatch] !JSTryFinally | try,block,catches,finally
JSVariable !JSAnnot !(JSCommaList JSExpression) !JSSemi | var|const, decl, autosemi
JSWhile !JSAnnot !JSAnnot !JSExpression !JSAnnot !JSStatement | while,lb,expr,rb,stmt
JSWith !JSAnnot !JSAnnot !JSExpression !JSAnnot !JSStatement !JSSemi | with,lb,expr,rb,stmt list

Instances

Eq JSStatement |
Data JSStatement |
Show JSStatement |

data JSBlock

Constructors

JSBlock !JSAnnot ![JSStatement] !JSAnnot | lbrace, stmts, rbrace

Instances

Eq JSBlock |
Data JSBlock |
Show JSBlock |

data JSSwitchParts

Constructors

JSCase !JSAnnot !JSExpression !JSAnnot ![JSStatement] | expr,colon,stmtlist
JSDefault !JSAnnot !JSAnnot ![JSStatement] | colon,stmtlist

Instances

Eq JSSwitchParts |
Data JSSwitchParts |
Show JSSwitchParts |

data JSAST

Constructors

JSAstProgram ![JSStatement] !JSAnnot | source elements, tailing whitespace
JSAstStatement !JSStatement !JSAnnot |
JSAstExpression !JSExpression !JSAnnot |
JSAstLiteral !JSExpression !JSAnnot |

Instances

Eq JSAST |
Data JSAST |
Show JSAST |

data JSObjectProperty

Constructors

JSPropertyAccessor !JSAccessor !JSPropertyName !JSAnnot ![JSExpression] !JSAnnot !JSBlock | (get|set), name, lb, params, rb, block
JSPropertyNameandValue !JSPropertyName !JSAnnot ![JSExpression] | name, colon, value

Instances

Eq JSObjectProperty |
Data JSObjectProperty |
Show JSObjectProperty |

data JSPropertyName

Constructors

JSPropertyIdent !JSAnnot !String |
JSPropertyString !JSAnnot !String |
JSPropertyNumber !JSAnnot !String |

Instances

Eq JSPropertyName |
Data JSPropertyName |
Show JSPropertyName |

type JSObjectPropertyList = JSCommaTrailingList JSObjectProperty

data JSAccessor

Accessors for JSObjectProperty is either `get` or `set`.

Constructors

JSAccessorGet !JSAnnot |
JSAccessorSet !JSAnnot |

Instances

Eq JSAccessor |
Data JSAccessor |
Show JSAccessor |

data JSIdent

Constructors

JSIdentName !JSAnnot !String |
JSIdentNone |

Instances

Eq JSIdent |
Data JSIdent |
Show JSIdent |

data JSVarInitializer

Constructors

JSVarInit !JSAnnot !JSExpression | assignop, initializer
JSVarInitNone |

Instances

Eq JSVarInitializer |
Data JSVarInitializer |
Show JSVarInitializer |

data JSArrayElement

Constructors

JSArrayElement !JSExpression |
JSArrayComma !JSAnnot |

Instances

Eq JSArrayElement |
Data JSArrayElement |
Show JSArrayElement |

data JSCommaList a

Constructors

JSLCons !(JSCommaList a) !JSAnnot !a | head, comma, a
JSLOne !a | single element (no comma)
JSLNil |

Instances

Eq a => Eq (JSCommaList a) |
Data a => Data (JSCommaList a) |
Show a => Show (JSCommaList a) |

data JSCommaTrailingList a

Constructors

JSCTLComma !(JSCommaList a) !JSAnnot | list, trailing comma
JSCTLNone !(JSCommaList a) | list

Instances

Eq a => Eq (JSCommaTrailingList a) |
Data a => Data (JSCommaTrailingList a) |
Show a => Show (JSCommaTrailingList a) |

showStripped :: JSAST -> String

Show the AST elements stipped of their JSAnnot data.