Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- type AParser = Parsec [MToken] LineColPos
- execAParser :: SourceName -> AParser a -> [MToken] -> Either ParseError a
- parseFromString :: AParser a -> String -> Either ParseError a
- parseGLua :: [MToken] -> Either ParseError AST
- parseGLuaFromString :: String -> Either ParseError AST
- rgStart2sp :: Region -> SourcePos
- rgEnd2sp :: Region -> SourcePos
- sp2Rg :: SourcePos -> Region
- lcp2sp :: LineColPos -> SourcePos
- sp2lcp :: SourcePos -> LineColPos
- updatePosMToken :: SourcePos -> MToken -> [MToken] -> SourcePos
- pMTok :: Token -> AParser MToken
- pMSatisfy :: (MToken -> Bool) -> AParser MToken
- pMToken :: forall a. (MToken -> Maybe a) -> AParser a
- pPos :: AParser LineColPos
- pEndPos :: AParser LineColPos
- annotated :: (Region -> a -> b) -> AParser a -> AParser b
- parseChunk :: [MToken] -> AParser AST
- parseBlock :: AParser Block
- parseMStat :: AParser MStat
- pInterleaved :: AParser a -> AParser b -> AParser [b]
- parseReturn :: AParser AReturn
- parseLabel :: AParser MToken
- parseStat :: AParser Stat
- parseDefinition :: AParser Stat
- parseLocalDefinition :: AParser Stat
- parseFunction :: AParser Stat
- parseLocalFunction :: AParser Stat
- parseIf :: AParser Stat
- parseFor :: AParser Stat
- parseNFor :: AParser Stat
- parseGFor :: AParser Stat
- parseFuncName :: AParser FuncName
- parseLocFuncName :: AParser FuncName
- parseNumber :: AParser Expr
- parseString :: AParser MToken
- pName :: AParser MToken
- parseNameList :: AParser [MToken]
- parseVarList :: AParser [PrefixExp]
- parseLocalVarList :: AParser [PrefixExp]
- parseParList :: AParser [MToken]
- parseExpressionList :: AParser [MExpr]
- parseSubExpression :: AParser Expr
- parseAnonymFunc :: AParser Expr
- samePrioL :: [(Token, BinOp)] -> AParser MExpr -> AParser MExpr
- samePrioR :: [(Token, BinOp)] -> AParser MExpr -> AParser MExpr
- parseUnOp :: AParser UnOp
- parseBinOp :: AParser BinOp
- lvl1 :: [(Token, BinOp)]
- lvl2 :: [(Token, BinOp)]
- lvl3 :: [(Token, BinOp)]
- lvl4 :: [(Token, BinOp)]
- lvl5 :: [(Token, BinOp)]
- lvl6 :: [(Token, BinOp)]
- lvl8 :: [(Token, BinOp)]
- parseExpression :: AParser MExpr
- parsePrefixExp :: AParser PrefixExp
- pPrefixExp :: AParser [PFExprSuffix] -> AParser PrefixExp
- pPFExprSuffix :: AParser PFExprSuffix
- pPFExprCallSuffix :: AParser PFExprSuffix
- pPFExprIndexSuffix :: AParser PFExprSuffix
- pFunctionCall :: AParser PrefixExp
- parseVar :: AParser PrefixExp
- parseArgs :: AParser Args
- parseTableConstructor :: AParser [Field]
- parseFieldList :: AParser [Field]
- parseNamedField :: AParser (FieldSep -> Field)
- parseField :: AParser (FieldSep -> Field)
- parseFieldSep :: AParser FieldSep
- parseOptionalFieldSep :: AParser FieldSep
Documentation
execAParser :: SourceName -> AParser a -> [MToken] -> Either ParseError a Source #
Execute a parser
parseFromString :: AParser a -> String -> Either ParseError a Source #
Parse a string directly
parseGLua :: [MToken] -> Either ParseError AST Source #
Parse Garry's mod Lua tokens to an abstract syntax tree. Also returns parse errors
rgStart2sp :: Region -> SourcePos Source #
Region start to SourcePos
lcp2sp :: LineColPos -> SourcePos Source #
LineColPos to SourcePos
sp2lcp :: SourcePos -> LineColPos Source #
SourcePos to LineColPos
updatePosMToken :: SourcePos -> MToken -> [MToken] -> SourcePos Source #
Update a SourcePos with an MToken
pPos :: AParser LineColPos Source #
Get the source position Simply gets the position of the next token Falls back on the collected position when there is no token left
pEndPos :: AParser LineColPos Source #
Get the source position Simply gets the end position of the last parsed token
annotated :: (Region -> a -> b) -> AParser a -> AParser b Source #
A thing of which the region is to be parsed
parseChunk :: [MToken] -> AParser AST Source #
Parses the full AST Its first parameter contains all comments Assumes the mtokens fed to the AParser have no comments
parseBlock :: AParser Block Source #
Parse a block with an optional return value
pInterleaved :: AParser a -> AParser b -> AParser [b] Source #
Parser that is interleaved with 0 or more of the other parser
parseReturn :: AParser AReturn Source #
Parse a return value
parseLabel :: AParser MToken Source #
Label
parseDefinition :: AParser Stat Source #
Global definition Note: Uses try to avoid conflicts with function calls
parseLocalDefinition :: AParser Stat Source #
Local definition
parseFunction :: AParser Stat Source #
Global function definition
parseLocalFunction :: AParser Stat Source #
Local function definition
parseFuncName :: AParser FuncName Source #
Function name (includes dot indices and meta indices)
parseLocFuncName :: AParser FuncName Source #
Local function name: cannot be a meta function nor indexed
parseNumber :: AParser Expr Source #
Parse a number into an expression
parseString :: AParser MToken Source #
Parse any kind of string
parseNameList :: AParser [MToken] Source #
Parse a list of identifiers
parseVarList :: AParser [PrefixExp] Source #
Parse variable list (var1, var2, var3)
parseLocalVarList :: AParser [PrefixExp] Source #
Parse local variable list (var1, var2, var3)
parseParList :: AParser [MToken] Source #
Parse list of function parameters
parseExpressionList :: AParser [MExpr] Source #
list of expressions
parseSubExpression :: AParser Expr Source #
Subexpressions, i.e. without operators
parseAnonymFunc :: AParser Expr Source #
Separate parser for anonymous function subexpression
samePrioL :: [(Token, BinOp)] -> AParser MExpr -> AParser MExpr Source #
Parse operators of the same precedence in a chain
parseBinOp :: AParser BinOp Source #
Parses a binary operator
lvl1 :: [(Token, BinOp)] Source #
Operators, sorted by priority Priority from: http://www.lua.org/manual/5.2/manual.html#3.4.7
lvl2 :: [(Token, BinOp)] Source #
Operators, sorted by priority Priority from: http://www.lua.org/manual/5.2/manual.html#3.4.7
lvl3 :: [(Token, BinOp)] Source #
Operators, sorted by priority Priority from: http://www.lua.org/manual/5.2/manual.html#3.4.7
lvl4 :: [(Token, BinOp)] Source #
Operators, sorted by priority Priority from: http://www.lua.org/manual/5.2/manual.html#3.4.7
lvl5 :: [(Token, BinOp)] Source #
Operators, sorted by priority Priority from: http://www.lua.org/manual/5.2/manual.html#3.4.7
lvl6 :: [(Token, BinOp)] Source #
Operators, sorted by priority Priority from: http://www.lua.org/manual/5.2/manual.html#3.4.7
lvl8 :: [(Token, BinOp)] Source #
Operators, sorted by priority Priority from: http://www.lua.org/manual/5.2/manual.html#3.4.7
parseExpression :: AParser MExpr Source #
Parse chains of binary and unary operators
parsePrefixExp :: AParser PrefixExp Source #
Prefix expressions can have any arbitrary list of expression suffixes
pPrefixExp :: AParser [PFExprSuffix] -> AParser PrefixExp Source #
Prefix expressions The suffixes define rules on the allowed suffixes
pPFExprSuffix :: AParser PFExprSuffix Source #
Parse any expression suffix
pPFExprCallSuffix :: AParser PFExprSuffix Source #
Parse an indexing expression suffix
pPFExprIndexSuffix :: AParser PFExprSuffix Source #
Parse an indexing expression suffix
pFunctionCall :: AParser PrefixExp Source #
Function calls are prefix expressions, but the last suffix MUST be either a function call or a metafunction call
parseVar :: AParser PrefixExp Source #
single variable. Note: definition differs from reference to circumvent the left recursion var ::= Name [{PFExprSuffix}* indexation] | '(' exp ')' {PFExprSuffix}* indexation where "{PFExprSuffix}* indexation" is any arbitrary sequence of prefix expression suffixes that end with an indexation
parseTableConstructor :: AParser [Field] Source #
Table constructor
parseFieldList :: AParser [Field] Source #
A list of table entries Grammar: field {separator field} [separator]
parseNamedField :: AParser (FieldSep -> Field) Source #
Parse a named field (e.g. {named = field}) Contains try to avoid conflict with unnamed fields
parseFieldSep :: AParser FieldSep Source #
Field separator, either comma or semicolon
parseOptionalFieldSep :: AParser FieldSep Source #
Optional field separator, returns NoSep when no separator is found Used at the end of a field list