Stability | experimental |
---|---|
Safe Haskell | None |
Language | Haskell2010 |
Language.Egison.Parser.Pattern
Contents
Description
A parser for Egison patterns.
Synopsis
- parseExpr :: (Source s, MonadError (Errors s) m) => ParseMode n v e s -> s -> m (Expr n v e)
- parseExprL :: forall m s n v e. (Source s, MonadError (Errors s) m) => ParseMode n v e s -> s -> m (ExprL n v e)
- data Fixity n = Fixity {
- associativity :: Associativity
- precedence :: Precedence
- symbol :: n
- data Location = Location {}
- type Errors s = NonEmpty (Error s)
- data Position = Position {}
- class IsToken c where
- isSpace :: c -> Bool
- newline :: c
- parenLeft :: c
- parenRight :: c
- underscore :: c
- hash :: c
- question :: c
- exclamation :: c
- and :: c
- vertical :: c
- dollar :: c
- bracketLeft :: c
- bracketRight :: c
- comma :: c
- data Associativity
- type Token s = Token s
- type Tokens s = Tokens s
- data ErrorItem s
- = Tokens (Tokens s)
- | Label String
- | EndOfInput
- data Error s
- class Source s => Parsable a s mode where
- parse :: MonadError (Errors s) m => mode -> s -> m a
- parseWithLocation :: MonadError (Errors s) m => mode -> s -> m (Cofree (Base a) Location)
- parseNonGreedy :: MonadError (Errors s) m => mode -> s -> m (a, s)
- parseNonGreedyWithLocation :: MonadError (Errors s) m => mode -> s -> m (Cofree (Base a) Location, s)
- newtype Precedence = Precedence Int
- class (TraversableStream s, IsToken (Token s)) => Source s
- type ExtParser s a = Tokens s -> Either String a
- data ParseMode n v e s = ParseMode {
- filename :: FilePath
- fixities :: [ParseFixity n s]
- blockComment :: Maybe (Tokens s, Tokens s)
- lineComment :: Maybe (Tokens s)
- varNameParser :: ExtParser s v
- nameParser :: ExtParser s n
- valueExprParser :: ExtParser s e
- data ParseFixity n s = ParseFixity {}
- type ExprL n v e = Cofree (ExprF n v e) Location
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.
Fixity of infix operators.
Constructors
Fixity | |
Fields
|
Location, a range of positions in source code.
Instances
Data Location Source # | |||||
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 # | |||||
Generic Location Source # | |||||
Defined in Language.Egison.Parser.Pattern.Prim.Location Associated Types
| |||||
Show Location Source # | |||||
Eq Location Source # | |||||
type Rep Location Source # | |||||
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-10VR46D4phTIwhGxwo1f2J" 'False) (C1 ('MetaCons "Location" 'PrefixI 'True) (S1 ('MetaSel ('Just "begin") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Position) :*: S1 ('MetaSel ('Just "end") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Position))) |
Position in source code.
Instances
Data Position Source # | |||||
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 # | |||||
Generic Position Source # | |||||
Defined in Language.Egison.Parser.Pattern.Prim.Location Associated Types
| |||||
Show Position Source # | |||||
Eq Position Source # | |||||
type Rep Position Source # | |||||
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-10VR46D4phTIwhGxwo1f2J" '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 IsToken c where Source #
Provide a set of tokens needed to parse pattern expressions.
Methods
parenRight :: c Source #
underscore :: c Source #
exclamation :: c Source #
bracketLeft :: c Source #
bracketRight :: c Source #
Instances
IsToken Char Source # | |
Defined in Language.Egison.Parser.Pattern.Token Methods isSpace :: Char -> Bool Source # parenRight :: Char Source # underscore :: Char Source # exclamation :: Char Source # bracketLeft :: Char Source # bracketRight :: Char Source # |
data Associativity Source #
Associativity of infix operators.
Constructors
AssocLeft | |
AssocRight | |
AssocNone |
Instances
Data Associativity Source # | |||||
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 # | |||||
Generic Associativity Source # | |||||
Defined in Language.Egison.Syntax.Pattern.Fixity.Associativity Associated Types
| |||||
Show Associativity Source # | |||||
Defined in Language.Egison.Syntax.Pattern.Fixity.Associativity Methods showsPrec :: Int -> Associativity -> ShowS # show :: Associativity -> String # showList :: [Associativity] -> ShowS # | |||||
Eq Associativity Source # | |||||
Defined in Language.Egison.Syntax.Pattern.Fixity.Associativity Methods (==) :: Associativity -> Associativity -> Bool # (/=) :: Associativity -> Associativity -> Bool # | |||||
type Rep Associativity Source # | |||||
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-10VR46D4phTIwhGxwo1f2J" '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))) |
Token representation in Error
.
Constructors
Tokens (Tokens s) | |
Label String | |
EndOfInput |
Parse error.
Constructors
UnexpectedToken | |
ExternalError | |
UnexpectedEndOfFile | |
class Source s => Parsable a s mode where Source #
Type class providing functions for parsing.
Minimal complete definition
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
Source s => Parsable (Expr n v e) s (ParseMode n v e s) Source # | |
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 # |
newtype Precedence Source #
A precedence of infix operators.
Constructors
Precedence Int |
Instances
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 ExtParser s a = Tokens s -> Either String a Source #
is a type for externally provided parser of ExtParser
s aa
.
data ParseMode n v e s Source #
Parser configuration.
Constructors
ParseMode | |
Fields
|
Instances
Source s => Parsable (Expr n v e) s (ParseMode n v e s) Source # | |
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 # |
Orphan instances
Source s => Parsable (Expr n v e) s (ParseMode n v e s) Source # | |
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 # |