grammar-combinators-0.2.3: A parsing library of context-free grammar combinators.

Text.GrammarCombinators.Utils.IsReachable

Synopsis

Documentation

foldReachable :: forall phi r rr t ix n. Domain phi => GAnyExtendedContextFreeGrammar phi t r rr -> phi ix -> (forall ix'. phi ix' -> n -> n) -> n -> nSource

Fold a given function over all non-terminals that are reachable from a given non-terminal. This function will at least fold over the given non-terminal itself.

foldReachableProper :: forall phi r t rr ix n. Domain phi => GAnyExtendedContextFreeGrammar phi t r rr -> phi ix -> (forall ix'. phi ix' -> n -> n) -> n -> nSource

Fold a given function over all non-terminals that are reachable from a given non-terminal. This function is limited to proper reachable rules (see isReachableProper for what that means).

isReachable :: forall phi r t rr ix ix'. Domain phi => GAnyExtendedContextFreeGrammar phi t r rr -> phi ix -> phi ix' -> BoolSource

Check if a given non-terminal is reachable from a given other non-terminal in a given extended context-free grammar. This function assumes that all grammars are reachable from themselves.

isReachableProper :: forall phi r t rr ix ix'. Domain phi => GAnyExtendedContextFreeGrammar phi t r rr -> phi ix -> phi ix' -> BoolSource

Check if a given non-terminal is reachable from a given other non-terminal in a given extended context-free grammar. For this function, a non- terminal is not automatically considered reachable from itself, but only if it has some production in which a submatch of itself is present.