Safe Haskell | None |
---|
- parseText :: Parsec [LTok] () a -> String -> Either ParseError a
- parseFile :: FilePath -> IO (Either ParseError (Block SourcePos))
- llex :: String -> [LTok]
- llexFile :: FilePath -> IO [LTok]
- stat :: Parser (Stat SourcePos)
- exp :: Parser (Exp SourcePos)
- chunk :: Parser (Block SourcePos)
- data Block a = Block a [Stat a] (Maybe [Exp a])
- data Stat a
- = Assign a [Var a] [Exp a]
- | FunCall a (FunCall a)
- | Label a (Name a)
- | Break a
- | Goto a (Name a)
- | Do a (Block a)
- | While a (Exp a) (Block a)
- | Repeat a (Block a) (Exp a)
- | If a [(Exp a, Block a)] (Maybe (Block a))
- | ForRange a (Name a) (Exp a) (Exp a) (Maybe (Exp a)) (Block a)
- | ForIn a [Name a] [Exp a] (Block a)
- | FunAssign a (FunName a) (FunBody a)
- | LocalFunAssign a (Name a) (FunBody a)
- | LocalAssign a [Name a] (Maybe [Exp a])
- | EmptyStat a
- data Exp a
- pprint :: LPretty a => a -> Doc
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 SourcePos))Source
Parse a Lua file. You can use parseText chunk
to parse a file from a string.
A block is list of statements with optional return statement.
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 | ; |
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 # |