-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Lua parser and pretty printer -- @package language-lua2 @version 0.1.0.3 -- | Lua pretty-printing re-exports. All AST nodes are instances of -- Pretty; this module just re-exports types and top-level -- rendering functions from wl-pprint. module Language.Lua.Pretty -- | The abstract data type Doc represents pretty documents. -- -- Doc is an instance of the Show class. (show -- doc) pretty prints document doc with a page width of 100 -- characters and a ribbon width of 40 characters. -- --
--   show (text "hello" <$> text "world")
--   
-- -- Which would return the string "hello\nworld", i.e. -- --
--   hello
--   world
--   
data Doc :: * -- | The member prettyList is only used to define the instance -- Pretty a => Pretty [a]. In normal circumstances only the -- pretty function is used. class Pretty a pretty :: Pretty a => a -> Doc prettyList :: Pretty a => [a] -> Doc -- | The data type SimpleDoc represents rendered documents and is -- used by the display functions. -- -- The Int in SText contains the length of the string. -- The Int in SLine contains the indentation for that -- line. The library provides two default display functions -- displayS and displayIO. You can provide your own display -- function by writing a function from a SimpleDoc to your own -- output format. data SimpleDoc :: * SEmpty :: SimpleDoc SChar :: Char -> SimpleDoc -> SimpleDoc SText :: SrictNotUnpackedInt -> String -> SimpleDoc -> SimpleDoc SLine :: SrictNotUnpackedInt -> SimpleDoc -> SimpleDoc -- | This is the default pretty printer which is used by show, -- putDoc and hPutDoc. (renderPretty ribbonfrac width -- x) renders document x with a page width of -- width and a ribbon width of (ribbonfrac * width) -- characters. The ribbon width is the maximal amount of non-indentation -- characters on a line. The parameter ribbonfrac should be -- between 0.0 and 1.0. If it is lower or higher, the -- ribbon width will be 0 or width respectively. renderPretty :: Float -> Int -> Doc -> SimpleDoc -- | (renderCompact x) renders document x without adding -- any indentation. Since no 'pretty' printing is involved, this renderer -- is very fast. The resulting output contains fewer characters than a -- pretty printed version and can be used for output that is read by -- other programs. renderCompact :: Doc -> SimpleDoc -- | (displayS simpleDoc) takes the output simpleDoc from -- a rendering function and transforms it to a ShowS type (for use -- in the Show class). -- --
--   showWidth :: Int -> Doc -> String
--   showWidth w x   = displayS (renderPretty 0.4 w x) ""
--   
displayS :: SimpleDoc -> ShowS -- | (displayIO handle simpleDoc) writes simpleDoc to the -- file handle handle. This function is used for example by -- hPutDoc: -- --
--   hPutDoc handle doc  = displayIO handle (renderPretty 0.4 100 doc)
--   
displayIO :: Handle -> SimpleDoc -> IO () -- | Abstract syntax of Lua 5.3 source files. See -- http://www.lua.org/manual/5.3/ for more information. module Language.Lua.Syntax -- | An identifier, defined as any string of letters, digits, or -- underscores, not beginning with a digit. -- -- http://www.lua.org/manual/5.3/manual.html#3.1 data Ident a Ident :: !a -> !String -> Ident a -- | Zero or more Idents. data IdentList a IdentList :: !a -> ![Ident a] -> IdentList a -- | One or more Idents. data IdentList1 a IdentList1 :: !a -> !(NonEmpty (Ident a)) -> IdentList1 a -- | A chunk; Lua's compilation unit. -- -- http://www.lua.org/manual/5.3/manual.html#3.3.2 type Chunk = Block -- | A block of statements, possibly ending in a return statement. -- -- http://www.lua.org/manual/5.3/manual.html#3.3.1 data Block a Block :: !a -> ![Statement a] -> !(Maybe (ReturnStatement a)) -> Block a -- | A statement. -- -- http://www.lua.org/manual/5.3/manual.html#3.3 data Statement a -- |
--   ;
--   
EmptyStmt :: !a -> Statement a -- |
--   var1, var2, var3 = exp1, exp2, exp3
--   
Assign :: !a -> !(VariableList1 a) -> !(ExpressionList1 a) -> Statement a -- |
--   foo.bar(args)
--   
FunCall :: !a -> !(FunctionCall a) -> Statement a -- |
--   ::label::
--   
Label :: !a -> !(Ident a) -> Statement a -- |
--   break
--   
Break :: !a -> Statement a -- |
--   goto label
--   
Goto :: !a -> !(Ident a) -> Statement a -- |
--   do block end
--   
Do :: !a -> !(Block a) -> Statement a -- |
--   while exp do block end
--   
While :: !a -> !(Expression a) -> !(Block a) -> Statement a -- |
--   repeat block until exp
--   
Repeat :: !a -> !(Block a) -> !(Expression a) -> Statement a -- |
--   if exp then block else block end
--   
If :: !a -> !(NonEmpty (Expression a, Block a)) -> !(Maybe (Block a)) -> Statement a -- |
--   for x = exp do block end
--   
For :: !a -> !(Ident a) -> !(Expression a) -> !(Expression a) -> !(Maybe (Expression a)) -> !(Block a) -> Statement a -- |
--   for a, b, c in exp1, exp2, exp3 do block end
--   
ForIn :: !a -> !(IdentList1 a) -> !(ExpressionList1 a) -> !(Block a) -> Statement a -- |
--   function name body
--   
FunAssign :: !a -> !(FunctionName a) -> !(FunctionBody a) -> Statement a -- |
--   local function name body
--   
LocalFunAssign :: !a -> !(Ident a) -> !(FunctionBody a) -> Statement a -- |
--   local x, y, z
--   
LocalAssign :: !a -> !(IdentList1 a) -> !(ExpressionList a) -> Statement a data ReturnStatement a -- |
--   return exp1, exp2
--   
ReturnStatement :: !a -> !(ExpressionList a) -> ReturnStatement a data FunctionName a -- |
--   foo.bar:baz
--   
FunctionName :: !a -> !(IdentList1 a) -> !(Maybe (Ident a)) -> FunctionName a -- | A variable. -- -- http://www.lua.org/manual/5.3/manual.html#3.2 data Variable a -- |
--   x
--   
VarIdent :: !a -> !(Ident a) -> Variable a -- |
--   table[exp]
--   
VarField :: !a -> !(PrefixExpression a) -> !(Expression a) -> Variable a -- |
--   table.field
--   
VarFieldName :: !a -> !(PrefixExpression a) -> !(Ident a) -> Variable a -- | One or more Variables. data VariableList1 a VariableList1 :: !a -> !(NonEmpty (Variable a)) -> VariableList1 a -- | An expression. -- -- http://www.lua.org/manual/5.3/manual.html#3.4 data Expression a Nil :: !a -> Expression a Bool :: !a -> !Bool -> Expression a Integer :: !a -> !String -> Expression a Float :: !a -> !String -> Expression a String :: !a -> !String -> Expression a Vararg :: !a -> Expression a FunDef :: !a -> !(FunctionBody a) -> Expression a PrefixExp :: !a -> !(PrefixExpression a) -> Expression a TableCtor :: !a -> !(TableConstructor a) -> Expression a Binop :: !a -> !(Binop a) -> !(Expression a) -> !(Expression a) -> Expression a Unop :: !a -> !(Unop a) -> !(Expression a) -> Expression a -- | Zero or more Expressions. data ExpressionList a ExpressionList :: !a -> ![Expression a] -> ExpressionList a -- | One or more Expressions. data ExpressionList1 a ExpressionList1 :: !a -> !(NonEmpty (Expression a)) -> ExpressionList1 a data PrefixExpression a PrefixVar :: !a -> !(Variable a) -> PrefixExpression a PrefixFunCall :: !a -> !(FunctionCall a) -> PrefixExpression a Parens :: !a -> !(Expression a) -> PrefixExpression a -- | A function call. May be a statement or an expression. -- -- http://www.lua.org/manual/5.3/manual.html#3.3.6 -- -- http://www.lua.org/manual/5.3/manual.html#3.4.10 data FunctionCall a FunctionCall :: !a -> !(PrefixExpression a) -> !(FunctionArgs a) -> FunctionCall a MethodCall :: !a -> !(PrefixExpression a) -> !(Ident a) -> !(FunctionArgs a) -> FunctionCall a data FunctionArgs a -- |
--   (exp1, exp2)
--   
Args :: !a -> !(ExpressionList a) -> FunctionArgs a -- |
--   { x = exp }
--   
ArgsTable :: !a -> !(TableConstructor a) -> FunctionArgs a -- |
--   "str"
--   
ArgsString :: !a -> !String -> FunctionArgs a data FunctionBody a -- |
--   (x, y, ...) block end
--   
FunctionBody :: !a -> !(IdentList a) -> !Bool -> !(Block a) -> FunctionBody a -- | A table constructor. -- -- http://www.lua.org/manual/5.3/manual.html#3.4.9 data TableConstructor a -- |
--   { x = 5, [f(1)] = 6, 7 }
--   
TableConstructor :: !a -> !(FieldList a) -> TableConstructor a data Field a -- |
--   [exp1] = exp2
--   
FieldExp :: !a -> !(Expression a) -> !(Expression a) -> Field a -- |
--   name = exp
--   
FieldIdent :: !a -> !(Ident a) -> !(Expression a) -> Field a -- |
--   exp
--   
Field :: !a -> !(Expression a) -> Field a -- | Zero or more Fields, separated by , or ;. data FieldList a FieldList :: !a -> ![Field a] -> FieldList a data Binop a -- | + Plus :: !a -> Binop a -- | - Minus :: !a -> Binop a -- | * Mult :: !a -> Binop a -- | / FloatDiv :: !a -> Binop a -- | // FloorDiv :: !a -> Binop a -- | ^ Exponent :: !a -> Binop a -- | % Modulo :: !a -> Binop a -- | & BitwiseAnd :: !a -> Binop a -- | ~ BitwiseXor :: !a -> Binop a -- | | BitwiseOr :: !a -> Binop a -- | >> Rshift :: !a -> Binop a -- | << Lshift :: !a -> Binop a -- | .. Concat :: !a -> Binop a -- | < Lt :: !a -> Binop a -- | <= Leq :: !a -> Binop a -- | > Gt :: !a -> Binop a -- | >= Geq :: !a -> Binop a -- | == Eq :: !a -> Binop a -- | ~= Neq :: !a -> Binop a -- | and And :: !a -> Binop a -- | or Or :: !a -> Binop a data Unop a -- | - Negate :: !a -> Unop a -- | not Not :: !a -> Unop a -- | # Length :: !a -> Unop a -- | ~ BitwiseNot :: !a -> Unop a class Functor ast => Annotated ast ann :: Annotated ast => Lens' (ast a) a instance Typeable Ident instance Typeable IdentList instance Typeable IdentList1 instance Typeable FunctionName instance Typeable Binop instance Typeable Unop instance Typeable Expression instance Typeable TableConstructor instance Typeable FieldList instance Typeable Field instance Typeable FunctionBody instance Typeable Block instance Typeable ReturnStatement instance Typeable ExpressionList instance Typeable Statement instance Typeable FunctionCall instance Typeable FunctionArgs instance Typeable PrefixExpression instance Typeable Variable instance Typeable ExpressionList1 instance Typeable VariableList1 instance Data a => Data (Ident a) instance Eq a => Eq (Ident a) instance Functor Ident instance Generic (Ident a) instance Show a => Show (Ident a) instance Data a => Data (IdentList a) instance Eq a => Eq (IdentList a) instance Functor IdentList instance Generic (IdentList a) instance Show a => Show (IdentList a) instance Data a => Data (IdentList1 a) instance Eq a => Eq (IdentList1 a) instance Functor IdentList1 instance Generic (IdentList1 a) instance Show a => Show (IdentList1 a) instance Data a => Data (FunctionName a) instance Eq a => Eq (FunctionName a) instance Functor FunctionName instance Generic (FunctionName a) instance Show a => Show (FunctionName a) instance Data a => Data (Binop a) instance Eq a => Eq (Binop a) instance Functor Binop instance Generic (Binop a) instance Show a => Show (Binop a) instance Data a => Data (Unop a) instance Eq a => Eq (Unop a) instance Functor Unop instance Generic (Unop a) instance Show a => Show (Unop a) instance Data a => Data (Expression a) instance Eq a => Eq (Expression a) instance Functor Expression instance Generic (Expression a) instance Show a => Show (Expression a) instance Data a => Data (TableConstructor a) instance Eq a => Eq (TableConstructor a) instance Functor TableConstructor instance Generic (TableConstructor a) instance Show a => Show (TableConstructor a) instance Data a => Data (FieldList a) instance Eq a => Eq (FieldList a) instance Functor FieldList instance Generic (FieldList a) instance Show a => Show (FieldList a) instance Data a => Data (Field a) instance Eq a => Eq (Field a) instance Functor Field instance Generic (Field a) instance Show a => Show (Field a) instance Data a => Data (FunctionBody a) instance Eq a => Eq (FunctionBody a) instance Functor FunctionBody instance Generic (FunctionBody a) instance Show a => Show (FunctionBody a) instance Data a => Data (Block a) instance Eq a => Eq (Block a) instance Functor Block instance Generic (Block a) instance Show a => Show (Block a) instance Data a => Data (ReturnStatement a) instance Eq a => Eq (ReturnStatement a) instance Functor ReturnStatement instance Generic (ReturnStatement a) instance Show a => Show (ReturnStatement a) instance Data a => Data (ExpressionList a) instance Eq a => Eq (ExpressionList a) instance Functor ExpressionList instance Generic (ExpressionList a) instance Show a => Show (ExpressionList a) instance Data a => Data (Statement a) instance Eq a => Eq (Statement a) instance Functor Statement instance Generic (Statement a) instance Show a => Show (Statement a) instance Data a => Data (FunctionCall a) instance Eq a => Eq (FunctionCall a) instance Functor FunctionCall instance Generic (FunctionCall a) instance Show a => Show (FunctionCall a) instance Data a => Data (FunctionArgs a) instance Eq a => Eq (FunctionArgs a) instance Functor FunctionArgs instance Generic (FunctionArgs a) instance Show a => Show (FunctionArgs a) instance Data a => Data (PrefixExpression a) instance Eq a => Eq (PrefixExpression a) instance Functor PrefixExpression instance Generic (PrefixExpression a) instance Show a => Show (PrefixExpression a) instance Data a => Data (Variable a) instance Eq a => Eq (Variable a) instance Functor Variable instance Generic (Variable a) instance Show a => Show (Variable a) instance Data a => Data (ExpressionList1 a) instance Eq a => Eq (ExpressionList1 a) instance Functor ExpressionList1 instance Generic (ExpressionList1 a) instance Show a => Show (ExpressionList1 a) instance Data a => Data (VariableList1 a) instance Eq a => Eq (VariableList1 a) instance Functor VariableList1 instance Generic (VariableList1 a) instance Show a => Show (VariableList1 a) instance Datatype D1Ident instance Constructor C1_0Ident instance Datatype D1IdentList instance Constructor C1_0IdentList instance Datatype D1IdentList1 instance Constructor C1_0IdentList1 instance Datatype D1FunctionName instance Constructor C1_0FunctionName instance Datatype D1Binop instance Constructor C1_0Binop instance Constructor C1_1Binop instance Constructor C1_2Binop instance Constructor C1_3Binop instance Constructor C1_4Binop instance Constructor C1_5Binop instance Constructor C1_6Binop instance Constructor C1_7Binop instance Constructor C1_8Binop instance Constructor C1_9Binop instance Constructor C1_10Binop instance Constructor C1_11Binop instance Constructor C1_12Binop instance Constructor C1_13Binop instance Constructor C1_14Binop instance Constructor C1_15Binop instance Constructor C1_16Binop instance Constructor C1_17Binop instance Constructor C1_18Binop instance Constructor C1_19Binop instance Constructor C1_20Binop instance Datatype D1Unop instance Constructor C1_0Unop instance Constructor C1_1Unop instance Constructor C1_2Unop instance Constructor C1_3Unop instance Datatype D1Expression instance Constructor C1_0Expression instance Constructor C1_1Expression instance Constructor C1_2Expression instance Constructor C1_3Expression instance Constructor C1_4Expression instance Constructor C1_5Expression instance Constructor C1_6Expression instance Constructor C1_7Expression instance Constructor C1_8Expression instance Constructor C1_9Expression instance Constructor C1_10Expression instance Datatype D1TableConstructor instance Constructor C1_0TableConstructor instance Datatype D1FieldList instance Constructor C1_0FieldList instance Datatype D1Field instance Constructor C1_0Field instance Constructor C1_1Field instance Constructor C1_2Field instance Datatype D1FunctionBody instance Constructor C1_0FunctionBody instance Datatype D1Block instance Constructor C1_0Block instance Datatype D1ReturnStatement instance Constructor C1_0ReturnStatement instance Datatype D1ExpressionList instance Constructor C1_0ExpressionList instance Datatype D1Statement instance Constructor C1_0Statement instance Constructor C1_1Statement instance Constructor C1_2Statement instance Constructor C1_3Statement instance Constructor C1_4Statement instance Constructor C1_5Statement instance Constructor C1_6Statement instance Constructor C1_7Statement instance Constructor C1_8Statement instance Constructor C1_9Statement instance Constructor C1_10Statement instance Constructor C1_11Statement instance Constructor C1_12Statement instance Constructor C1_13Statement instance Constructor C1_14Statement instance Datatype D1FunctionCall instance Constructor C1_0FunctionCall instance Constructor C1_1FunctionCall instance Datatype D1FunctionArgs instance Constructor C1_0FunctionArgs instance Constructor C1_1FunctionArgs instance Constructor C1_2FunctionArgs instance Datatype D1PrefixExpression instance Constructor C1_0PrefixExpression instance Constructor C1_1PrefixExpression instance Constructor C1_2PrefixExpression instance Datatype D1Variable instance Constructor C1_0Variable instance Constructor C1_1Variable instance Constructor C1_2Variable instance Datatype D1ExpressionList1 instance Constructor C1_0ExpressionList1 instance Datatype D1VariableList1 instance Constructor C1_0VariableList1 instance Annotated Unop instance Annotated Binop instance Annotated FieldList instance Annotated Field instance Annotated TableConstructor instance Annotated FunctionBody instance Annotated FunctionArgs instance Annotated FunctionCall instance Annotated PrefixExpression instance Annotated ExpressionList1 instance Annotated ExpressionList instance Annotated Expression instance Annotated VariableList1 instance Annotated Variable instance Annotated FunctionName instance Annotated ReturnStatement instance Annotated Statement instance Annotated Block instance Annotated IdentList1 instance Annotated IdentList instance Annotated Ident instance Pretty (Unop a) instance Pretty (Binop a) instance Pretty (Field a) instance Pretty (TableConstructor a) instance Pretty (FunctionBody a) instance Pretty (FunctionArgs a) instance Pretty (FunctionCall a) instance Pretty (PrefixExpression a) instance Pretty (Expression a) instance Pretty (Variable a) instance Pretty (FunctionName a) instance Pretty (ReturnStatement a) instance Pretty (Statement a) instance Pretty (Block a) instance Pretty (Ident a) module Language.Lua.Token data Token -- | and TkAnd :: Token -- | break TkBreak :: Token -- | do TkDo :: Token -- | else TkElse :: Token -- | elseif TkElseif :: Token -- | end TkEnd :: Token -- | false TkFalse :: Token -- | for TkFor :: Token -- | function TkFunction :: Token -- | goto TkGoto :: Token -- | if TkIf :: Token -- | in TkIn :: Token -- | local TkLocal :: Token -- | nil TkNil :: Token -- | not TkNot :: Token -- | or TkOr :: Token -- | repeat TkRepeat :: Token -- | return TkReturn :: Token -- | then TkThen :: Token -- | true TkTrue :: Token -- | until TkUntil :: Token -- | while TkWhile :: Token -- | + TkPlus :: Token -- | - TkDash :: Token -- | * TkMult :: Token -- | / TkFloatDiv :: Token -- | % TkModulo :: Token -- | ^ TkExponent :: Token -- | # TkLength :: Token -- | & TkBitwiseAnd :: Token -- | ~ TkTilde :: Token -- | | TkBitwiseOr :: Token -- | << TkLShift :: Token -- | >> TkRShift :: Token -- | // TkFloorDiv :: Token -- | == TkEq :: Token -- | ~= TkNeq :: Token -- | <= TkLeq :: Token -- | >= TkGeq :: Token -- | < TkLt :: Token -- |
--   
TkGt :: Token -- | = TkAssign :: Token -- | ( TkLParen :: Token -- | ) TkRParen :: Token -- | { TkLBrace :: Token -- | } TkRBrace :: Token -- | [ TkLBracket :: Token -- | ] TkRBracket :: Token -- | :: TkLabel :: Token -- | ; TkSemi :: Token -- | : TkColon :: Token -- | , TkComma :: Token -- | . TkDot :: Token -- | .. TkConcat :: Token -- | ... TkVararg :: Token -- | ' TkQuote :: Token -- | " TkDoubleQuote :: Token TkIdent :: String -> Token TkStringLit :: String -> Token TkIntLit :: String -> Token TkFloatLit :: String -> Token showToken :: Token -> String instance Typeable Token instance Data Token instance Eq Token instance Generic Token instance Show Token instance Datatype D1Token instance Constructor C1_0Token instance Constructor C1_1Token instance Constructor C1_2Token instance Constructor C1_3Token instance Constructor C1_4Token instance Constructor C1_5Token instance Constructor C1_6Token instance Constructor C1_7Token instance Constructor C1_8Token instance Constructor C1_9Token instance Constructor C1_10Token instance Constructor C1_11Token instance Constructor C1_12Token instance Constructor C1_13Token instance Constructor C1_14Token instance Constructor C1_15Token instance Constructor C1_16Token instance Constructor C1_17Token instance Constructor C1_18Token instance Constructor C1_19Token instance Constructor C1_20Token instance Constructor C1_21Token instance Constructor C1_22Token instance Constructor C1_23Token instance Constructor C1_24Token instance Constructor C1_25Token instance Constructor C1_26Token instance Constructor C1_27Token instance Constructor C1_28Token instance Constructor C1_29Token instance Constructor C1_30Token instance Constructor C1_31Token instance Constructor C1_32Token instance Constructor C1_33Token instance Constructor C1_34Token instance Constructor C1_35Token instance Constructor C1_36Token instance Constructor C1_37Token instance Constructor C1_38Token instance Constructor C1_39Token instance Constructor C1_40Token instance Constructor C1_41Token instance Constructor C1_42Token instance Constructor C1_43Token instance Constructor C1_44Token instance Constructor C1_45Token instance Constructor C1_46Token instance Constructor C1_47Token instance Constructor C1_48Token instance Constructor C1_49Token instance Constructor C1_50Token instance Constructor C1_51Token instance Constructor C1_52Token instance Constructor C1_53Token instance Constructor C1_54Token instance Constructor C1_55Token instance Constructor C1_56Token instance Constructor C1_57Token instance Constructor C1_58Token instance Constructor C1_59Token instance Constructor C1_60Token module Language.Lua.Lexer -- |
--   lex :: String -> [L Token]
--   lex = streamToList . runLexer luaLexer ""
--   
-- --
--   >>> lex "5+5"
--   [TkIntLit "5",TkPlus,TkIntLit "5"]
--   
--   >>> lex "foo?"
--   [TkIdent "foo"*** Exception: Lexical error at :1:4
--   
luaLexer :: Lexer Token -- | The lexical error exception data LexicalError :: * LexicalError :: SrictNotUnpackedPos -> LexicalError -- | A stream of tokens data TokenStream tok :: * -> * TsToken :: tok -> TokenStream tok -> TokenStream tok TsEof :: TokenStream tok TsError :: LexicalError -> TokenStream tok -- | Run a lexer on a string and produce a lazy stream of tokens runLexer :: Lexer tok -> String -> String -> TokenStream (L tok) -- | Convert a TokenStream to a list of tokens. Turn TsError -- into a runtime LexicalError exception. streamToList :: TokenStream tok -> [tok] -- | Convert a TokenStream into either a token list or a -- LexicalError. This function may be occasionally useful, but in -- general its use is discouraged because it needs to force the whole -- stream before returning a result. streamToEitherList :: TokenStream tok -> Either LexicalError [tok] module Language.Lua.Parser -- | Parse a Lua file. May throw LuaParseException. -- --
--   parseLua = parseLuaWith luaChunk
--   
parseLua :: String -> String -> Chunk NodeInfo -- | Parse Lua code with the given grammar. May throw -- LuaParseException. -- --
--   >>> parseLuaWith luaExprssion "" "5+5"
--   Binop
--       (NodeInfo
--           { nodeLoc    = Loc (Pos "" 1 1 0) (Pos "" 1 3 2)
--           , nodeTokens = fromList [TkIntLit "5",TkPlus,TkIntLit "5"]
--           })
--       (Plus
--           (NodeInfo
--               { nodeLoc    = Loc (Pos "" 1 2 1) (Pos "" 1 2 1)
--               , nodeTokens = fromList [TkPlus]
--               }))
--       (Integer
--           (NodeInfo
--               { nodeLoc    = Loc (Pos "" 1 1 0) (Pos "" 1 1 0)
--               , nodeTokens = fromList [TkIntLit "5"]
--               })
--           "5")
--       (Integer
--           (NodeInfo
--               { nodeLoc    = Loc (Pos "" 1 3 2) (Pos "" 1 3 2)
--               , nodeTokens = fromList [TkIntLit "5"]
--               })
--            "5")
--   
-- -- All AST nodes are Functors over their annotation: -- --
--   >>> (() <$) <$> parseLuaWith luaExpression "" "5+5"
--   Binop () (Plus ()) (Integer () "5") (Integer () "5")
--   
parseLuaWith :: LuaGrammar f -> String -> String -> f NodeInfo data LuaParseException LuaLexException :: !Pos -> LuaParseException LuaParseException :: !FilePath -> !(Report String [L Token]) -> LuaParseException LuaAmbiguousParseException :: !FilePath -> !(Report String [L Token]) -> LuaParseException type LuaGrammar f = forall r. Grammar r (Prod r String (L Token) (f NodeInfo)) -- | Grammar for a Lua chunk; i.e. a Lua compilation unit, defined as a -- list of statements. This is the grammar you should use to parse real -- Lua code. luaChunk :: LuaGrammar Chunk -- | Grammar for a single Lua statement. Mostly subsumed by -- luaChunk. luaStatement :: LuaGrammar Statement -- | Grammar for a Lua expression. Provided for smaller REPL-like parsing -- that operates only on expressions. luaExpression :: LuaGrammar Expression -- | AST node source location and constituent tokens. The tokens are -- provided for style-checking purposes; with them, you may assert proper -- whitespace protocol, alignment, trailing commas on table constructors, -- and whatever other subjectivities. data NodeInfo NodeInfo :: !Loc -> !(Seq (L Token)) -> NodeInfo -- | Source location; spans the entirety of the node. _nodeLoc :: NodeInfo -> !Loc -- | Parsed tokens involved in node production. _nodeTokens :: NodeInfo -> !(Seq (L Token)) nodeLoc :: Lens' NodeInfo Loc nodeTokens :: Lens' NodeInfo (Seq (L Token)) -- | A parsing report, which contains fields that are useful for presenting -- errors to the user if a parse is deemed a failure. Note however that -- we get a report even when we successfully parse something. data Report e i :: * -> * -> * Report :: Int -> [e] -> i -> Report e i -- | The final position in the input (0-based) that the parser reached. position :: Report e i -> Int -- | The named productions processed at the final position. expected :: Report e i -> [e] -- | The part of the input string that was not consumed, which may be -- empty. unconsumed :: Report e i -> i -- | The result of a parse. data Result s e i a :: * -> * -> * -> * -> * -- | The parser ended. Ended :: Report e i -> Result s e i a -- | The parser parsed a number of as. These are given as a -- computation, ST s [a] that constructs the as -- when run. We can thus save some work by ignoring this computation if -- we do not care about the results. The Int is the position in -- the input where these results were obtained, the i the rest -- of the input, and the last component is the continuation. Parsed :: ST s [a] -> Int -> i -> ST s (Result s e i a) -> Result s e i a -- | Return all parses from the result of a given parser. The result may -- contain partial parses. The Ints are the position at which a -- result was produced. allParses :: (forall s. ST s (i -> ST s (Result s e i a))) -> i -> ([(a, Int)], Report e i) -- | Return all parses that reached the end of the input from the result of -- a given parser. fullParses :: ListLike i t => (forall s. ST s (i -> ST s (Result s e i a))) -> i -> ([a], Report e i) -- | Create a parser from the given grammar. parser :: ListLike i t => (forall (r :: * -> * -> * -> *). Grammar r (Prod r e t a)) -> ST s (i -> ST s (Result s e i a)) -- | See e.g. how far the parser is able to parse the input string before -- it fails. This can be much faster than getting the parse results for -- highly ambiguous grammars. report :: ListLike i t => (forall s. ST s (i -> ST s (Result s e i a))) -> i -> Report e i instance Typeable NodeInfo instance Typeable LuaParseException instance Data NodeInfo instance Eq NodeInfo instance Generic NodeInfo instance Show NodeInfo instance Eq LuaParseException instance Datatype D1NodeInfo instance Constructor C1_0NodeInfo instance Selector S1_0_0NodeInfo instance Selector S1_0_1NodeInfo instance Exception LuaParseException instance Show LuaParseException instance HasNodeInfo a => HasNodeInfo (Maybe a) instance HasNodeInfo a => HasNodeInfo (NonEmpty a) instance HasNodeInfo a => HasNodeInfo (Seq a) instance HasNodeInfo a => HasNodeInfo [a] instance (HasNodeInfo a, HasNodeInfo b, HasNodeInfo c, HasNodeInfo d) => HasNodeInfo (a, b, c, d) instance (HasNodeInfo a, HasNodeInfo b, HasNodeInfo c) => HasNodeInfo (a, b, c) instance (HasNodeInfo a, HasNodeInfo b) => HasNodeInfo (a, b) instance Annotated ast => HasNodeInfo (ast NodeInfo) instance HasNodeInfo (L Token) instance HasNodeInfo NodeInfo instance Monoid NodeInfo