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

Safe HaskellSafe-Inferred

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 Source

Constructors

Name a String 

Instances

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

data Stat a Source

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 
Typeable1 Stat 
Annotated Stat 
Eq a => Eq (Stat a) 
Data a => Data (Stat a) 
Show a => Show (Stat a) 

data Exp a Source

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 
Typeable1 Exp 
Annotated Exp 
Eq a => Eq (Exp a) 
Data a => Data (Exp a) 
Show a => Show (Exp a) 

data Var a Source

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 
Typeable1 Var 
Annotated Var 
Eq a => Eq (Var a) 
Data a => Data (Var a) 
Show a => Show (Var a) 

data Binop a Source

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

data Unop a Source

Constructors

Neg a 
Not a 
Len a 

Instances

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

data PrefixExp a Source

Constructors

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

data Table a Source

Constructors

Table a [TableField a]

list of table fields

Instances

data TableField a Source

Constructors

ExpField a (Exp a) (Exp a)

[exp] = exp

NamedField a (Name a) (Exp a)

name = exp

Field a (Exp a) 

data Block a Source

A block is list of statements with optional return statement.

Constructors

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

Instances

data FunName a Source

Constructors

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

data FunDef a Source

Constructors

FunDef a (FunBody a) 

Instances

data FunBody a Source

Constructors

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

(args, vararg, block)

data FunCall a Source

Constructors

NormalFunCall a (PrefixExp a) (FunArg a)

prefixexp ( funarg )

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

prefixexp : name ( funarg )

data FunArg a Source

Constructors

Args a [Exp a]

list of args

TableArg a (Table a)

table constructor

StringArg a String

string

Instances

class Functor ast => Annotated ast whereSource

Methods

ann :: ast l -> lSource

Retrieve the annotation of an AST node.

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

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.