Questions tagged [uu-parsinglib]

uu-parsinglib is a Haskell combinator parsing library with `Applicative` interface.

The uu-parsinglib Haskell package. Fast, online, error-correcting, monadic, applicative, merging, permuting, idiomatic parser combinators. It's written by Doaitse Swierstra from Utrecht University.

New version of the Utrecht University parser combinator library, which provides online, error correction, annotation free, applicative style parser combinators. In addition to this we do provide a monadic and idiomatic interface. Parsers do analyse themselves to avoid commonly made errors. A recent addition was the combinator <||> and associates, which generalise merging and permuting parsers.

This version is based on the module Data.Listlike, and as a result a great variety of input structures (Strings, ByteStrings, etc.) can be handled.

The modules Text.ParserCombinators.UU.Demo.Examples, Text.ParserCombinators.UU.Idioms and Text.ParserCombinators.UU.Demo.MergeAndpermute contain a ready-made show examples function, which can be called (e.g. from ghci) to see, e.g., the error correction at work. It contains extensive haddock documentation, so why not just take a look to see the correction process at work, and to get a feeling for how the various combinators can be used?

The file Text.ParserCombinators.UU.CHANGELOG contains a log of the most recent changes and additions.

The file Text.ParserCombinators.UU.README contains some references to background information.

Links

17 questions
17
votes
1 answer

Parsec or happy (with alex) or uu-parsinglib

I am going to write a parser of verilog (or vhdl) language and will do a lot of manipulations (sort of transformations) of the parsed data. I intend to parse really big files (full Verilog designs, as big as 10K lines) and I will ultimately support…
Dilawar
  • 5,438
  • 9
  • 45
  • 58
7
votes
2 answers

Performance of uu-parsinglib compared to "try" in Parsec

Question I know Parsec and uu-parsinglib and I've written parsers in both of them. Recently I discovered, that there is a problem in uu-parsinglib, which could significantly affect its performance and I do not see a way to solve it. Lets consider…
Wojciech Danilo
  • 11,573
  • 17
  • 66
  • 132
6
votes
2 answers

Parsing an expression grammar having function application with parser combinators (left-recursion)

As a simplified subproblem of a parser for a real language, I am trying to implement a parser for expressions of a fictional language which looks similar to standard imperative languages (like Python, JavaScript, and so). Its syntax features the…
Johannes Weiss
  • 52,533
  • 16
  • 102
  • 136
6
votes
1 answer

Unplanned greedy behaviour in uu-parsinglib

The problem I came across a problem today and I do not know how to solve it. It is very strange to me, because the code I've written should (according to my current knowledge) is correct. So below you can find a sample parser combinators. The most…
Wojciech Danilo
  • 11,573
  • 17
  • 66
  • 132
6
votes
3 answers

Cannot compute minimal length of a parser - uu-parsinglib in Haskell

Lets see the code snippet: pSegmentBegin p i = pIndentExact i *> ((:) <$> p i <*> ((pEOL *> pSegment p i) <|> pure [])) if I change this code in my parser to: pSegmentBegin p i = do pIndentExact i ((:) <$> p i <*> ((pEOL *> pSegment p…
Wojciech Danilo
  • 11,573
  • 17
  • 66
  • 132
6
votes
1 answer

Correctly parsing line indentations in uu-parsinglib in Haskell

I want to create a parser combinator, which will collect all lines below current place, which indentation levels will be greater or equal some i. I think the idea is simple: Consume a line - if its indentation is: ok -> do it for next lines wrong…
Wojciech Danilo
  • 11,573
  • 17
  • 66
  • 132
4
votes
2 answers

Combining lexer and parser in a parser combinator

I'm using uu-parsinglib, but I think the following question is parser combinator generic. Let's consider the following example: I've got a lexer with a combinator pLex, which produces a list of tokens (of type MyToken). I now want to write a parser,…
Wojciech Danilo
  • 11,573
  • 17
  • 66
  • 132
3
votes
1 answer

An UU parser recognizing just the empty string input?

I need a value of type Parser () which would succeed (and return ()) on empty (lenght 0) input, and fail in all other cases. pSatisfy (const False) doesn't quite do what's required. pEnd doesn't even seem appropriate for this purpose. pExact 0…
ulidtko
  • 14,740
  • 10
  • 56
  • 88
3
votes
1 answer

UU-Parsinglib slowering drastically when some rules are enabled

I'm writing a compiler using uu-parsinglib and I saw a very strange thing. I defined a pChoice combinator like: pChoice = foldr (<<|>) pFail (notice, I'm using greedy <<|>). Lets consider following code: pFactor i = pChoice [ Expr.Var <$>…
Wojciech Danilo
  • 11,573
  • 17
  • 66
  • 132
3
votes
1 answer

Profiling parsers written using parser combinator libraries in Haskell

What are the standard methods to profile parser written in parser combinator libraries in Haskell? I'm currently using uu-parsinglib but I would be very interested in knowing the methods of profiling also other parser combinator libraries like…
Wojciech Danilo
  • 11,573
  • 17
  • 66
  • 132
3
votes
1 answer

Customize errors handling in uu-parsinglib in Haskell

Is it possible to: throw custom parser errors using uu-parsinglib in Haskell? (I want especially to print custom error message with position information) customize the way errors are displayed to the user? somehow control where the automatic…
Wojciech Danilo
  • 11,573
  • 17
  • 66
  • 132
2
votes
3 answers

Insert a character into parser combinator character stream in Haskell

This question is related to both Parsec and uu-parsinglib. When we write parser combinators, they process characters streams from compiler. Is it somehow possible to parse a character and put it back (or return another character back) to the input…
Wojciech Danilo
  • 11,573
  • 17
  • 66
  • 132
1
vote
1 answer

Parsec's satisfy equivalent in uu-parsinglib

I am looking for a satisfy function like the one Parsec has. Something like: --The parser satisfy f succeeds for any character for which the supplied --function f returns True. --Returns the character that is actually parsed. satisfy :: (Char ->…
aochagavia
  • 5,887
  • 5
  • 34
  • 53
1
vote
1 answer

Monadic parse with uu-parsinglib

I'm trying to create a Monadic parser using uu_parsinglib. I thought I had it covered, but I'm getting some unexpected results in testing A cut down example of my parser is: pType :: Parser ASTType pType = addLength 0 $ do (Amb n_list) <- pName …
OllieB
  • 1,431
  • 9
  • 14
1
vote
1 answer

How to maintain a state in uu-parsinglib Haskell parser combinator

I would like to be able to use get and put functions from State Monad while writing uu-parsinglib parser combinator. How can this be done? Can I somehow create state parser using this library?
Wojciech Danilo
  • 11,573
  • 17
  • 66
  • 132
1
2