sutori-0.2.4: Sutori language compiler

Safe HaskellSafe
LanguageHaskell2010

Sutori.AST

Description

 

Synopsis

Documentation

type SutID = String Source #

Global type for Sutori IDs

type SutAST = [SutInstruction] Source #

A SutAST is a list of instructions

data SutModule Source #

A Sutori Module has a name and a SutAST

Constructors

SutModule SutID SutAST 

data SutInstruction Source #

A SutIntruction represents an instruction/action in the (imperative) story

Constructors

InstExpression SutExpression

Some expressions can be understood an an instruction on its own

ReadVal SutID SutExpression

The action of someone asking for the value of an expression

ReturnVal SutExpression

The action of finishing a story with an expression

Selection SutID SutExpression SutAST SutAST

A selection between two blocks of code given a true/false condition

IterationU SutID SutExpression SutAST

An unbounded iteration while a condition persists

IterationB SutID SutExpression SutAST

A bounded iteration of a story to be repeated a number of times

FreePointer SutID SutExpression

The action of freeing a direction (so it points nowhere)

PrintVal SutID SutExpression

The action of a person saying the value of an expression (into the console)

Break

Stops the innermost iteration loop (skips the rest of the iteratons)

Continue

Skips the current iteration (stays in the loop, skips to next iteration)

data SutExpression Source #

A SutExpression

Constructors

ArrayGet SutType SutExpression SutExpression

Indexing of an array to get an element

BinaryOp SutType SutOperator SutExpression SutExpression

A binary operation

UnaryOp SutType SutOperator SutExpression

An unary operation

SutCall SutType SutID [SutExpression]

A function call

CreatePointer SutType SutID

A direction (pointer) creation

ExprConstructor SutType SutConstructor

A construct (machines, chains, etc...)

ExprID SutType SutID Scope

An ID as an expression

ExprLiteral SutType SutLiteral

A literal

Dereference SutType SutExpression

Dereference of a direction (pointer)

MemberGet SutType SutExpression SutID

Access to a member of a structured value

data SutOperator Source #

Sutori operators

Constructors

SutOpPos

Unary plus/make positive

SutOpNeg

Unary minus/negate

SutOpNot

Unary not

SutOpDer

Unary dereference

SutOpAdd

Binary addition

SutOpSub

Binary substraction

SutOpMul

Binary multiplication

SutOpDiv

Binary division

SutOpIntDiv

Binary integer division

SutOpMod

Binary modulo

SutOpPow

Binary power

SutOpAnd

Binary and

SutOpOr

Binary or

SutOpEqual

Binary equal

SutOpNotEq

Binary not equal

SutOpGEq

Binary greater or equal than

SutOpLEq

Binary less or equal than

SutOpGreater

Binary greater than

SutOpLess

Binary less than

SutOpAssign

Binary assignment

SutOpIndex

Binary indexation

SutOpMember

Binary member get

expressionType :: SutExpression -> SutType Source #

Extracts the type from any expression

withPrimitiveType :: SutPrimitive -> SutExpression -> SutExpression Source #

Clones the expression overriding the type for the given primitive type This is used for type coersion, mostly

asTypeError :: SutExpression -> SutExpression Source #

Clones the expression but sets the type as a TypeError