mini-ml-0.1.0.0: MiniML compiler
Safe HaskellSafe-Inferred
LanguageHaskell2010

Parser.Ast

Description

Contains all AST elements, all of these produced by the Parser module.

Synopsis

Program

newtype Program Source #

The head of the AST.

Constructors

Program [Statement] 

Instances

Instances details
Show Program Source # 
Instance details

Defined in Parser.Ast

Eq Program Source # 
Instance details

Defined in Parser.Ast

Methods

(==) :: Program -> Program -> Bool #

(/=) :: Program -> Program -> Bool #

Statements

data Statement Source #

Statement.

Constructors

StmtDecl Declaration

Declaration statement, see Declaration.

StmtExpr Expression

Expression statement, see Expression.

Instances

Instances details
Show Statement Source # 
Instance details

Defined in Parser.Ast

Eq Statement Source # 
Instance details

Defined in Parser.Ast

Declarations

data Declaration Source #

Declaration.

Constructors

DeclVar (Identifier, Maybe Type) Expression

Variable declaration.

let x = 5
DeclFun Identifier IsRec Fun

Function declaration.

let f x y = x + y
let rec f x y = f x 1 + f 1 y

Instances

Instances details
Show Declaration Source # 
Instance details

Defined in Parser.Ast

Eq Declaration Source # 
Instance details

Defined in Parser.Ast

Expressions

data Expression Source #

Expression.

Constructors

ExprId Identifier

Identifier expression, see Identifier.

ExprPrimVal PrimitiveValue

Primitive value expression, see PrimitiveValue.

ExprBinOp BinaryOperator Expression Expression

Binary operation, see BinaryOperator.

ExprUnOp UnaryOperator Expression

Unary operation, see UnaryOperator.

ExprApp Expression Expression

Function application expression.

f 6
(fun x y = x + y) 5
ExprIte Expression Expression Expression

If-then-else expression.

if x > 4 then x * 8 else x / 15
ExprLetIn Declaration Expression

Let expression.

let x = 4 in x * x
let f x y = x + y in f 4 8
let rec f x y = f x 1 + f 1 y in f 4 8
ExprFun Fun

Anonymous function, see Fun.

Instances

Instances details
Show Expression Source # 
Instance details

Defined in Parser.Ast

Eq Expression Source # 
Instance details

Defined in Parser.Ast

data Fun Source #

Function representation without the name.

It contains its parameters, returned type and body.

fun x -> true
fun x y -> x + y

Instances

Instances details
Show Fun Source # 
Instance details

Defined in Parser.Ast

Methods

showsPrec :: Int -> Fun -> ShowS #

show :: Fun -> String #

showList :: [Fun] -> ShowS #

Eq Fun Source # 
Instance details

Defined in Parser.Ast

Methods

(==) :: Fun -> Fun -> Bool #

(/=) :: Fun -> Fun -> Bool #