egison-pattern-src-0.2.1.2: Manipulating Egison patterns: abstract syntax, parser, and pretty-printer
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Language.Egison.Parser.Pattern

Description

A parser for Egison patterns.

Synopsis

Documentation

parseExpr :: (Source s, MonadError (Errors s) m) => ParseMode n v e s -> s -> m (Expr n v e) Source #

Parse Expr.

parseExprL :: forall m s n v e. (Source s, MonadError (Errors s) m) => ParseMode n v e s -> s -> m (ExprL n v e) Source #

Parse Expr with locations annotated.

data Location Source #

Location, a range of positions in source code.

Constructors

Location 

Fields

Instances

Instances details
Eq Location Source # 
Instance details

Defined in Language.Egison.Parser.Pattern.Prim.Location

Data Location Source # 
Instance details

Defined in Language.Egison.Parser.Pattern.Prim.Location

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Location -> c Location #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Location #

toConstr :: Location -> Constr #

dataTypeOf :: Location -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Location) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Location) #

gmapT :: (forall b. Data b => b -> b) -> Location -> Location #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Location -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Location -> r #

gmapQ :: (forall d. Data d => d -> u) -> Location -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Location -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Location -> m Location #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Location -> m Location #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Location -> m Location #

Show Location Source # 
Instance details

Defined in Language.Egison.Parser.Pattern.Prim.Location

Generic Location Source # 
Instance details

Defined in Language.Egison.Parser.Pattern.Prim.Location

Associated Types

type Rep Location :: Type -> Type #

Methods

from :: Location -> Rep Location x #

to :: Rep Location x -> Location #

type Rep Location Source # 
Instance details

Defined in Language.Egison.Parser.Pattern.Prim.Location

type Rep Location = D1 ('MetaData "Location" "Language.Egison.Parser.Pattern.Prim.Location" "egison-pattern-src-0.2.1.2-1Qi6jwrQLCI3G9sPNSOjGo" 'False) (C1 ('MetaCons "Location" 'PrefixI 'True) (S1 ('MetaSel ('Just "begin") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Position) :*: S1 ('MetaSel ('Just "end") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Position)))

data Position Source #

Position in source code.

Constructors

Position 

Fields

Instances

Instances details
Eq Position Source # 
Instance details

Defined in Language.Egison.Parser.Pattern.Prim.Location

Data Position Source # 
Instance details

Defined in Language.Egison.Parser.Pattern.Prim.Location

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Position -> c Position #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Position #

toConstr :: Position -> Constr #

dataTypeOf :: Position -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Position) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Position) #

gmapT :: (forall b. Data b => b -> b) -> Position -> Position #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Position -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Position -> r #

gmapQ :: (forall d. Data d => d -> u) -> Position -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Position -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Position -> m Position #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Position -> m Position #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Position -> m Position #

Show Position Source # 
Instance details

Defined in Language.Egison.Parser.Pattern.Prim.Location

Generic Position Source # 
Instance details

Defined in Language.Egison.Parser.Pattern.Prim.Location

Associated Types

type Rep Position :: Type -> Type #

Methods

from :: Position -> Rep Position x #

to :: Rep Position x -> Position #

type Rep Position Source # 
Instance details

Defined in Language.Egison.Parser.Pattern.Prim.Location

type Rep Position = D1 ('MetaData "Position" "Language.Egison.Parser.Pattern.Prim.Location" "egison-pattern-src-0.2.1.2-1Qi6jwrQLCI3G9sPNSOjGo" 'False) (C1 ('MetaCons "Position" 'PrefixI 'True) (S1 ('MetaSel ('Just "line") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: S1 ('MetaSel ('Just "column") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)))

class (TraversableStream s, IsToken (Token s)) => Source s Source #

Constraint for the source of parser. TODO: Hide these methods in haddock (see haskell/haddock#330)

Minimal complete definition

eof, tokens, consTokens, snocTokens

type Tokens s = Tokens s Source #

Type of tokens in the source.

type Token s = Token s Source #

Type of token in the source.

type Errors s = NonEmpty (Error s) Source #

Type synonym for an error list.

data Error s Source #

Parse error.

Instances

Instances details
Eq (Tokens s) => Eq (Error s) Source # 
Instance details

Defined in Language.Egison.Parser.Pattern.Prim.Error

Methods

(==) :: Error s -> Error s -> Bool #

(/=) :: Error s -> Error s -> Bool #

Show (Tokens s) => Show (Error s) Source # 
Instance details

Defined in Language.Egison.Parser.Pattern.Prim.Error

Methods

showsPrec :: Int -> Error s -> ShowS #

show :: Error s -> String #

showList :: [Error s] -> ShowS #

data ErrorItem s Source #

Token representation in Error.

Constructors

Tokens (Tokens s) 
Label String 
EndOfInput 

Instances

Instances details
Eq (Tokens s) => Eq (ErrorItem s) Source # 
Instance details

Defined in Language.Egison.Parser.Pattern.Prim.Error

Methods

(==) :: ErrorItem s -> ErrorItem s -> Bool #

(/=) :: ErrorItem s -> ErrorItem s -> Bool #

Show (Tokens s) => Show (ErrorItem s) Source # 
Instance details

Defined in Language.Egison.Parser.Pattern.Prim.Error

class Source s => Parsable a s mode where Source #

Type class providing functions for parsing.

Minimal complete definition

parseNonGreedyWithLocation

Methods

parse :: MonadError (Errors s) m => mode -> s -> m a Source #

Parse a source stream.

default parse :: (Recursive a, Corecursive a, MonadError (Errors s) m) => mode -> s -> m a Source #

parseWithLocation :: MonadError (Errors s) m => mode -> s -> m (Cofree (Base a) Location) Source #

Parse a source stream with location annotations.

parseNonGreedy :: MonadError (Errors s) m => mode -> s -> m (a, s) Source #

Parse a source stream non-greedily. That is, this parser will only consume the input until a is fully parsed, and return the rest of the input.

default parseNonGreedy :: (Recursive a, Corecursive a, MonadError (Errors s) m) => mode -> s -> m (a, s) Source #

parseNonGreedyWithLocation :: MonadError (Errors s) m => mode -> s -> m (Cofree (Base a) Location, s) Source #

Parse a source stream non-greedily with location annotations.

Instances

Instances details
Source s => Parsable (Expr n v e) s (ParseMode n v e s) Source # 
Instance details

Defined in Language.Egison.Parser.Pattern

Methods

parse :: MonadError (Errors s) m => ParseMode n v e s -> s -> m (Expr n v e) Source #

parseWithLocation :: MonadError (Errors s) m => ParseMode n v e s -> s -> m (Cofree (Base (Expr n v e)) Location) Source #

parseNonGreedy :: MonadError (Errors s) m => ParseMode n v e s -> s -> m (Expr n v e, s) Source #

parseNonGreedyWithLocation :: MonadError (Errors s) m => ParseMode n v e s -> s -> m (Cofree (Base (Expr n v e)) Location, s) Source #

data Associativity Source #

Associativity of infix operators.

Instances

Instances details
Eq Associativity Source # 
Instance details

Defined in Language.Egison.Syntax.Pattern.Fixity.Associativity

Data Associativity Source # 
Instance details

Defined in Language.Egison.Syntax.Pattern.Fixity.Associativity

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Associativity -> c Associativity #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Associativity #

toConstr :: Associativity -> Constr #

dataTypeOf :: Associativity -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Associativity) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Associativity) #

gmapT :: (forall b. Data b => b -> b) -> Associativity -> Associativity #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Associativity -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Associativity -> r #

gmapQ :: (forall d. Data d => d -> u) -> Associativity -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Associativity -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Associativity -> m Associativity #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Associativity -> m Associativity #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Associativity -> m Associativity #

Show Associativity Source # 
Instance details

Defined in Language.Egison.Syntax.Pattern.Fixity.Associativity

Generic Associativity Source # 
Instance details

Defined in Language.Egison.Syntax.Pattern.Fixity.Associativity

Associated Types

type Rep Associativity :: Type -> Type #

type Rep Associativity Source # 
Instance details

Defined in Language.Egison.Syntax.Pattern.Fixity.Associativity

type Rep Associativity = D1 ('MetaData "Associativity" "Language.Egison.Syntax.Pattern.Fixity.Associativity" "egison-pattern-src-0.2.1.2-1Qi6jwrQLCI3G9sPNSOjGo" 'False) (C1 ('MetaCons "AssocLeft" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "AssocRight" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "AssocNone" 'PrefixI 'False) (U1 :: Type -> Type)))

newtype Precedence Source #

A precedence of infix operators.

Constructors

Precedence Int 

Instances

Instances details
Eq Precedence Source # 
Instance details

Defined in Language.Egison.Syntax.Pattern.Fixity.Precedence

Data Precedence Source # 
Instance details

Defined in Language.Egison.Syntax.Pattern.Fixity.Precedence

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Precedence -> c Precedence #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Precedence #

toConstr :: Precedence -> Constr #

dataTypeOf :: Precedence -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Precedence) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Precedence) #

gmapT :: (forall b. Data b => b -> b) -> Precedence -> Precedence #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Precedence -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Precedence -> r #

gmapQ :: (forall d. Data d => d -> u) -> Precedence -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Precedence -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Precedence -> m Precedence #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Precedence -> m Precedence #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Precedence -> m Precedence #

Ord Precedence Source # 
Instance details

Defined in Language.Egison.Syntax.Pattern.Fixity.Precedence

Show Precedence Source # 
Instance details

Defined in Language.Egison.Syntax.Pattern.Fixity.Precedence

Generic Precedence Source # 
Instance details

Defined in Language.Egison.Syntax.Pattern.Fixity.Precedence

Associated Types

type Rep Precedence :: Type -> Type #

type Rep Precedence Source # 
Instance details

Defined in Language.Egison.Syntax.Pattern.Fixity.Precedence

type Rep Precedence = D1 ('MetaData "Precedence" "Language.Egison.Syntax.Pattern.Fixity.Precedence" "egison-pattern-src-0.2.1.2-1Qi6jwrQLCI3G9sPNSOjGo" 'True) (C1 ('MetaCons "Precedence" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)))

data Fixity n Source #

Fixity of infix operators.

Constructors

Fixity 

data ParseMode n v e s Source #

Parser configuration.

Instances

Instances details
Source s => Parsable (Expr n v e) s (ParseMode n v e s) Source # 
Instance details

Defined in Language.Egison.Parser.Pattern

Methods

parse :: MonadError (Errors s) m => ParseMode n v e s -> s -> m (Expr n v e) Source #

parseWithLocation :: MonadError (Errors s) m => ParseMode n v e s -> s -> m (Cofree (Base (Expr n v e)) Location) Source #

parseNonGreedy :: MonadError (Errors s) m => ParseMode n v e s -> s -> m (Expr n v e, s) Source #

parseNonGreedyWithLocation :: MonadError (Errors s) m => ParseMode n v e s -> s -> m (Cofree (Base (Expr n v e)) Location, s) Source #

data ParseFixity n s Source #

Fixity of infix operators.

Constructors

ParseFixity 

Fields

type ExtParser s a = Tokens s -> Either String a Source #

ExtParser s a is a type for externally provided parser of a.

type ExprL n v e = Cofree (ExprF n v e) Location Source #

Expr with locations annotated.

Orphan instances

Source s => Parsable (Expr n v e) s (ParseMode n v e s) Source # 
Instance details

Methods

parse :: MonadError (Errors s) m => ParseMode n v e s -> s -> m (Expr n v e) Source #

parseWithLocation :: MonadError (Errors s) m => ParseMode n v e s -> s -> m (Cofree (Base (Expr n v e)) Location) Source #

parseNonGreedy :: MonadError (Errors s) m => ParseMode n v e s -> s -> m (Expr n v e, s) Source #

parseNonGreedyWithLocation :: MonadError (Errors s) m => ParseMode n v e s -> s -> m (Cofree (Base (Expr n v e)) Location, s) Source #