!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~?A return type like Either, that distinguishes not only between B right and wrong answers, but also had gradations of wrongness. 9 Not used in this library. !!!!!!!!!!!!!!!!!!!!!!!!!! The Parser7 datatype is a fairly generic parsing monad with error F reporting and a running state. It can be used for arbitrary token ! types, not just String input. =Apply a parser to an initial state and input token sequence. A The parser cannot return an error value explicitly, so errors J raise an exception. Thus, results can be partial (lazily constructed,  but containing undefined). FSimple failure can be corrected, but when a simple fail is not strong K enough, use failBad for emphasis. It guarantees parsing will terminate  with an exception. CCommit is a way of raising the severity of any errors found within K its argument. Used in the middle of a parser definition, it means that I any operations prior to commitment fail softly, but after commitment,  they fail hard.  One token  One token satifying a predicate *Apply a parsed function to a parsed value x  y3 parses both x and y, but discards the result of y p   f applies the transformation f to any error message  generated in p, having no effect if p succeeds.  adjustErrBad is just like  adjustErr except it also raises the  severity of the error. p   q= means parse p unless p fails in which case parse q instead. I Can be chained together to give multiple attempts to parse something. K (Note that q could itself be a failing parser, e.g. to change the error ; message from that defined in p to something different.) 7 However, a *severe* failure in p cannot be ignored. 7Parse the first alternative in the list that succeeds. @Parse the first alternative that succeeds, but if none succeed, D report only the severe errors, and if none of those, then report  all the soft errors. KHelper for formatting error messages: indents all lines by a fixed amount. @ indicates whether the parser succeeded through the Maybe type. 'many p'5 parses a list of elements with individual parser p. = Cannot fail, since an empty list is a valid return value. !Parse a non-empty list of items. 3Parse a list of items separated by discarded junk. =Parse a non-empty list of items separated by discarded junk. @Parse a list of items, discarding the start, end, and separator  items. 1Parse a bracketed item, discarding the brackets. 'manyFinally e t'& parses a possibly-empty sequence of e's, A terminated by a t. Any parse failures could be due either to A a badly-formed terminator or a badly-formed element, so raise  both possible errors. Update the internal state. Query the internal state. #Deliver the entire internal state. FPush some tokens back onto the front of the input stream and reparse. C This is useful e.g. for recursively expanding macros. When the ? user-parser recognises a macro use, it can lookup the macro > expansion from the parse state, lex it, and then stuff the . lexed expansion back down into the parser.     The Parser7 datatype is a fairly generic parsing monad with error B reporting. It can be used for arbitrary token types, not just L String input. (If you require a running state, use module PolyStateLazy  instead.) EApply a parser to an input token sequence. The parser cannot return K an error value explicitly, so errors raise an exception. Thus, results B can be partial (lazily constructed, but containing undefined). FSimple failure can be corrected, but when a simple fail is not strong A enough, use failBad for emphasis. It guarantees parsing will  terminate with an exception. CCommit is a way of raising the severity of any errors found within K its argument. Used in the middle of a parser definition, it means that I any operations prior to commitment fail softly, but after commitment,  they fail hard.  One token ! One token satifying a predicate "*Apply a parsed function to a parsed value #x # y3 parses both x and y, but discards the result of y $p $ f applies the transformation f to any error message  generated in p, having no effect if p succeeds. % adjustErrBad is just like  adjustErr except it also raises the  severity of the error. &p & q= means parse p unless p fails in which case parse q instead. I Can be chained together to give multiple attempts to parse something. K (Note that q could itself be a failing parser, e.g. to change the error ; message from that defined in p to something different.) 7 However, a *severe* failure in p cannot be ignored. '7Parse the first alternative in the list that succeeds. (@Parse the first alternative that succeeds, but if none succeed, D report only the severe errors, and if none of those, then report  all the soft errors. )KHelper for formatting error messages: indents all lines by a fixed amount. **@ indicates whether the parser succeeded through the Maybe type. +'many p'5 parses a list of elements with individual parser p. = Cannot fail, since an empty list is a valid return value. ,!Parse a non-empty list of items. -3Parse a list of items separated by discarded junk. .=Parse a non-empty list of items separated by discarded junk. /@Parse a list of items, discarding the start, end, and separator  items. 01Parse a bracketed item, discarding the brackets. 1'manyFinally e t'& parses a possibly-empty sequence of e's, A terminated by a t. Any parse failures could be due either to A a badly-formed terminator or a badly-formed element, so raise  both possible errors. 2FPush some tokens back onto the front of the input stream and reparse. C This is useful e.g. for recursively expanding macros. When the ? user-parser recognises a macro use, it can lookup the macro > expansion from the parse state, lex it, and then stuff the . lexed expansion back down into the parser.  !"#$%&'()*+,-./012 !"#$%)&'(*+,-./012 !"#$%&'()*+,-./012?A return type like Either, that distinguishes not only between B right and wrong answers, but also had gradations of wrongness. 3The Parser7 datatype is a fairly generic parsing monad with error F reporting and a running state. It can be used for arbitrary token ! types, not just String input. 45=Apply a parser to an initial state and input token sequence. 6CWhen a simple fail is not strong enough, use failBad for emphasis. L An emphasised (severe) error can propagate out through choice operators. 7CCommit is a way of raising the severity of any errors found within K its argument. Used in the middle of a parser definition, it means that I any operations prior to commitment fail softly, but after commitment,  they fail hard. 8 One token 9 One token satifying a predicate :*Apply a parsed function to a parsed value ;x ; y3 parses both x and y, but discards the result of y <p < f applies the transformation f to any error message  generated in p, having no effect if p succeeds. = adjustErrBad is just like  adjustErr except it also raises the  severity of the error. >p > q= means parse p unless p fails in which case parse q instead. I Can be chained together to give multiple attempts to parse something. K (Note that q could itself be a failing parser, e.g. to change the error ; message from that defined in p to something different.) 5 However, a severe failure in p cannot be ignored. ?7Parse the first alternative in the list that succeeds. @@Parse the first alternative that succeeds, but if none succeed, D report only the severe errors, and if none of those, then report  all the soft errors. AKHelper for formatting error messages: indents all lines by a fixed amount. B'many p'5 parses a list of elements with individual parser p. = Cannot fail, since an empty list is a valid return value. C!Parse a non-empty list of items. D3Parse a list of items separated by discarded junk. E=Parse a non-empty list of items separated by discarded junk. F@Parse a list of items, discarding the start, end, and separator  items. G1Parse a bracketed item, discarding the brackets. H'manyFinally e t'& parses a possibly-empty sequence of e's, A terminated by a t. Any parse failures could be due either to A a badly-formed terminator or a badly-formed element, so raise  both possible errors. IUpdate the internal state. JQuery the internal state. K#Deliver the entire internal state. LFPush some tokens back onto the front of the input stream and reparse. C This is useful e.g. for recursively expanding macros. When the ? user-parser recognises a macro use, it can lookup the macro > expansion from the parse state, lex it, and then stuff the . lexed expansion back down into the parser. 3456789:;<=>?@ABCDEFGHIJKL3456789:;<=A>?@BCDEFGHIJKL34456789:;<=>?@ABCDEFGHIJKLMThe Parser7 datatype is a fairly generic parsing monad with error B reporting. It can be used for arbitrary token types, not just H String input. (If you require a running state, use module PolyState  instead) NO+Apply a parser to an input token sequence. PCWhen a simple fail is not strong enough, use failBad for emphasis. L An emphasised (severe) error can propagate out through choice operators. QCCommit is a way of raising the severity of any errors found within K its argument. Used in the middle of a parser definition, it means that I any operations prior to commitment fail softly, but after commitment,  they fail hard. R One token S One token satifying a predicate T*Apply a parsed function to a parsed value Ux U y3 parses both x and y, but discards the result of y Vp V f applies the transformation f to any error message  generated in p, having no effect if p succeeds. W adjustErrBad is just like  adjustErr except it also raises the  severity of the error. Xp X q= means parse p unless p fails in which case parse q instead. I Can be chained together to give multiple attempts to parse something. K (Note that q could itself be a failing parser, e.g. to change the error ; message from that defined in p to something different.) 7 However, a *severe* failure in p cannot be ignored. Y7Parse the first alternative in the list that succeeds. Z@Parse the first alternative that succeeds, but if none succeed, D report only the severe errors, and if none of those, then report  all the soft errors. [KHelper for formatting error messages: indents all lines by a fixed amount. \\@ indicates whether the parser succeeded through the Maybe type. ]'many p'5 parses a list of elements with individual parser p. = Cannot fail, since an empty list is a valid return value. ^!Parse a non-empty list of items. _3Parse a list of items separated by discarded junk. `=Parse a non-empty list of items separated by discarded junk. a@Parse a list of items, discarding the start, end, and separator  items. b1Parse a bracketed item, discarding the brackets. c'manyFinally e t'& parses a possibly-empty sequence of e's, A terminated by a t. Any parse failures could be due either to A a badly-formed terminator or a badly-formed element, so raise  both possible errors. dFPush some tokens back onto the front of the input stream and reparse. C This is useful e.g. for recursively expanding macros. When the ? user-parser recognises a macro use, it can lookup the macro > expansion from the parse state, lex it, and then stuff the . lexed expansion back down into the parser. MNOPQRSTUVWXYZ[\]^_`abcdMNOPQRSTUVW[XYZ\]^_`abcdMNNOPQRSTUVWXYZ[\]^_`abcd e The class Parse is a replacement for Read, operating over String input. M Essentially, it permits better error messages for why something failed to ' parse. It is rather important that parse can read back exactly what 1 is generated by the corresponding instance of show. To apply a parser  to some text, use  runParser. fgh8A synonym for Parser Char, i.e. string input (no state) iEIf there already exists a Read instance for a type, then we can make 8 a Parser for it, but with only poor error-reporting. j*One lexical chunk (Haskell-style lexing). kFEnsure that the next input word is the given string. (Note the input @ is lexed as haskell, so wordbreaks at spaces, symbols, etc.) l)Allow true string parens around an item. mFDeal with named field syntax. The string argument is the field name, 2 and the parser returns the value of the field. nIParse one of a bunch of alternative constructors. In the list argument, > the first element of the pair is the constructor name, and K the second is the parser for the rest of the value. The first matching  parse is returned. o>Parse one of the given nullary constructors (an enumeration). F The string argument is the name of the type, and the list argument : should contain all of the possible enumeration values. #MNOPQRSTUVWXYZ[\]^_`abcdefghijklmno hefgijklmno efgfghijklmnopq:The parser type is parametrised on the types of the state s,  the input tokens t , error-type e, and the result value a. A The state and remaining input are threaded through the monad. r#Deliver the first remaining token. s$Fail if end of input is not reached CDeliver the first parse result only, eliminating any backtracking. tCApply the parser to some real input, given an initial state value.  If the parser fails, raise  to halt the program. E (This is the original exported behaviour - to allow the caller to ( deal with the error differently, see papply'.) uCApply the parser to some real input, given an initial state value. C If the parser fails, return a diagnostic message to the caller. v8A choice between parsers. Keep only the first success. 5Deliver the first token if it satisfies a predicate. w3Deliver the first token if it equals the argument. x;Deliver the first token if it does not equal the argument. yDeliver zero or more values of a. zDeliver one or more values of a. {Deliver zero or more values of a separated by b's. |Deliver one or more values of a separated by b's. }~>Accept a complete parse of the input only, no partial parses. GReturn an error using the supplied diagnostic string, and a token type ( which includes position information. 0If the parser fails, generate an error message. Update the internal state. Query the internal state. #Deliver the entire internal state. ;This is useful for recursively expanding macros. When the ? user-parser recognises a macro use, it can lookup the macro > expansion from the parse state, lex it, and then stuff the . lexed expansion back down into the parser. pqrstuvwxyz{|}~pqrstuvwxyz{|}~pqqrstuvwxyz{|}~All A LIBRARY OF MONADIC PARSER COMBINATORS 29th July 1996 Graham Hutton Erik Meijer University of Nottingham University of UtrechtStable/Malcolm Wallace <Malcolm.Wallace@cs.york.ac.uk>%The parser monad $$$      !"     "      !"     "#$%&'()*+,- ./0123456789:;<=>?@" .A02B56789:;CDEFGHIJKLMNOPQRSTUVWVWVVXYAZ[\B]^_ polyparse-1.0$Text.ParserCombinators.PolyStateLazyText.ParserCombinators.PolyLazy Text.ParserCombinators.PolyStateText.ParserCombinators.Poly Text.Parse*Text.ParserCombinators.HuttonMeijerWallace#Text.ParserCombinators.HuttonMeijerParserP runParserfailBadcommitnextsatisfyapplydiscard adjustErr adjustErrBadonFailoneOfoneOf'indentoptionalmanymany1sepBysepBy1 bracketSepbracket manyFinallystUpdatestQuerystGetreparseParseparse parseList TextParser parseByReadwordisWordoptionalParensfield constructors enumerationitemeofpapplypapply'+++toknottoksepbysepby1chainlchainl1chainrchainr1opstoEOFelserrorstupdstquerystgetfirstsatchardigitlowerupperletteralphanumstringidentnatintspacescommentjunkskiptokennaturalintegersymbol identifierEitherEthrowE ParseResult joinresultsbaseGHC.Errerror parseerrorToken