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

Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Cfg.FirstSet

Description

First sets of a context-free grammar.

Synopsis

Documentation

firstSet :: forall cfg t nt. (Cfg cfg (AugT t) (AugNT nt), Ord nt, Ord t, Show nt) => cfg (AugT t) (AugNT nt) -> AugNT nt -> LookaheadSet t Source

Returns the first set of the nonterminal for the grammar. To avoid recalculations, hold a copy of firstSet cfg.

firstSetMap :: forall cfg t nt. (Cfg cfg (AugT t) (AugNT nt), Ord nt, Ord t, Show nt) => cfg (AugT t) (AugNT nt) -> Map (AugNT nt) (LookaheadSet t) Source

Returns the first set of the nonterminal for the grammar as a map.

firstsOfVs :: Ord t => (AugNT nt -> LookaheadSet t) -> AugVs t nt -> LookaheadSet t Source

Given a firsts function, find the first set of a list of symbols.