symantic-grammar-0.1.0.20170703: Library for symantic grammars.

Safe HaskellNone
LanguageHaskell2010

Language.Symantic.Grammar.Regular

Contents

Description

Symantics for regular grammars.

Synopsis

Type Reg

newtype Reg lr g a Source #

Left or right regular grammar.

Constructors

Reg 

Fields

Instances

Gram_Error err g => Gram_Error err (Reg lr g) Source # 

Methods

catch :: Reg lr g (Either err a) -> Reg lr g a Source #

Gram_State st g => Gram_State st (Reg lr g) Source # 

Methods

stateBefore :: Reg lr g (st -> (st, a)) -> Reg lr g a Source #

stateAfter :: Reg lr g (st -> (st, a)) -> Reg lr g a Source #

getBefore :: Reg lr g (st -> a) -> Reg lr g a Source #

getAfter :: Reg lr g (st -> a) -> Reg lr g a Source #

put :: Reg lr g (st, a) -> Reg lr g a Source #

Gram_Reader st g => Gram_Reader st (Reg lr g) Source # 

Methods

askBefore :: Reg lr g (st -> a) -> Reg lr g a Source #

askAfter :: Reg lr g (st -> a) -> Reg lr g a Source #

ContextFreeOf (Reg lr) Source # 

Methods

cfOf :: Reg lr g a -> CF g a Source #

Functor g => Functor (Reg lr g) Source # 

Methods

fmap :: (a -> b) -> Reg lr g a -> Reg lr g b #

(<$) :: a -> Reg lr g b -> Reg lr g a #

Gram_RuleEBNF g => Gram_RuleEBNF (Reg SideL g) Source # 

Methods

ruleEBNF :: EBNF () -> Reg SideL g a -> RuleEBNF a Source #

argEBNF :: Text -> Reg SideL g a Source #

Gram_RuleEBNF g => Gram_RuleEBNF (Reg SideR g) Source # 

Methods

ruleEBNF :: EBNF () -> Reg SideR g a -> RuleEBNF a Source #

argEBNF :: Text -> Reg SideR g a Source #

Gram_Rule g => Gram_Rule (Reg lr g) Source # 

Methods

rule :: Text -> Rule (Reg lr g a) Source #

rule1 :: Text -> Rule (Reg lr g a -> Reg lr g b) Source #

rule2 :: Text -> Rule (Reg lr g a -> Reg lr g b -> Reg lr g c) Source #

rule3 :: Text -> Rule (Reg lr g a -> Reg lr g b -> Reg lr g c -> Reg lr g d) Source #

rule4 :: Text -> Rule (Reg lr g a -> Reg lr g b -> Reg lr g c -> Reg lr g d -> Reg lr g e) Source #

Gram_Terminal g => Gram_Terminal (Reg lr g) Source # 

Methods

any :: Reg lr g Char Source #

but :: Terminal (Reg lr g) Char -> Terminal (Reg lr g) Char -> Terminal (Reg lr g) Char Source #

eoi :: Reg lr g () Source #

char :: Char -> Reg lr g Char Source #

string :: String -> Reg lr g String Source #

unicat :: Unicat -> Reg lr g Char Source #

range :: (Char, Char) -> Reg lr g Char Source #

(Functor g, Gram_Alt g, Gram_RegL g) => Gram_RegL (Reg SideL g) Source # 

Methods

(<*.) :: RegL (Reg SideL g) (a -> b) -> Terminal (Reg SideL g) a -> RegL (Reg SideL g) b Source #

manyL :: Terminal (Reg SideL g) a -> RegL (Reg SideL g) [a] Source #

someL :: Terminal (Reg SideL g) a -> RegL (Reg SideL g) [a] Source #

(Functor g, Gram_Alt g, Gram_RegR g) => Gram_RegR (Reg SideR g) Source # 

Methods

(.*>) :: Terminal (Reg SideR g) (a -> b) -> RegR (Reg SideR g) a -> RegR (Reg SideR g) b Source #

manyR :: Terminal (Reg SideR g) a -> RegR (Reg SideR g) [a] Source #

someR :: Terminal (Reg SideR g) a -> RegR (Reg SideR g) [a] Source #

Gram_Try g => Gram_Try (Reg lr g) Source # 

Methods

try :: Reg lr g a -> Reg lr g a Source #

Gram_Alt g => Gram_Alt (Reg lr g) Source # 

Methods

empty :: Reg lr g a Source #

(<+>) :: Reg lr g a -> Reg lr g a -> Reg lr g a Source #

choice :: [Reg lr g a] -> Reg lr g a Source #

IsString (g a) => IsString (Reg lr g a) Source # 

Methods

fromString :: String -> Reg lr g a #

Class Gram_Alt

class Gram_Alt g where Source #

Like Alternative but without the Applicative super-class, because a regular grammar is not closed under Applicative.

Minimal complete definition

empty, (<+>)

Methods

empty :: g a Source #

(<+>) :: g a -> g a -> g a infixl 3 Source #

choice :: [g a] -> g a Source #

Instances

Gram_Alt RuleEBNF Source # 
Gram_Alt EBNF Source # 

Methods

empty :: EBNF a Source #

(<+>) :: EBNF a -> EBNF a -> EBNF a Source #

choice :: [EBNF a] -> EBNF a Source #

Gram_Alt p => Gram_Alt (Terminal p) Source # 

Methods

empty :: Terminal p a Source #

(<+>) :: Terminal p a -> Terminal p a -> Terminal p a Source #

choice :: [Terminal p a] -> Terminal p a Source #

Gram_Alt g => Gram_Alt (CF g) Source # 

Methods

empty :: CF g a Source #

(<+>) :: CF g a -> CF g a -> CF g a Source #

choice :: [CF g a] -> CF g a Source #

Gram_Alt g => Gram_Alt (Reg lr g) Source # 

Methods

empty :: Reg lr g a Source #

(<+>) :: Reg lr g a -> Reg lr g a -> Reg lr g a Source #

choice :: [Reg lr g a] -> Reg lr g a Source #

Type Gram_Try

class Gram_Try g where Source #

Explicit backtracking.

To get more accurate error messages, it is helpful to backtrack (put try constructors) only when the grammar actually has another alternative that could match, instead of always backtracking all previous alternatives, as in: try a <+> b

Minimal complete definition

try

Methods

try :: g a -> g a Source #

Instances

Gram_Try RuleEBNF Source # 

Methods

try :: RuleEBNF a -> RuleEBNF a Source #

Gram_Try EBNF Source # 

Methods

try :: EBNF a -> EBNF a Source #

Gram_Try g => Gram_Try (CF g) Source # 

Methods

try :: CF g a -> CF g a Source #

Gram_Try g => Gram_Try (Reg lr g) Source # 

Methods

try :: Reg lr g a -> Reg lr g a Source #

Class Gram_RegR

class (Functor g, Gram_Alt g) => Gram_RegR g where Source #

Symantics for right regular grammars.

Minimal complete definition

(.*>)

Methods

(.*>) :: Terminal g (a -> b) -> RegR g a -> RegR g b infixl 4 Source #

manyR :: Terminal g a -> RegR g [a] Source #

someR :: Terminal g a -> RegR g [a] Source #

Instances

Gram_RegR RuleEBNF Source # 
Gram_RegR EBNF Source # 

Methods

(.*>) :: Terminal EBNF (a -> b) -> RegR EBNF a -> RegR EBNF b Source #

manyR :: Terminal EBNF a -> RegR EBNF [a] Source #

someR :: Terminal EBNF a -> RegR EBNF [a] Source #

Gram_RegR g => Gram_RegR (CF g) Source # 

Methods

(.*>) :: Terminal (CF g) (a -> b) -> RegR (CF g) a -> RegR (CF g) b Source #

manyR :: Terminal (CF g) a -> RegR (CF g) [a] Source #

someR :: Terminal (CF g) a -> RegR (CF g) [a] Source #

(Functor g, Gram_Alt g, Gram_RegR g) => Gram_RegR (Reg SideR g) Source # 

Methods

(.*>) :: Terminal (Reg SideR g) (a -> b) -> RegR (Reg SideR g) a -> RegR (Reg SideR g) b Source #

manyR :: Terminal (Reg SideR g) a -> RegR (Reg SideR g) [a] Source #

someR :: Terminal (Reg SideR g) a -> RegR (Reg SideR g) [a] Source #

Class Gram_RegL

class (Functor g, Gram_Alt g) => Gram_RegL g where Source #

Symantics for left regular grammars.

Minimal complete definition

(<*.)

Methods

(<*.) :: RegL g (a -> b) -> Terminal g a -> RegL g b infixl 4 Source #

manyL :: Terminal g a -> RegL g [a] Source #

someL :: Terminal g a -> RegL g [a] Source #

Instances

Gram_RegL RuleEBNF Source # 
Gram_RegL EBNF Source # 

Methods

(<*.) :: RegL EBNF (a -> b) -> Terminal EBNF a -> RegL EBNF b Source #

manyL :: Terminal EBNF a -> RegL EBNF [a] Source #

someL :: Terminal EBNF a -> RegL EBNF [a] Source #

Gram_RegL g => Gram_RegL (CF g) Source # 

Methods

(<*.) :: RegL (CF g) (a -> b) -> Terminal (CF g) a -> RegL (CF g) b Source #

manyL :: Terminal (CF g) a -> RegL (CF g) [a] Source #

someL :: Terminal (CF g) a -> RegL (CF g) [a] Source #

(Functor g, Gram_Alt g, Gram_RegL g) => Gram_RegL (Reg SideL g) Source # 

Methods

(<*.) :: RegL (Reg SideL g) (a -> b) -> Terminal (Reg SideL g) a -> RegL (Reg SideL g) b Source #

manyL :: Terminal (Reg SideL g) a -> RegL (Reg SideL g) [a] Source #

someL :: Terminal (Reg SideL g) a -> RegL (Reg SideL g) [a] Source #