symantic-grammar-0.2.0.20170709: Library for symantic grammars.

Safe HaskellNone
LanguageHaskell2010

Language.Symantic.Grammar.ContextFree

Contents

Description

Symantics for context-free grammars.

Synopsis

Type CF

newtype CF g a Source #

Context-free grammar.

Constructors

CF 

Fields

Instances

Gram_Error err g => Gram_Error err (CF g) Source # 

Methods

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

Gram_State st g => Gram_State st (CF g) Source # 

Methods

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

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

getBefore :: CF g (st -> a) -> CF g a Source #

getAfter :: CF g (st -> a) -> CF g a Source #

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

Gram_Reader st g => Gram_Reader st (CF g) Source # 

Methods

askBefore :: CF g (st -> a) -> CF g a Source #

askAfter :: CF g (st -> a) -> CF g a Source #

Functor g => Functor (CF g) Source # 

Methods

fmap :: (a -> b) -> CF g a -> CF g b #

(<$) :: a -> CF g b -> CF g a #

Applicative g => Applicative (CF g) Source # 

Methods

pure :: a -> CF g a #

(<*>) :: CF g (a -> b) -> CF g a -> CF g b #

(*>) :: CF g a -> CF g b -> CF g b #

(<*) :: CF g a -> CF g b -> CF g a #

Gram_RuleEBNF g => Gram_RuleEBNF (CF g) Source # 

Methods

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

argEBNF :: Text -> CF g a Source #

Gram_Rule g => Gram_Rule (CF g) Source # 

Methods

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

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

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

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

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

Gram_Terminal g => Gram_Terminal (CF g) 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 #

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 #

Gram_Try g => Gram_Try (CF g) Source # 

Methods

try :: CF g a -> CF g 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_Comment g => Gram_Comment (CF g) Source # 

Methods

commentable :: CF g () -> CF g () -> CF g () -> CF g () Source #

comment_line :: CF (CF g) String -> CF (CF g) String Source #

comment_block :: CF (CF g) String -> Reg lr (CF g) String -> CF (CF g) String Source #

lexeme :: CF (CF g) a -> CF (CF g) a Source #

parens :: CF (CF g) a -> CF (CF g) a Source #

symbol :: String -> CF (CF g) String Source #

Gram_AltApp g => Gram_AltApp (CF g) Source # 

Methods

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

optional :: CF g a -> CF g (Maybe a) Source #

manyFoldL :: b -> (a -> b -> b) -> CF g a -> CF g b Source #

someFoldL :: b -> (a -> b -> b) -> CF g a -> CF g b Source #

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

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

manySkip :: CF g a -> CF g () Source #

someSkip :: CF g a -> CF g () Source #

inside :: (in_ -> next) -> CF (CF g) begin -> CF (CF g) in_ -> CF (CF g) end -> CF (CF g) next -> CF (CF g) next Source #

Gram_App g => Gram_App (CF g) Source # 

Methods

between :: CF g open -> CF g close -> CF g a -> CF g a Source #

Gram_CF g => Gram_CF (CF g) Source # 

Methods

(<&) :: CF (CF g) (a -> b) -> Reg lr (CF g) a -> CF (CF g) b Source #

(&>) :: Reg lr (CF g) (a -> b) -> CF (CF g) a -> CF (CF g) b Source #

minus :: CF (CF g) a -> Reg lr (CF g) b -> CF (CF g) a Source #

Gram_Op g => Gram_Op (CF g) Source # 

Methods

operators :: CF (CF g) a -> CF (CF g) (Unifix, a -> a) -> CF (CF g) (Infix, a -> a -> a) -> CF (CF g) (Unifix, a -> a) -> CF (CF g) (Either Error_Fixity a) Source #

infixrG :: CF (CF g) a -> CF (CF g) (a -> a -> a) -> CF (CF g) a Source #

infixlG :: CF (CF g) a -> CF (CF g) (a -> a -> a) -> CF (CF g) a Source #

IsString (g a) => IsString (CF g a) Source # 

Methods

fromString :: String -> CF g a #

class ContextFreeOf gram where Source #

Minimal complete definition

cfOf

Methods

cfOf :: gram g a -> CF g a Source #

Instances

ContextFreeOf Terminal Source # 

Methods

cfOf :: Terminal g a -> CF g a Source #

ContextFreeOf (Reg lr) Source # 

Methods

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

Class Gram_CF

class Gram_CF g where Source #

Symantics for context-free grammars.

Minimal complete definition

(<&), (&>), minus

Methods

(<&) :: CF g (a -> b) -> Reg lr g a -> CF g b infixl 4 Source #

NOTE: CFL ∩ RL is a CFL. See ISBN 81-7808-347-7, Theorem 7.27, p.286

(&>) :: Reg lr g (a -> b) -> CF g a -> CF g b infixl 4 Source #

minus :: CF g a -> Reg lr g b -> CF g a Source #

NOTE: CFL - RL is a CFL. See ISBN 81-7808-347-7, Theorem 7.29, p.289

Instances

Gram_CF RuleEBNF Source # 

Methods

(<&) :: CF RuleEBNF (a -> b) -> Reg lr RuleEBNF a -> CF RuleEBNF b Source #

(&>) :: Reg lr RuleEBNF (a -> b) -> CF RuleEBNF a -> CF RuleEBNF b Source #

minus :: CF RuleEBNF a -> Reg lr RuleEBNF b -> CF RuleEBNF a Source #

Gram_CF EBNF Source # 

Methods

(<&) :: CF EBNF (a -> b) -> Reg lr EBNF a -> CF EBNF b Source #

(&>) :: Reg lr EBNF (a -> b) -> CF EBNF a -> CF EBNF b Source #

minus :: CF EBNF a -> Reg lr EBNF b -> CF EBNF a Source #

Gram_CF g => Gram_CF (CF g) Source # 

Methods

(<&) :: CF (CF g) (a -> b) -> Reg lr (CF g) a -> CF (CF g) b Source #

(&>) :: Reg lr (CF g) (a -> b) -> CF (CF g) a -> CF (CF g) b Source #

minus :: CF (CF g) a -> Reg lr (CF g) b -> CF (CF g) a Source #

Class Gram_App

class Applicative g => Gram_App g where Source #

Methods

between :: g open -> g close -> g a -> g a Source #

Instances

Gram_App RuleEBNF Source # 

Methods

between :: RuleEBNF open -> RuleEBNF close -> RuleEBNF a -> RuleEBNF a Source #

Gram_App EBNF Source # 

Methods

between :: EBNF open -> EBNF close -> EBNF a -> EBNF a Source #

Gram_App g => Gram_App (CF g) Source # 

Methods

between :: CF g open -> CF g close -> CF g a -> CF g a Source #

Class Gram_AltApp

class (Gram_Alt g, Gram_App g) => Gram_AltApp g where Source #

Symantics when Gram_Alt and Gram_App are allowed by the grammar.

Methods

option :: a -> g a -> g a Source #

optional :: g a -> g (Maybe a) Source #

manyFoldL :: b -> (a -> b -> b) -> g a -> g b Source #

someFoldL :: b -> (a -> b -> b) -> g a -> g b Source #

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

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

manySkip :: g a -> g () Source #

someSkip :: g a -> g () Source #

inside :: (in_ -> next) -> CF g begin -> CF g in_ -> CF g end -> CF g next -> CF g next Source #

Instances

Gram_AltApp RuleEBNF Source # 

Methods

option :: a -> RuleEBNF a -> RuleEBNF a Source #

optional :: RuleEBNF a -> RuleEBNF (Maybe a) Source #

manyFoldL :: b -> (a -> b -> b) -> RuleEBNF a -> RuleEBNF b Source #

someFoldL :: b -> (a -> b -> b) -> RuleEBNF a -> RuleEBNF b Source #

many :: RuleEBNF a -> RuleEBNF [a] Source #

some :: RuleEBNF a -> RuleEBNF [a] Source #

manySkip :: RuleEBNF a -> RuleEBNF () Source #

someSkip :: RuleEBNF a -> RuleEBNF () Source #

inside :: (in_ -> next) -> CF RuleEBNF begin -> CF RuleEBNF in_ -> CF RuleEBNF end -> CF RuleEBNF next -> CF RuleEBNF next Source #

Gram_AltApp EBNF Source # 

Methods

option :: a -> EBNF a -> EBNF a Source #

optional :: EBNF a -> EBNF (Maybe a) Source #

manyFoldL :: b -> (a -> b -> b) -> EBNF a -> EBNF b Source #

someFoldL :: b -> (a -> b -> b) -> EBNF a -> EBNF b Source #

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

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

manySkip :: EBNF a -> EBNF () Source #

someSkip :: EBNF a -> EBNF () Source #

inside :: (in_ -> next) -> CF EBNF begin -> CF EBNF in_ -> CF EBNF end -> CF EBNF next -> CF EBNF next Source #

Gram_AltApp g => Gram_AltApp (CF g) Source # 

Methods

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

optional :: CF g a -> CF g (Maybe a) Source #

manyFoldL :: b -> (a -> b -> b) -> CF g a -> CF g b Source #

someFoldL :: b -> (a -> b -> b) -> CF g a -> CF g b Source #

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

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

manySkip :: CF g a -> CF g () Source #

someSkip :: CF g a -> CF g () Source #

inside :: (in_ -> next) -> CF (CF g) begin -> CF (CF g) in_ -> CF (CF g) end -> CF (CF g) next -> CF (CF g) next Source #

Class Gram_Comment

class (Gram_Terminal g, Gram_Rule g, Gram_Alt g, Gram_App g, Gram_AltApp g, Gram_CF g) => Gram_Comment g where Source #

Symantics for handling comments after each lexeme.

Methods

commentable :: g () -> g () -> g () -> g () Source #

comment_line :: CF g String -> CF g String Source #

comment_block :: CF g String -> Reg lr g String -> CF g String Source #

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

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

symbol :: String -> CF g String Source #

gram_comment :: forall g. (Gram_Comment g, Gram_RuleEBNF g) => [CF g ()] Source #