ptera-0.1.0.0: A parser generator
Safe HaskellNone
LanguageHaskell2010

Language.Parser.Ptera

Synopsis

Documentation

class HasField (x :: k) r a | x r -> a where #

Constraint representing the fact that the field x belongs to the record type r and has field type a. This will be solved automatically, but manual instances may be provided as well.

Methods

getField :: r -> a #

Selector function to extract the field from the record.

data HFList (a :: k -> Type) (b :: [k]) where #

Constructors

HFNil :: forall k (a :: k -> Type). HFList a ('[] :: [k]) 
HFCons :: forall k (a :: k -> Type) (x :: k) (xs :: [k]). a x -> HFList a xs -> HFList a (x ': xs) 

data DictF (a :: k -> Constraint) (b :: k) where #

Constructors

DictF :: forall k (a :: k -> Constraint) (b :: k). a b => DictF a b 

class TokensMember tokens t where Source #

Methods

tokensMembership :: Proxy# '(tokens, t) -> Membership (TokensTag tokens) t Source #

data Expr rules tokens elem us Source #

class Rules rules where Source #

Methods

generateRules :: T (DictF (HasRuleExprField rules)) (RulesTag rules) Source #

class MemberInitials rules initials where Source #

Methods

memberInitials :: T (DictF (HasRuleExprField rules)) initials Source #

class (KnownSymbol v, HasField v rules (RuleExprType rules (RuleExprReturnType rules v))) => HasRuleExprField rules v where Source #

Minimal complete definition

Nothing

Associated Types

type RuleExprReturnType rules v :: Type Source #

Methods

nonTerminalName :: rules -> proxy v -> String Source #

class GrammarToken tokens elem where Source #

Methods

tokenToTerminal :: Proxy tokens -> elem -> T (TokensTag tokens) Source #

type family RuleExprType (rules :: Type) :: Type -> Type Source #

type family RulesTag (rules :: Type) :: [Symbol] Source #

type family TokensTag (tokens :: Type) :: [Symbol] Source #

fixGrammar :: forall initials action rules tokens elem. MemberInitials rules initials => Rules rules => RuleExprType rules ~ RuleExpr action rules tokens elem => rules -> Grammar action rules tokens elem initials Source #

ruleExpr :: [Alt action rules tokens elem a] -> RuleExpr action rules tokens elem a Source #

(<^>) :: Expr rules tokens elem us1 -> Expr rules tokens elem us2 -> Expr rules tokens elem (Concat us1 us2) infixr 5 Source #

var :: KnownSymbol v => proxy v -> Expr rules tokens elem '[RuleExprReturnType rules v] Source #

varA :: forall v rules tokens elem. KnownSymbol v => Expr rules tokens elem '[RuleExprReturnType rules v] Source #

tok :: Membership (TokensTag tokens) t -> Expr rules tokens elem '[elem] Source #

tokA :: forall t rules tokens elem. TokensMember tokens t => Expr rules tokens elem '[elem] Source #

data ActionTaskResult ctx a Source #

Instances

Instances details
Functor (ActionTaskResult ctx) Source # 
Instance details

Defined in Language.Parser.Ptera.Syntax

Methods

fmap :: (a -> b) -> ActionTaskResult ctx a -> ActionTaskResult ctx b #

(<$) :: a -> ActionTaskResult ctx b -> ActionTaskResult ctx a #

(Eq a, Eq ctx) => Eq (ActionTaskResult ctx a) Source # 
Instance details

Defined in Language.Parser.Ptera.Syntax

Methods

(==) :: ActionTaskResult ctx a -> ActionTaskResult ctx a -> Bool #

(/=) :: ActionTaskResult ctx a -> ActionTaskResult ctx a -> Bool #

(Show a, Show ctx) => Show (ActionTaskResult ctx a) Source # 
Instance details

Defined in Language.Parser.Ptera.Syntax

newtype ActionTask ctx a Source #

Constructors

ActionTask 

Fields

Instances

Instances details
Monad (ActionTask ctx) Source # 
Instance details

Defined in Language.Parser.Ptera.Syntax

Methods

(>>=) :: ActionTask ctx a -> (a -> ActionTask ctx b) -> ActionTask ctx b #

(>>) :: ActionTask ctx a -> ActionTask ctx b -> ActionTask ctx b #

return :: a -> ActionTask ctx a #

Functor (ActionTask ctx) Source # 
Instance details

Defined in Language.Parser.Ptera.Syntax

Methods

fmap :: (a -> b) -> ActionTask ctx a -> ActionTask ctx b #

(<$) :: a -> ActionTask ctx b -> ActionTask ctx a #

Applicative (ActionTask ctx) Source # 
Instance details

Defined in Language.Parser.Ptera.Syntax

Methods

pure :: a -> ActionTask ctx a #

(<*>) :: ActionTask ctx (a -> b) -> ActionTask ctx a -> ActionTask ctx b #

liftA2 :: (a -> b -> c) -> ActionTask ctx a -> ActionTask ctx b -> ActionTask ctx c #

(*>) :: ActionTask ctx a -> ActionTask ctx b -> ActionTask ctx b #

(<*) :: ActionTask ctx a -> ActionTask ctx b -> ActionTask ctx a #

newtype SemActM ctx us a Source #

Constructors

SemActM 

Fields

Instances

Instances details
Functor (SemActM ctx us) Source # 
Instance details

Defined in Language.Parser.Ptera.Syntax

Methods

fmap :: (a -> b) -> SemActM ctx us a -> SemActM ctx us b #

(<$) :: a -> SemActM ctx us b -> SemActM ctx us a #

type Alt = AltM () Source #

type AltM ctx = Alt (SemActM ctx) Source #

type RuleExprM ctx = RuleExpr (SemActM ctx) Source #

type GrammarM ctx = Grammar (SemActM ctx) Source #

pattern (:*) :: u -> HList us -> HList (u ': us) infixr 6 Source #

pattern HNil :: HList '[] Source #

(<:>) :: Expr rules tokens elem us -> (HList us -> a) -> AltM ctx rules tokens elem a infixl 4 Source #

eps :: (HList '[] -> a) -> AltM ctx rules tokens elem a Source #

(<::>) :: Expr rules tokens elem us -> (HList us -> ActionTask ctx a) -> AltM ctx rules tokens elem a infixl 4 Source #

epsM :: (HList '[] -> ActionTask ctx a) -> AltM ctx rules tokens elem a Source #

modifyAction :: (ctx -> ctx) -> ActionTask ctx () Source #

data ParseResult posMark altHelp a Source #

Constructors

Parsed a 
ParseFailed posMark (FailedReason altHelp) 

Instances

Instances details
Functor (ParseResult posMark altHelp) Source # 
Instance details

Defined in Language.Parser.Ptera.Runner.RunT

Methods

fmap :: (a -> b) -> ParseResult posMark altHelp a -> ParseResult posMark altHelp b #

(<$) :: a -> ParseResult posMark altHelp b -> ParseResult posMark altHelp a #

(Show a, Show posMark, Show altHelp) => Show (ParseResult posMark altHelp a) Source # 
Instance details

Defined in Language.Parser.Ptera.Runner.RunT

Methods

showsPrec :: Int -> ParseResult posMark altHelp a -> ShowS #

show :: ParseResult posMark altHelp a -> String #

showList :: [ParseResult posMark altHelp a] -> ShowS #

type Result posMark = ParseResult posMark () Source #

runParser :: forall v initials posMark m rules elem proxy. Member initials v => T posMark elem m => proxy v -> Runner rules elem initials -> m (Result posMark (RuleExprReturnType rules v)) Source #

newtype ListScanner e a Source #

Constructors

ListScanner 

Fields

Instances

Instances details
Monad (ListScanner e) Source # 
Instance details

Defined in Language.Parser.Ptera.Scanner

Methods

(>>=) :: ListScanner e a -> (a -> ListScanner e b) -> ListScanner e b #

(>>) :: ListScanner e a -> ListScanner e b -> ListScanner e b #

return :: a -> ListScanner e a #

Functor (ListScanner e) Source # 
Instance details

Defined in Language.Parser.Ptera.Scanner

Methods

fmap :: (a -> b) -> ListScanner e a -> ListScanner e b #

(<$) :: a -> ListScanner e b -> ListScanner e a #

Applicative (ListScanner e) Source # 
Instance details

Defined in Language.Parser.Ptera.Scanner

Methods

pure :: a -> ListScanner e a #

(<*>) :: ListScanner e (a -> b) -> ListScanner e a -> ListScanner e b #

liftA2 :: (a -> b -> c) -> ListScanner e a -> ListScanner e b -> ListScanner e c #

(*>) :: ListScanner e a -> ListScanner e b -> ListScanner e b #

(<*) :: ListScanner e a -> ListScanner e b -> ListScanner e a #

Scanner [e] e (ListScanner e) Source # 
Instance details

Defined in Language.Parser.Ptera.Scanner

data ScanMode posMark Source #

Constructors

ScanModeNoBack 
ScanModeNeedBack posMark 

Instances

Instances details
Eq posMark => Eq (ScanMode posMark) Source # 
Instance details

Defined in Language.Parser.Ptera.Scanner

Methods

(==) :: ScanMode posMark -> ScanMode posMark -> Bool #

(/=) :: ScanMode posMark -> ScanMode posMark -> Bool #

Show posMark => Show (ScanMode posMark) Source # 
Instance details

Defined in Language.Parser.Ptera.Scanner

Methods

showsPrec :: Int -> ScanMode posMark -> ShowS #

show :: ScanMode posMark -> String #

showList :: [ScanMode posMark] -> ShowS #

class Monad m => Scanner posMark elem m | m -> posMark, m -> elem where Source #

Methods

consumeInput :: m (Maybe elem) Source #

getPosMark :: m posMark Source #

seekToPosMark :: posMark -> m () Source #

scanMode :: ScanMode posMark -> m () Source #

Instances

Instances details
Scanner [e] e (ListScanner e) Source # 
Instance details

Defined in Language.Parser.Ptera.Scanner

runListScanner :: ListScanner e a -> [e] -> a Source #

type Parser = T Source #

genRunner :: GrammarToken tokens elem => GrammarM ctx rules tokens elem initials -> Either [StringLit] (Parser ctx rules elem initials) Source #