language-lua-0.3.0: Lua parser and pretty-printer

Safe HaskellSafe-Inferred
LanguageHaskell98

Language.Lua.Annotated.Syntax

Description

Lua 5.2 syntax tree, as specified in http://www.lua.org/manual/5.2/manual.html#9. Annotation implementation is inspired by haskell-src-exts.

Synopsis

Documentation

data Name a

Constructors

Name a String 

Instances

Functor Name 
Eq a => Eq (Name a) 
Show a => Show (Name a) 

data Stat a

Constructors

Assign a [Var a] [Exp a]

var1, var2 .. = exp1, exp2 ..

FunCall a (FunCall a)

function call

Label a (Name a)

label for goto

Break a

break

Goto a (Name a)

goto label

Do a (Block a)

do .. end

While a (Exp a) (Block a)

while .. do .. end

Repeat a (Block a) (Exp a)

repeat .. until ..

If a [(Exp a, Block a)] (Maybe (Block a))

if .. then .. [elseif ..] [else ..] end

ForRange a (Name a) (Exp a) (Exp a) (Maybe (Exp a)) (Block a)

for x=start, end [, step] do .. end

ForIn a [Name a] [Exp a] (Block a)

for x in .. do .. end

FunAssign a (FunName a) (FunBody a)

function <var> (..) .. end

LocalFunAssign a (Name a) (FunBody a)

local function <var> (..) .. end

LocalAssign a [Name a] (Maybe [Exp a])

local var1, var2 .. = exp1, exp2 ..

EmptyStat a

;

Instances

Functor Stat 
Annotated Stat 
Eq a => Eq (Stat a) 
Show a => Show (Stat a) 

data Exp a

Constructors

Nil a 
Bool a Bool 
Number a String 
String a String 
Vararg a

...

EFunDef a (FunDef a)

function (..) .. end

PrefixExp a (PrefixExp a) 
TableConst a (Table a)

table constructor

Binop a (Binop a) (Exp a) (Exp a)

binary operators, + - * ^ % .. <= >= == ~= and or

Unop a (Unop a) (Exp a)

unary operators, - not #

Instances

Functor Exp 
Annotated Exp 
Eq a => Eq (Exp a) 
Show a => Show (Exp a) 

data Var a

Constructors

VarName a (Name a)

variable

Select a (PrefixExp a) (Exp a)

table[exp]

SelectName a (PrefixExp a) (Name a)

table.variable

Instances

Functor Var 
Annotated Var 
Eq a => Eq (Var a) 
Show a => Show (Var a) 

data Binop a

Constructors

Add a 
Sub a 
Mul a 
Div a 
Exp a 
Mod a 
Concat a 
LT a 
LTE a 
GT a 
GTE a 
EQ a 
NEQ a 
And a 
Or a 

Instances

Functor Binop 
Annotated Binop 
Eq a => Eq (Binop a) 
Show a => Show (Binop a) 

data Unop a

Constructors

Neg a 
Not a 
Len a 

Instances

Functor Unop 
Annotated Unop 
Eq a => Eq (Unop a) 
Show a => Show (Unop a) 

data PrefixExp a

Constructors

PEVar a (Var a) 
PEFunCall a (FunCall a) 
Paren a (Exp a) 

data Table a

Constructors

Table a [TableField a]

list of table fields

Instances

Functor Table 
Annotated Table 
Eq a => Eq (Table a) 
Show a => Show (Table a) 

data TableField a

Constructors

ExpField a (Exp a) (Exp a)

[exp] = exp

NamedField a (Name a) (Exp a)

name = exp

Field a (Exp a) 

data Block a

A block is list of statements with optional return statement.

Constructors

Block a [Stat a] (Maybe [Exp a]) 

Instances

Functor Block 
Annotated Block 
Eq a => Eq (Block a) 
Show a => Show (Block a) 

data FunName a

Constructors

FunName a (Name a) [Name a] (Maybe (Name a)) 

Instances

data FunDef a

Constructors

FunDef a (FunBody a) 

Instances

data FunBody a

Constructors

FunBody a [Name a] (Maybe a) (Block a)

(args, vararg, block)

Instances

data FunCall a

Constructors

NormalFunCall a (PrefixExp a) (FunArg a)

prefixexp ( funarg )

MethodCall a (PrefixExp a) (Name a) (FunArg a)

prefixexp : name ( funarg )

Instances

data FunArg a

Constructors

Args a [Exp a]

list of args

TableArg a (Table a)

table constructor

StringArg a String

string

Instances

class Functor ast => Annotated ast where

Methods

ann :: ast l -> l

Retrieve the annotation of an AST node.

amap :: (l -> l) -> ast l -> ast l

Change the annotation of an AST node. Note that only the annotation of the node itself is affected, and not the annotations of any child nodes. if all nodes in the AST tree are to be affected, use fmap.