FormalGrammars-0.3.1.1: (Context-free) grammars in formal language theory

Safe HaskellNone
LanguageHaskell2010

FormalLanguage.CFG.Grammar.Util

Description

Collection of small helper functions for grammars.

Synopsis

Documentation

isTerminal :: Symbol -> Bool Source #

Term, Deletion, and Epsilon all count as terminal symbols.

isBindableTerminal :: Symbol -> Bool Source #

Term, and Epsilon are terminal symbols that can be bound.

isSyntactic :: Symbol -> Bool Source #

Only SynVars are non-terminal.

isSynStacked :: Symbol -> Bool Source #

special case of single-tape synvar in multi-tape setting

isAllSplit :: Symbol -> Bool Source #

true if we have a split synvar

splitK0 :: Symbol -> Symbol Source #

Set all splitK values to 0 for lookups.

splitToFull :: Symbol -> Symbol Source #

Take a split symbol and rewrite as full.

isSynTerm :: Symbol -> Bool Source #

Is this a syntactic terminal symbol?

isEpsilon :: Symbol -> Bool Source #

Epsilon-only symbols.

dim :: Grammar -> Int Source #

Dimension of the grammar. Rather costly, because we check for dimensional consistency.

uniqueTermsWithTape :: Grammar -> [(SynTermEps, Tape)] Source #

Extract single-tape terminals together with their tape dimension.

uniqueBindableTermsWithTape :: Grammar -> [(SynTermEps, Tape)] Source #

Extract single-tape bindable terminals together with their tape dimension.

uniqueTerminalSymbols :: Grammar -> [Symbol] Source #

Return the nub list of terminal symbols. This includes Deletion symbols, and might not be what you want. Check uniqueBindableTerminalSymbols too!

uniqueSyntacticSymbols :: Grammar -> [Symbol] Source #

Return the nub list of syntactic symbols.

uniqueSynTermSymbols :: Grammar -> [Symbol] Source #

Return the nub list of syntactic terminals.

normalizeStartEpsilon :: Grammar -> Grammar Source #

TODO Currently a stub (original is in .Grammar still. Want to have it monadically, as the code is a mess.

isLeftLinear :: Grammar -> Bool Source #

Left-linear grammars have at most one non-terminal on the RHS. It is the first symbol.