Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Documentation
:: TokenText | Are identifiers |
-> Bool | Option |
-> Bool |
|
-> String | Name of created Haskell module. |
-> AbsMod | Name of Haskell module for abstract syntax. |
-> CF | Grammar. |
-> Doc |
Derive pretty-printer from a BNF grammar.
compareRules :: IsFun f => Rul f -> Rul f -> Ordering Source #
Define an ordering on lists' rules with the following properties:
- rules with a higher coercion level should come first, i.e. the rules for [Foo3] are before rules for [Foo1] and they are both lower than rules for [Foo].
- [] < [_] < _:_
This is desiged to correctly order the rules in the prt function for lists so that the pattern matching works as expectd.
>>>
compareRules (npRule "[]" (ListCat (CoercCat "Foo" 3)) [] Parsable) (npRule "[]" (ListCat (CoercCat "Foo" 1)) [] Parsable)
LT
>>>
compareRules (npRule "[]" (ListCat (CoercCat "Foo" 3)) [] Parsable) (npRule "[]" (ListCat (Cat "Foo")) [] Parsable)
LT
>>>
compareRules (npRule "[]" (ListCat (Cat "Foo")) [] Parsable) (npRule "(:[])" (ListCat (Cat "Foo")) [] Parsable)
LT
>>>
compareRules (npRule "(:[])" (ListCat (Cat "Foo")) [] Parsable) (npRule "(:)" (ListCat (Cat "Foo")) [] Parsable)
LT