module Hydra.Grammar where
import qualified Hydra.Core as Core
import Data.List
import Data.Map
import Data.Set
newtype Constant =
Constant {
Constant -> String
unConstant :: String}
deriving (Constant -> Constant -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Constant -> Constant -> Bool
$c/= :: Constant -> Constant -> Bool
== :: Constant -> Constant -> Bool
$c== :: Constant -> Constant -> Bool
Eq, Eq Constant
Constant -> Constant -> Bool
Constant -> Constant -> Ordering
Constant -> Constant -> Constant
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Constant -> Constant -> Constant
$cmin :: Constant -> Constant -> Constant
max :: Constant -> Constant -> Constant
$cmax :: Constant -> Constant -> Constant
>= :: Constant -> Constant -> Bool
$c>= :: Constant -> Constant -> Bool
> :: Constant -> Constant -> Bool
$c> :: Constant -> Constant -> Bool
<= :: Constant -> Constant -> Bool
$c<= :: Constant -> Constant -> Bool
< :: Constant -> Constant -> Bool
$c< :: Constant -> Constant -> Bool
compare :: Constant -> Constant -> Ordering
$ccompare :: Constant -> Constant -> Ordering
Ord, ReadPrec [Constant]
ReadPrec Constant
Int -> ReadS Constant
ReadS [Constant]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Constant]
$creadListPrec :: ReadPrec [Constant]
readPrec :: ReadPrec Constant
$creadPrec :: ReadPrec Constant
readList :: ReadS [Constant]
$creadList :: ReadS [Constant]
readsPrec :: Int -> ReadS Constant
$creadsPrec :: Int -> ReadS Constant
Read, Int -> Constant -> String -> String
[Constant] -> String -> String
Constant -> String
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [Constant] -> String -> String
$cshowList :: [Constant] -> String -> String
show :: Constant -> String
$cshow :: Constant -> String
showsPrec :: Int -> Constant -> String -> String
$cshowsPrec :: Int -> Constant -> String -> String
Show)
_Constant :: Name
_Constant = (String -> Name
Core.Name String
"hydra/grammar.Constant")
newtype Grammar =
Grammar {
Grammar -> [Production]
unGrammar :: [Production]}
deriving (Grammar -> Grammar -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Grammar -> Grammar -> Bool
$c/= :: Grammar -> Grammar -> Bool
== :: Grammar -> Grammar -> Bool
$c== :: Grammar -> Grammar -> Bool
Eq, Eq Grammar
Grammar -> Grammar -> Bool
Grammar -> Grammar -> Ordering
Grammar -> Grammar -> Grammar
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Grammar -> Grammar -> Grammar
$cmin :: Grammar -> Grammar -> Grammar
max :: Grammar -> Grammar -> Grammar
$cmax :: Grammar -> Grammar -> Grammar
>= :: Grammar -> Grammar -> Bool
$c>= :: Grammar -> Grammar -> Bool
> :: Grammar -> Grammar -> Bool
$c> :: Grammar -> Grammar -> Bool
<= :: Grammar -> Grammar -> Bool
$c<= :: Grammar -> Grammar -> Bool
< :: Grammar -> Grammar -> Bool
$c< :: Grammar -> Grammar -> Bool
compare :: Grammar -> Grammar -> Ordering
$ccompare :: Grammar -> Grammar -> Ordering
Ord, ReadPrec [Grammar]
ReadPrec Grammar
Int -> ReadS Grammar
ReadS [Grammar]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Grammar]
$creadListPrec :: ReadPrec [Grammar]
readPrec :: ReadPrec Grammar
$creadPrec :: ReadPrec Grammar
readList :: ReadS [Grammar]
$creadList :: ReadS [Grammar]
readsPrec :: Int -> ReadS Grammar
$creadsPrec :: Int -> ReadS Grammar
Read, Int -> Grammar -> String -> String
[Grammar] -> String -> String
Grammar -> String
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [Grammar] -> String -> String
$cshowList :: [Grammar] -> String -> String
show :: Grammar -> String
$cshow :: Grammar -> String
showsPrec :: Int -> Grammar -> String -> String
$cshowsPrec :: Int -> Grammar -> String -> String
Show)
_Grammar :: Name
_Grammar = (String -> Name
Core.Name String
"hydra/grammar.Grammar")
newtype Label =
Label {
Label -> String
unLabel :: String}
deriving (Label -> Label -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Label -> Label -> Bool
$c/= :: Label -> Label -> Bool
== :: Label -> Label -> Bool
$c== :: Label -> Label -> Bool
Eq, Eq Label
Label -> Label -> Bool
Label -> Label -> Ordering
Label -> Label -> Label
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Label -> Label -> Label
$cmin :: Label -> Label -> Label
max :: Label -> Label -> Label
$cmax :: Label -> Label -> Label
>= :: Label -> Label -> Bool
$c>= :: Label -> Label -> Bool
> :: Label -> Label -> Bool
$c> :: Label -> Label -> Bool
<= :: Label -> Label -> Bool
$c<= :: Label -> Label -> Bool
< :: Label -> Label -> Bool
$c< :: Label -> Label -> Bool
compare :: Label -> Label -> Ordering
$ccompare :: Label -> Label -> Ordering
Ord, ReadPrec [Label]
ReadPrec Label
Int -> ReadS Label
ReadS [Label]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Label]
$creadListPrec :: ReadPrec [Label]
readPrec :: ReadPrec Label
$creadPrec :: ReadPrec Label
readList :: ReadS [Label]
$creadList :: ReadS [Label]
readsPrec :: Int -> ReadS Label
$creadsPrec :: Int -> ReadS Label
Read, Int -> Label -> String -> String
[Label] -> String -> String
Label -> String
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [Label] -> String -> String
$cshowList :: [Label] -> String -> String
show :: Label -> String
$cshow :: Label -> String
showsPrec :: Int -> Label -> String -> String
$cshowsPrec :: Int -> Label -> String -> String
Show)
_Label :: Name
_Label = (String -> Name
Core.Name String
"hydra/grammar.Label")
data LabeledPattern =
LabeledPattern {
LabeledPattern -> Label
labeledPatternLabel :: Label,
LabeledPattern -> Pattern
labeledPatternPattern :: Pattern}
deriving (LabeledPattern -> LabeledPattern -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LabeledPattern -> LabeledPattern -> Bool
$c/= :: LabeledPattern -> LabeledPattern -> Bool
== :: LabeledPattern -> LabeledPattern -> Bool
$c== :: LabeledPattern -> LabeledPattern -> Bool
Eq, Eq LabeledPattern
LabeledPattern -> LabeledPattern -> Bool
LabeledPattern -> LabeledPattern -> Ordering
LabeledPattern -> LabeledPattern -> LabeledPattern
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: LabeledPattern -> LabeledPattern -> LabeledPattern
$cmin :: LabeledPattern -> LabeledPattern -> LabeledPattern
max :: LabeledPattern -> LabeledPattern -> LabeledPattern
$cmax :: LabeledPattern -> LabeledPattern -> LabeledPattern
>= :: LabeledPattern -> LabeledPattern -> Bool
$c>= :: LabeledPattern -> LabeledPattern -> Bool
> :: LabeledPattern -> LabeledPattern -> Bool
$c> :: LabeledPattern -> LabeledPattern -> Bool
<= :: LabeledPattern -> LabeledPattern -> Bool
$c<= :: LabeledPattern -> LabeledPattern -> Bool
< :: LabeledPattern -> LabeledPattern -> Bool
$c< :: LabeledPattern -> LabeledPattern -> Bool
compare :: LabeledPattern -> LabeledPattern -> Ordering
$ccompare :: LabeledPattern -> LabeledPattern -> Ordering
Ord, ReadPrec [LabeledPattern]
ReadPrec LabeledPattern
Int -> ReadS LabeledPattern
ReadS [LabeledPattern]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LabeledPattern]
$creadListPrec :: ReadPrec [LabeledPattern]
readPrec :: ReadPrec LabeledPattern
$creadPrec :: ReadPrec LabeledPattern
readList :: ReadS [LabeledPattern]
$creadList :: ReadS [LabeledPattern]
readsPrec :: Int -> ReadS LabeledPattern
$creadsPrec :: Int -> ReadS LabeledPattern
Read, Int -> LabeledPattern -> String -> String
[LabeledPattern] -> String -> String
LabeledPattern -> String
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [LabeledPattern] -> String -> String
$cshowList :: [LabeledPattern] -> String -> String
show :: LabeledPattern -> String
$cshow :: LabeledPattern -> String
showsPrec :: Int -> LabeledPattern -> String -> String
$cshowsPrec :: Int -> LabeledPattern -> String -> String
Show)
_LabeledPattern :: Name
_LabeledPattern = (String -> Name
Core.Name String
"hydra/grammar.LabeledPattern")
_LabeledPattern_label :: FieldName
_LabeledPattern_label = (String -> FieldName
Core.FieldName String
"label")
_LabeledPattern_pattern :: FieldName
_LabeledPattern_pattern = (String -> FieldName
Core.FieldName String
"pattern")
data Pattern =
PatternNil |
PatternIgnored Pattern |
PatternLabeled LabeledPattern |
PatternConstant Constant |
PatternRegex Regex |
PatternNonterminal Symbol |
PatternSequence [Pattern] |
PatternAlternatives [Pattern] |
PatternOption Pattern |
PatternStar Pattern |
PatternPlus Pattern
deriving (Pattern -> Pattern -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Pattern -> Pattern -> Bool
$c/= :: Pattern -> Pattern -> Bool
== :: Pattern -> Pattern -> Bool
$c== :: Pattern -> Pattern -> Bool
Eq, Eq Pattern
Pattern -> Pattern -> Bool
Pattern -> Pattern -> Ordering
Pattern -> Pattern -> Pattern
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Pattern -> Pattern -> Pattern
$cmin :: Pattern -> Pattern -> Pattern
max :: Pattern -> Pattern -> Pattern
$cmax :: Pattern -> Pattern -> Pattern
>= :: Pattern -> Pattern -> Bool
$c>= :: Pattern -> Pattern -> Bool
> :: Pattern -> Pattern -> Bool
$c> :: Pattern -> Pattern -> Bool
<= :: Pattern -> Pattern -> Bool
$c<= :: Pattern -> Pattern -> Bool
< :: Pattern -> Pattern -> Bool
$c< :: Pattern -> Pattern -> Bool
compare :: Pattern -> Pattern -> Ordering
$ccompare :: Pattern -> Pattern -> Ordering
Ord, ReadPrec [Pattern]
ReadPrec Pattern
Int -> ReadS Pattern
ReadS [Pattern]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Pattern]
$creadListPrec :: ReadPrec [Pattern]
readPrec :: ReadPrec Pattern
$creadPrec :: ReadPrec Pattern
readList :: ReadS [Pattern]
$creadList :: ReadS [Pattern]
readsPrec :: Int -> ReadS Pattern
$creadsPrec :: Int -> ReadS Pattern
Read, Int -> Pattern -> String -> String
[Pattern] -> String -> String
Pattern -> String
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [Pattern] -> String -> String
$cshowList :: [Pattern] -> String -> String
show :: Pattern -> String
$cshow :: Pattern -> String
showsPrec :: Int -> Pattern -> String -> String
$cshowsPrec :: Int -> Pattern -> String -> String
Show)
_Pattern :: Name
_Pattern = (String -> Name
Core.Name String
"hydra/grammar.Pattern")
_Pattern_nil :: FieldName
_Pattern_nil = (String -> FieldName
Core.FieldName String
"nil")
_Pattern_ignored :: FieldName
_Pattern_ignored = (String -> FieldName
Core.FieldName String
"ignored")
_Pattern_labeled :: FieldName
_Pattern_labeled = (String -> FieldName
Core.FieldName String
"labeled")
_Pattern_constant :: FieldName
_Pattern_constant = (String -> FieldName
Core.FieldName String
"constant")
_Pattern_regex :: FieldName
_Pattern_regex = (String -> FieldName
Core.FieldName String
"regex")
_Pattern_nonterminal :: FieldName
_Pattern_nonterminal = (String -> FieldName
Core.FieldName String
"nonterminal")
_Pattern_sequence :: FieldName
_Pattern_sequence = (String -> FieldName
Core.FieldName String
"sequence")
_Pattern_alternatives :: FieldName
_Pattern_alternatives = (String -> FieldName
Core.FieldName String
"alternatives")
_Pattern_option :: FieldName
_Pattern_option = (String -> FieldName
Core.FieldName String
"option")
_Pattern_star :: FieldName
_Pattern_star = (String -> FieldName
Core.FieldName String
"star")
_Pattern_plus :: FieldName
_Pattern_plus = (String -> FieldName
Core.FieldName String
"plus")
data Production =
Production {
Production -> Symbol
productionSymbol :: Symbol,
Production -> Pattern
productionPattern :: Pattern}
deriving (Production -> Production -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Production -> Production -> Bool
$c/= :: Production -> Production -> Bool
== :: Production -> Production -> Bool
$c== :: Production -> Production -> Bool
Eq, Eq Production
Production -> Production -> Bool
Production -> Production -> Ordering
Production -> Production -> Production
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Production -> Production -> Production
$cmin :: Production -> Production -> Production
max :: Production -> Production -> Production
$cmax :: Production -> Production -> Production
>= :: Production -> Production -> Bool
$c>= :: Production -> Production -> Bool
> :: Production -> Production -> Bool
$c> :: Production -> Production -> Bool
<= :: Production -> Production -> Bool
$c<= :: Production -> Production -> Bool
< :: Production -> Production -> Bool
$c< :: Production -> Production -> Bool
compare :: Production -> Production -> Ordering
$ccompare :: Production -> Production -> Ordering
Ord, ReadPrec [Production]
ReadPrec Production
Int -> ReadS Production
ReadS [Production]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Production]
$creadListPrec :: ReadPrec [Production]
readPrec :: ReadPrec Production
$creadPrec :: ReadPrec Production
readList :: ReadS [Production]
$creadList :: ReadS [Production]
readsPrec :: Int -> ReadS Production
$creadsPrec :: Int -> ReadS Production
Read, Int -> Production -> String -> String
[Production] -> String -> String
Production -> String
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [Production] -> String -> String
$cshowList :: [Production] -> String -> String
show :: Production -> String
$cshow :: Production -> String
showsPrec :: Int -> Production -> String -> String
$cshowsPrec :: Int -> Production -> String -> String
Show)
_Production :: Name
_Production = (String -> Name
Core.Name String
"hydra/grammar.Production")
_Production_symbol :: FieldName
_Production_symbol = (String -> FieldName
Core.FieldName String
"symbol")
_Production_pattern :: FieldName
_Production_pattern = (String -> FieldName
Core.FieldName String
"pattern")
newtype Regex =
Regex {
Regex -> String
unRegex :: String}
deriving (Regex -> Regex -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Regex -> Regex -> Bool
$c/= :: Regex -> Regex -> Bool
== :: Regex -> Regex -> Bool
$c== :: Regex -> Regex -> Bool
Eq, Eq Regex
Regex -> Regex -> Bool
Regex -> Regex -> Ordering
Regex -> Regex -> Regex
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Regex -> Regex -> Regex
$cmin :: Regex -> Regex -> Regex
max :: Regex -> Regex -> Regex
$cmax :: Regex -> Regex -> Regex
>= :: Regex -> Regex -> Bool
$c>= :: Regex -> Regex -> Bool
> :: Regex -> Regex -> Bool
$c> :: Regex -> Regex -> Bool
<= :: Regex -> Regex -> Bool
$c<= :: Regex -> Regex -> Bool
< :: Regex -> Regex -> Bool
$c< :: Regex -> Regex -> Bool
compare :: Regex -> Regex -> Ordering
$ccompare :: Regex -> Regex -> Ordering
Ord, ReadPrec [Regex]
ReadPrec Regex
Int -> ReadS Regex
ReadS [Regex]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Regex]
$creadListPrec :: ReadPrec [Regex]
readPrec :: ReadPrec Regex
$creadPrec :: ReadPrec Regex
readList :: ReadS [Regex]
$creadList :: ReadS [Regex]
readsPrec :: Int -> ReadS Regex
$creadsPrec :: Int -> ReadS Regex
Read, Int -> Regex -> String -> String
[Regex] -> String -> String
Regex -> String
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [Regex] -> String -> String
$cshowList :: [Regex] -> String -> String
show :: Regex -> String
$cshow :: Regex -> String
showsPrec :: Int -> Regex -> String -> String
$cshowsPrec :: Int -> Regex -> String -> String
Show)
_Regex :: Name
_Regex = (String -> Name
Core.Name String
"hydra/grammar.Regex")
newtype Symbol =
Symbol {
Symbol -> String
unSymbol :: String}
deriving (Symbol -> Symbol -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Symbol -> Symbol -> Bool
$c/= :: Symbol -> Symbol -> Bool
== :: Symbol -> Symbol -> Bool
$c== :: Symbol -> Symbol -> Bool
Eq, Eq Symbol
Symbol -> Symbol -> Bool
Symbol -> Symbol -> Ordering
Symbol -> Symbol -> Symbol
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Symbol -> Symbol -> Symbol
$cmin :: Symbol -> Symbol -> Symbol
max :: Symbol -> Symbol -> Symbol
$cmax :: Symbol -> Symbol -> Symbol
>= :: Symbol -> Symbol -> Bool
$c>= :: Symbol -> Symbol -> Bool
> :: Symbol -> Symbol -> Bool
$c> :: Symbol -> Symbol -> Bool
<= :: Symbol -> Symbol -> Bool
$c<= :: Symbol -> Symbol -> Bool
< :: Symbol -> Symbol -> Bool
$c< :: Symbol -> Symbol -> Bool
compare :: Symbol -> Symbol -> Ordering
$ccompare :: Symbol -> Symbol -> Ordering
Ord, ReadPrec [Symbol]
ReadPrec Symbol
Int -> ReadS Symbol
ReadS [Symbol]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Symbol]
$creadListPrec :: ReadPrec [Symbol]
readPrec :: ReadPrec Symbol
$creadPrec :: ReadPrec Symbol
readList :: ReadS [Symbol]
$creadList :: ReadS [Symbol]
readsPrec :: Int -> ReadS Symbol
$creadsPrec :: Int -> ReadS Symbol
Read, Int -> Symbol -> String -> String
[Symbol] -> String -> String
Symbol -> String
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [Symbol] -> String -> String
$cshowList :: [Symbol] -> String -> String
show :: Symbol -> String
$cshow :: Symbol -> String
showsPrec :: Int -> Symbol -> String -> String
$cshowsPrec :: Int -> Symbol -> String -> String
Show)
_Symbol :: Name
_Symbol = (String -> Name
Core.Name String
"hydra/grammar.Symbol")