language-qux-0.2.0.0: Utilities for working with the Qux language

Copyright(c) Henry J. Wylde, 2015
LicenseBSD3
Maintainerpublic@hjwylde.com
Safe HaskellSafe
LanguageHaskell2010

Language.Qux.Syntax

Contents

Description

Abstract syntax tree nodes.

Instances of Pretty are provided for pretty printing.

Synopsis

Nodes

type Id = String Source

An identifier. Identifiers should match '[a-z_][a-zA-Z0-9_']*'.

data Program Source

A program is a module identifier (list of Id's) and a list of declarations.

Constructors

Program [Id] [Decl] 

data Decl Source

A declaration.

Constructors

FunctionDecl Id [(Type, Id)] [Stmt]

A name, list of (Type, Id) parameters and statements. The return type is treated as a parameter with id '@'.

data Stmt Source

A statement.

Constructors

IfStmt Expr [Stmt] [Stmt]

A condition, true block and false block of statements.

ReturnStmt Expr

An expression.

WhileStmt Expr [Stmt]

A condition and block of statements.

data Expr Source

A complex expression.

Constructors

ApplicationExpr Id [Expr]

A function name to call and the arguments to pass as parameters.

BinaryExpr BinaryOp Expr Expr

A binary operation.

ListExpr [Expr]

A list expression.

TypedExpr Type Expr

A typed expression. See Language.Qux.Annotated.TypeResolver.

UnaryExpr UnaryOp Expr

A unary operation.

ValueExpr Value

A raw value.

data BinaryOp Source

A binary operator.

Constructors

Acc

List access.

Mul

Multiplicaiton.

Div

Division.

Mod

Modulus.

Add

Addition.

Sub

Subtraction.

Lt

Less than.

Lte

Less than or equal to.

Gt

Greater than.

Gte

Greater than or equal to.

Eq

Equal to.

Neq

Not equal to.

data UnaryOp Source

A unary operator.

Constructors

Len

List length.

Neg

Negation.

data Value Source

A value is considered to be in it's normal form.

Constructors

BoolValue Bool

A boolean.

IntValue Integer

An unbounded integer.

ListValue [Value]

A normalised list value.

NilValue

A unit value.

data Type Source

A type.

Constructors

BoolType 
IntType 
ListType Type

A list type with an inner type.

NilType