context-free-grammar-0.0.1: Basic algorithms on context-free grammars

Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Cfg.PredictSet

Description

Predict sets of a context-free grammar.

Synopsis

Documentation

type Prediction t nt = (LookaheadSet t, Set (AugProduction t nt)) Source

A lookahead set with the productions it predicts

type Predictions t nt = Set (Prediction t nt) Source

A set of Predictions. The LookaheadSets of the Predictions will be pairwise disjoint.

predictSet Source

Arguments

:: Ord t 
=> (AugNT nt -> LookaheadSet t)

firstSet for the grammar

-> (AugNT nt -> LookaheadSet t)

followSet for the grammar

-> AugProduction t nt

the production

-> LookaheadSet t 

Returns the predict set of a production.

ll1Info :: (Cfg cfg (AugT t) (AugNT nt), Ord nt, Ord t) => cfg (AugT t) (AugNT nt) -> (AugProduction t nt -> LookaheadSet t) -> AugNT nt -> Predictions t nt Source

Returns the production Predictions for a nonterminal symbol.

ll1InfoMap :: forall cfg t nt. (Cfg cfg (AugT t) (AugNT nt), Ord nt, Ord t) => cfg (AugT t) (AugNT nt) -> (AugProduction t nt -> LookaheadSet t) -> Map (AugNT nt) (Predictions t nt) Source

Returns the production Predictions for the grammar as a map.

isLL1 :: Map (AugNT nt) (Predictions t nt) -> Bool Source

Returns true iff the predictions are unambiguous, true iff the grammar is LL(1).