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

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

Language.Qux.Annotated.Syntax

Contents

Description

Abstract syntax tree nodes with annotations.

The annotation style was inspired by haskell-src-exts.

Synopsis

Type class

class Annotated node where Source

An annotated class.

Methods

ann :: node a -> a Source

Annotated nodes

data Id a Source

An identifier.

Constructors

Id a String 

Instances

Annotated Id Source 
Eq a => Eq (Id a) Source 
Show a => Show (Id a) Source 

data Program a Source

A program is a list of declarations.

Constructors

Program a [Decl a] 

Instances

data Decl a Source

A declaration.

Constructors

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

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

Instances

name :: Decl a -> Id a Source

parameters :: Decl a -> [(Type a, Id a)] Source

stmts :: Decl a -> [Stmt a] Source

data Stmt a Source

A statement.

Constructors

IfStmt a (Expr a) [Stmt a] [Stmt a]

A condition, true block and false block of statements.

ReturnStmt a (Expr a)

An expression.

WhileStmt a (Expr a) [Stmt a]

A condition and block of statements.

Instances

data Expr a Source

A complex expression.

Constructors

ApplicationExpr a (Id a) [Expr a]

A function name to call and the arguments to pass.

BinaryExpr a BinaryOp (Expr a) (Expr a)

A binary operation.

ListExpr a [Expr a]

A list of expressions.

UnaryExpr a UnaryOp (Expr a)

A unary oepration.

ValueExpr a Value

A raw value.

Instances

data Type a Source

A type.

Constructors

BoolType a 
IntType a 
ListType a (Type a)

A list type with an inner type.

NilType a 

Instances

Regular nodes

data BinaryOp Source

A binary operator.

Constructors

Acc 
Mul 
Div 
Mod 
Add 
Sub 
Lt 
Lte 
Gt 
Gte 
Eq 
Neq 

data UnaryOp Source

A unary operator.

Constructors

Len 
Neg 

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 of values.

NilValue

A unit value.