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

Text.GrammarCombinators.Transform.UnfoldRecursion

Synopsis

Documentation

type UnfoldDepth phi = forall ix. phi ix -> IntegerSource

A value of type UnfoldDepth defines for each non-terminal in a grammar how many times it should be unfolded by the unfoldSelective or unfoldSelectiveE algorithms.

unfoldRecursion :: ProcessingContextFreeGrammar phi t r -> ProcessingRegularGrammar phi t rSource

Unfold recursion in a given contextx-free grammar, replacing calls to ref idx with the non-terminal's production rule. This produces production rules similar to those in traditional parser combinator libraries.

unfoldRecursionE :: ProcessingExtendedContextFreeGrammar phi t r -> ProcessingRegularGrammar phi t rSource

Unfold recursion in a given extended context-free grammar, replacing calls to ref idx with the non-terminal's production rule. This produces production rules similar to those in traditional parser combinator libraries.

selectNothing :: UnfoldDepth phiSource

A value of type UnfoldDepth phi indicating nothing should be unfolded at all. This can be used as a start value and then further modified with the selectNT function.

selectAllOnce :: UnfoldDepth phiSource

A value of type UnfoldDepth phi indicating every non-terminal should be unfolded once.

selectNT :: EqFam phi => UnfoldDepth phi -> phi ix -> UnfoldDepth phiSource

A function modifying a given UnfoldDepth phi by increasing the depth for a given non-terminal by 1.

modifyUnfoldDepth :: EqFam phi => UnfoldDepth phi -> (Integer -> Integer) -> phi ix -> UnfoldDepth phiSource

A function modifying a given UnfoldDepth phi by applying a given function to the depth for a given non-terminal.

unfoldSelective :: EqFam phi => UnfoldDepth phi -> ProcessingContextFreeGrammar phi t r -> ProcessingContextFreeGrammar phi t rSource

Selectively unfold a given context-free grammar according to a given UnfoldDepth.

unfoldSelectiveE :: EqFam phi => UnfoldDepth phi -> ProcessingExtendedContextFreeGrammar phi t r -> ProcessingExtendedContextFreeGrammar phi t rSource

Selectively unfold a given extended context-free grammar according to a given UnfoldDepth.

unfoldRule :: ContextFreeRule phi r t v -> ProcessingContextFreeGrammar phi t r -> ContextFreeRule phi r t vSource

Unfold a given context-free rule by replacing all references to non-terminals with the production rule for that non-terminal in a given processing context-free grammar.

unfoldRuleE :: ExtendedContextFreeRule phi r t v -> ProcessingExtendedContextFreeGrammar phi t r -> ExtendedContextFreeRule phi r t vSource

Unfold a given extended context-free rule by replacing all references to non-terminals with the production rule for that non-terminal in a given processing extended context-free grammar.