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

Safe HaskellNone

Language.Lua

Synopsis

Documentation

parseText :: Parsec [LTok] () a -> String -> Either ParseError aSource

Runs Lua lexer before parsing. Use parseText stat to parse statements, and parseText exp to parse expressions.

parseFile :: FilePath -> IO (Either ParseError Block)Source

Parse a Lua file. You can use parseText chunk to parse a file from a string.

llex :: String -> [LTok]Source

Lua lexer.

llexFile :: FilePath -> IO [LTok]Source

Run Lua lexer on a file.

stat :: Parser StatSource

Statement parser.

exp :: Parser ExpSource

Expression parser.

chunk :: Parser BlockSource

Lua file parser.

data Block Source

A block is list of statements with optional return statement.

Constructors

Block [Stat] (Maybe [Exp]) 

Instances

Eq Block 
Show Block 
LPretty Block 

data Stat Source

Constructors

Assign [Var] [Exp]

var1, var2 .. = exp1, exp2 ..

FunCall FunCall

function call

Label Name

label for goto

Break

break

Goto Name

goto label

Do Block

do .. end

While Exp Block

while .. do .. end

Repeat Block Exp

repeat .. until ..

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

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

ForRange Name Exp Exp (Maybe Exp) Block

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

ForIn [Name] [Exp] Block

for x in .. do .. end

FunAssign FunName FunBody

function <var> (..) .. end

LocalFunAssign Name FunBody

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

LocalAssign [Name] (Maybe [Exp])

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

EmptyStat

;

Instances

Eq Stat 
Show Stat 
LPretty Stat 

data Exp Source

Constructors

Nil 
Bool Bool 
Number String 
String String 
Vararg

...

EFunDef FunDef

function (..) .. end

PrefixExp PrefixExp 
TableConst Table

table constructor

Binop Binop Exp Exp

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

Unop Unop Exp

unary operators, - not #

Instances

Eq Exp 
Show Exp 
LPretty Exp 

pprint :: LPretty a => a -> DocSource