gll-0.2.0.0: src/GLL/Combinators/Options.hs
module GLL.Combinators.Options where
-- | Options datatype
-- * left_biased_choice: see function leftBiased
-- * pivot_select: provide a filtering function on `pivots'
data PCOptions = PCOptions { left_biased_choice :: Bool
, pivot_select :: Maybe ([Int] -> [Int])
}
-- | The default options: no disambiguation
defaultOptions :: PCOptions
defaultOptions = PCOptions False Nothing
-- | Perform a disambiguation similar to 'longest-match'
maximumPivot :: PCOptions -> PCOptions
maximumPivot opts = opts {pivot_select = Just op}
where op [] = []
op xs = (:[]) $ maximum xs
-- | Make the <|> combinator left-biased such that it
-- only returns results of the right child if the left
-- child does not has any results.
leftBiased :: PCOptions
leftBiased = defaultOptions { left_biased_choice = True }