microelm / elm-peg / Peg.Test

compareRules : Peg.Rule.Rule -> Peg.Rule.Rule -> Result String ()

Compare two PEG grammar rules for equality. Returns Err message if the rules are different, or Ok () if they are the same.

Arguments

Returns

Example

compareRules
    (Sequence [MatchLiteral "a", MatchLiteral "b"])
    (Sequence [MatchLiteral "a", MatchLiteral "b"])
--> Ok ()

compareRules
    (Sequence [MatchLiteral "a", MatchLiteral "b"])
    (Sequence [MatchLiteral "a", MatchLiteral "c"])
--> Err "expected: MatchLiteral \"b\", actual: MatchLiteral \"c\" at position 2"

compareRuleLists : List Peg.Rule.Rule -> List Peg.Rule.Rule -> Result String ()

Compare two lists of PEG grammar rules for equality. Returns Err message if the rules are different, or Ok () if they are the same.

Arguments

Returns

Example

compareRuleLists
    [ Sequence [MatchLiteral "a", MatchLiteral "b"]
    , Optional (MatchLiteral "c")
    , RuleRef "foo"
    ]
    [ Sequence [MatchLiteral "a", MatchLiteral "b"]
    , Optional (MatchLiteral "c")
    , RuleRef "foo"
    ]
--> Ok ()

compareRuleLists
    [ Sequence [MatchLiteral "a", MatchLiteral "b"]
    , Optional (MatchLiteral "c")
    , RuleRef "foo"
    ]
    [ Sequence [MatchLiteral "a", MatchLiteral "b"]
    , ZeroOrMore (MatchLiteral "c")
    , RuleRef "foo"
    ]
--> Err "expected: Optional (MatchLiteral \"c\"), actual: ZeroOrMore (MatchLiteral \"c\") at position 1"