symantic-grammar-0.2.0.20170709: Library for symantic grammars.

Safe HaskellNone
LanguageHaskell2010

Language.Symantic.Grammar.EBNF

Contents

Synopsis

Type EBNF

newtype EBNF a Source #

Extended Backus-Naur-Form, following the ISO-IEC-14977 notations, augmented with the following notations:

  • ("U+", code_point): for ISO-IEC-10646 (aka. Unicode).
  • (char, "…", char): for character range.
  • (rule, "&", rule): for the intersection.
  • (rule, "-", rule): for the difference.
  • (rule, " ", rule): for rule application.

Inherited attributes are:

  • RuleMode is the requested rendering mode of a Rule (body or reference).
  • Infix and Side are the properties of the parent operator, used to enclose the operand in parenthesis only when needed.

Synthetized attributes are:

Constructors

EBNF 

Fields

Instances

Functor EBNF Source # 

Methods

fmap :: (a -> b) -> EBNF a -> EBNF b #

(<$) :: a -> EBNF b -> EBNF a #

Applicative EBNF Source # 

Methods

pure :: a -> EBNF a #

(<*>) :: EBNF (a -> b) -> EBNF a -> EBNF b #

(*>) :: EBNF a -> EBNF b -> EBNF b #

(<*) :: EBNF a -> EBNF b -> EBNF a #

Gram_RuleEBNF EBNF Source # 

Methods

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

argEBNF :: Text -> EBNF a Source #

Gram_Rule EBNF Source # 

Methods

rule :: Text -> Rule (EBNF a) Source #

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

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

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

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

Gram_Terminal EBNF 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_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_Try EBNF Source # 

Methods

try :: EBNF a -> EBNF a Source #

Gram_Alt EBNF Source # 

Methods

empty :: EBNF a Source #

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

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

Gram_Comment EBNF 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_App EBNF Source # 

Methods

between :: EBNF open -> EBNF close -> EBNF a -> EBNF 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_Op EBNF Source # 

Methods

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

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

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

Gram_Error err EBNF Source # 

Methods

catch :: EBNF (Either err a) -> EBNF a Source #

Gram_State st EBNF Source # 

Methods

stateBefore :: EBNF (st -> (st, a)) -> EBNF a Source #

stateAfter :: EBNF (st -> (st, a)) -> EBNF a Source #

getBefore :: EBNF (st -> a) -> EBNF a Source #

getAfter :: EBNF (st -> a) -> EBNF a Source #

put :: EBNF (st, a) -> EBNF a Source #

Gram_Reader st EBNF Source # 

Methods

askBefore :: EBNF (st -> a) -> EBNF a Source #

askAfter :: EBNF (st -> a) -> EBNF a Source #

Show (EBNF a) Source # 

Methods

showsPrec :: Int -> EBNF a -> ShowS #

show :: EBNF a -> String #

showList :: [EBNF a] -> ShowS #

runEBNF :: EBNF a -> Text Source #

Get textual rendition of given EBNF.

renderEBNF :: RuleEBNF a -> Text Source #

Get textual rendition of given RuleEBNF.

ebnf_const :: Text -> EBNF a Source #

EBNF returns a constant rendition.

ebnf_arg :: EBNF a -> EBNF b -> EBNF () infixl 5 Source #

EBNF which adds an argument to be applied.

Type RuleMode

data RuleMode Source #

Constructors

RuleMode_Body

Request to generate the body of the rule.

RuleMode_Ref

Request to generate a reference to the rule.

Type Rule

type Rule a = a -> a Source #

Class Gram_Rule

class Gram_Rule g where Source #

Methods

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

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

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

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

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

Instances

Gram_Rule RuleEBNF Source # 
Gram_Rule EBNF Source # 

Methods

rule :: Text -> Rule (EBNF a) Source #

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

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

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

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

Gram_Rule g => Gram_Rule (Terminal g) Source # 

Methods

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

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

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

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

rule4 :: Text -> Rule (Terminal g a -> Terminal g b -> Terminal g c -> Terminal g d -> Terminal g e) 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_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 #

Type RuleEBNF

newtype RuleEBNF a Source #

Constructors

RuleEBNF 

Fields

Instances

Functor RuleEBNF Source # 

Methods

fmap :: (a -> b) -> RuleEBNF a -> RuleEBNF b #

(<$) :: a -> RuleEBNF b -> RuleEBNF a #

Applicative RuleEBNF Source # 

Methods

pure :: a -> RuleEBNF a #

(<*>) :: RuleEBNF (a -> b) -> RuleEBNF a -> RuleEBNF b #

(*>) :: RuleEBNF a -> RuleEBNF b -> RuleEBNF b #

(<*) :: RuleEBNF a -> RuleEBNF b -> RuleEBNF a #

Gram_RuleEBNF RuleEBNF Source # 
Gram_Rule RuleEBNF Source # 
Gram_Terminal RuleEBNF Source # 
Gram_RegL RuleEBNF Source # 
Gram_RegR RuleEBNF Source # 
Gram_Try RuleEBNF Source # 

Methods

try :: RuleEBNF a -> RuleEBNF a Source #

Gram_Alt RuleEBNF Source # 
Gram_Comment RuleEBNF Source # 
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_App RuleEBNF Source # 

Methods

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

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_Op RuleEBNF Source # 

Methods

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

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

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

Gram_Error err RuleEBNF Source # 

Methods

catch :: RuleEBNF (Either err a) -> RuleEBNF a Source #

Gram_State st RuleEBNF Source # 

Methods

stateBefore :: RuleEBNF (st -> (st, a)) -> RuleEBNF a Source #

stateAfter :: RuleEBNF (st -> (st, a)) -> RuleEBNF a Source #

getBefore :: RuleEBNF (st -> a) -> RuleEBNF a Source #

getAfter :: RuleEBNF (st -> a) -> RuleEBNF a Source #

put :: RuleEBNF (st, a) -> RuleEBNF a Source #

Gram_Reader st RuleEBNF Source # 

Methods

askBefore :: RuleEBNF (st -> a) -> RuleEBNF a Source #

askAfter :: RuleEBNF (st -> a) -> RuleEBNF a Source #

Class Gram_RuleEBNF

class Gram_RuleEBNF g where Source #

Symantics for rendering EBNF rules.

Minimal complete definition

ruleEBNF, argEBNF

Methods

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

argEBNF :: Text -> g a Source #