Module JavaScript.Types

A library to represent JavaScript programs.

Author: Michael Hanus

Version: May 2017

Summary of exported operations:

jsConsTerm :: String -> [JSExp] -> JSExp   
Representation of constructor terms in JavaScript as array structures.

Exported datatypes:


JSExp

Type of JavaScript expressions.

Constructors:

  • JSString :: String -> JSExp : string constant
  • JSInt :: Int -> JSExp : integer constant
  • JSBool :: Bool -> JSExp : Boolean constant
  • JSIVar :: Int -> JSExp : indexed variable
  • JSIArrayIdx :: Int -> Int -> JSExp : array access to index array variable
  • JSOp :: String -> JSExp -> JSExp -> JSExp : infix operator expression
  • JSFCall :: String -> [JSExp] -> JSExp : function call
  • JSApply :: JSExp -> JSExp -> JSExp : function call where the function is an expression
  • JSLambda :: [Int] -> [JSStat] -> JSExp : (anonymous) function with indexed variables as arguments

JSStat

Type of JavaScript statements.

Constructors:

  • JSAssign :: JSExp -> JSExp -> JSStat : assignment
  • JSIf :: JSExp -> [JSStat] -> [JSStat] -> JSStat : conditional
  • JSSwitch :: JSExp -> [JSBranch] -> JSStat : switch statement
  • JSPCall :: String -> [JSExp] -> JSStat : procedure call
  • JSReturn :: JSExp -> JSStat : return statement
  • JSVarDecl :: Int -> JSStat : local variable declaration

JSBranch

Constructors:

  • JSCase :: String -> [JSStat] -> JSBranch : case branch
  • JSDefault :: [JSStat] -> JSBranch : default branch

JSFDecl

Constructors:

  • JSFDecl :: String -> [Int] -> [JSStat] -> JSFDecl

Exported operations:

jsConsTerm :: String -> [JSExp] -> JSExp   

Representation of constructor terms in JavaScript as array structures.

Example call:
(jsConsTerm cons args)
Parameters:
  • cons : the name of the data constructor
  • args : the arguments of the constructor term
Further infos:
  • solution complete, i.e., able to compute all solutions