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

Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Cfg.Analysis

Description

Analysis of a context-free grammar

Synopsis

Documentation

data Analysis t nt Source

Analysis of a context-free grammar

Constructors

Analysis 

Fields

baseCfg :: FreeCfg t nt

(a FreeCfg equivalent to) the source grammar

augmentedCfg :: FreeCfg (AugT t) (AugNT nt)

the augmented grammar

nullables :: Set (AugNT nt)

the nonterminals in the grammar that can produce the empty string

firstSet :: AugNT nt -> LookaheadSet t

the first set of the nonterminal for the grammar

firstsOfVs :: AugVs t nt -> LookaheadSet t

the first set of a list of symbols

followSet :: AugNT nt -> LookaheadSet t

the follow set of the nonterminal for the grammar

predictSet :: AugProduction t nt -> LookaheadSet t

the predict set of the production

isLL1 :: Bool

True iff the grammar is LL(1)

ll1Info :: AugNT nt -> Predictions t nt

the productions for this nonterminal and the lookaheads that predict them

mkAnalysis :: forall cfg t nt. (Cfg cfg t nt, Ord nt, Ord t) => cfg t nt -> Analysis t nt Source

Analyzes a context-free grammar

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.