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

FormalLanguage.CFG.Grammar.Util

Description

Collection of small helper functions for grammars.

Synopsis

# Documentation

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

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

Only SynVars are non-terminal.

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

true if we have a split synvar

Set all splitK values to 0 for lookups.

Take a split symbol and rewrite as full.

Is this a syntactic terminal symbol?

Epsilon-only symbols.

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

Extract single-tape terminals together with their tape dimension.

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

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

Return the nub list of syntactic symbols.

Return the nub list of syntactic terminals.

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

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