Grempa-0.2.2: Embedded grammar DSL and LALR parser generator

Safe HaskellNone



Generate arbitrary input strings for a grammar and see that it is able to parse them.





:: (Show a, Show s, Eq a, Typeable a, Typeable s) 
=> Parser s a

Input parser

-> Grammar s a

The grammar used to generate the parser

-> Property 

QuickCheck property for seeing if a parser can parse everything produced by a grammar and get the expected result.

There are cases where the property will fail even though the parser is correct. That can happen when there is an epsilon production that makes it valid to make the result tree nest one more level without eating any of the input. The parsers generated will not do this, but the random input generator currently will (this is a bug). An example of this is the following:

 data Expr = ... | EApp Expr [Expr]
 grammar = ...
     expr <- rule [...
                  , EApp <@> expr <#> exprs
     exprs <- several expr

Here, the random generator may produce EApp expr [] for some expr, as the rule several expr matches 0 or more exprs. which will have the same input token string as just expr which is what the parser will parse, so the expected result and the parsed result will differ.