| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
GrammarType
Description
This module represents types of formal grammar.
In the moment we use it to represent a context-free grammar, conjunctive grammar, boolean grammar.
Synopsis
- newtype Terminal = Terminal {}
- newtype Nonterminal = Nonterminal {}
- data Symbol
- = T Terminal
- | N Nonterminal
- | Eps
- data Conj
- type StartSymbol = Nonterminal
- data Relation
- = Relation (Nonterminal, [Symbol])
- | BooleanRelation (Nonterminal, [Conj])
- data GrammarType
- = CFG
- | Conjunctive
- | Boolean
- newtype Grammar = Grammar (Set Nonterminal, Set Terminal, Set Relation, StartSymbol)
Documentation
Constructors
| Terminal | |
Fields | |
newtype Nonterminal Source #
Nonterminal is a type that represents nonterminal in the formal grammar Grammar.
Constructors
| Nonterminal | |
Fields | |
Instances
| Eq Nonterminal Source # | |
Defined in GrammarType | |
| Ord Nonterminal Source # | |
Defined in GrammarType Methods compare :: Nonterminal -> Nonterminal -> Ordering # (<) :: Nonterminal -> Nonterminal -> Bool # (<=) :: Nonterminal -> Nonterminal -> Bool # (>) :: Nonterminal -> Nonterminal -> Bool # (>=) :: Nonterminal -> Nonterminal -> Bool # max :: Nonterminal -> Nonterminal -> Nonterminal # min :: Nonterminal -> Nonterminal -> Nonterminal # | |
| Show Nonterminal Source # | |
Defined in GrammarType Methods showsPrec :: Int -> Nonterminal -> ShowS # show :: Nonterminal -> String # showList :: [Nonterminal] -> ShowS # | |
Symbol represents symbol that can be appear in right part of the Relation.
N is for Nonterminal.
And Eps is for empty symbol, epsilon.
Constructors
| T Terminal | |
| N Nonterminal | |
| Eps |
Conj is helper type for representing the right part of a relation in a boolean grammar
type StartSymbol = Nonterminal Source #
This type is synonym Nonterminal and used in order to separate StartSymbol from normal Nonterminal.
Relation is a rule of Grammar.
First constructor is for working only with CFG grammars
Second constructor is for working with Boolean or Conjunctive grammars,
though it might be used for defining grammars too
(right part of CFG relation is one PosConj in right part of boolean relation)
Constructors
| Relation (Nonterminal, [Symbol]) | |
| BooleanRelation (Nonterminal, [Conj]) |
data GrammarType Source #
This type we using to classify grammars.
Constructors
| CFG | |
| Conjunctive | |
| Boolean |
Instances
| Eq GrammarType Source # | |
Defined in GrammarType | |
| Ord GrammarType Source # | |
Defined in GrammarType Methods compare :: GrammarType -> GrammarType -> Ordering # (<) :: GrammarType -> GrammarType -> Bool # (<=) :: GrammarType -> GrammarType -> Bool # (>) :: GrammarType -> GrammarType -> Bool # (>=) :: GrammarType -> GrammarType -> Bool # max :: GrammarType -> GrammarType -> GrammarType # min :: GrammarType -> GrammarType -> GrammarType # | |
| Show GrammarType Source # | |
Defined in GrammarType Methods showsPrec :: Int -> GrammarType -> ShowS # show :: GrammarType -> String # showList :: [GrammarType] -> ShowS # | |