Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
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
newtype Nonterminal Source #
Nonterminal
is a type that represents nonterminal in the formal grammar Grammar
.
Instances
Eq Nonterminal Source # | |
Defined in GrammarType (==) :: Nonterminal -> Nonterminal -> Bool # (/=) :: Nonterminal -> Nonterminal -> Bool # | |
Ord Nonterminal Source # | |
Defined in GrammarType 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 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.
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)
Relation (Nonterminal, [Symbol]) | |
BooleanRelation (Nonterminal, [Conj]) |
data GrammarType Source #
This type we using to classify grammars.
Instances
Eq GrammarType Source # | |
Defined in GrammarType (==) :: GrammarType -> GrammarType -> Bool # (/=) :: GrammarType -> GrammarType -> Bool # | |
Ord GrammarType Source # | |
Defined in GrammarType 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 showsPrec :: Int -> GrammarType -> ShowS # show :: GrammarType -> String # showList :: [GrammarType] -> ShowS # |