module Hydra.Impl.Haskell.Dsl.Grammars where

import Hydra.All
import Data.String(IsString(..))


instance IsString Pattern where fromString :: String -> Pattern
fromString = String -> Pattern
symbol

infixr 0 >:
(>:) :: String -> Pattern -> Pattern
String
l >: :: String -> Pattern -> Pattern
>: Pattern
p = LabeledPattern -> Pattern
PatternLabeled forall a b. (a -> b) -> a -> b
$ Label -> Pattern -> LabeledPattern
LabeledPattern (String -> Label
Label String
l) Pattern
p

alts :: [Pattern] -> Pattern
alts :: [Pattern] -> Pattern
alts = [Pattern] -> Pattern
PatternAlternatives

define :: String -> [Pattern] -> Production
define :: String -> [Pattern] -> Production
define String
s [Pattern]
pats = Symbol -> Pattern -> Production
Production (String -> Symbol
Symbol String
s) Pattern
pat
  where
    pat :: Pattern
pat = case [Pattern]
pats of
      [Pattern
p] -> Pattern
p
      [Pattern]
_ -> [Pattern] -> Pattern
alts [Pattern]
pats

ignored :: Pattern -> Pattern
ignored :: Pattern -> Pattern
ignored = Pattern -> Pattern
PatternIgnored

list :: [Pattern] -> Pattern
list :: [Pattern] -> Pattern
list = [Pattern] -> Pattern
PatternSequence

nil :: Pattern
nil :: Pattern
nil = Pattern
PatternNil

opt :: Pattern -> Pattern
opt :: Pattern -> Pattern
opt = Pattern -> Pattern
PatternOption

plus :: Pattern -> Pattern
plus :: Pattern -> Pattern
plus = Pattern -> Pattern
PatternPlus

regex :: String -> Pattern
regex :: String -> Pattern
regex = Regex -> Pattern
PatternRegex forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Regex
Regex

star :: Pattern -> Pattern
star :: Pattern -> Pattern
star = Pattern -> Pattern
PatternStar

symbol :: String -> Pattern
symbol :: String -> Pattern
symbol = Symbol -> Pattern
PatternNonterminal forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Symbol
Symbol

terminal :: String -> Pattern
terminal :: String -> Pattern
terminal = Constant -> Pattern
PatternConstant forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Constant
Constant