Stability | experimental |
---|---|
Safe Haskell | None |
Language | Haskell2010 |
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 Location = Location {}
- 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
- class (TraversableStream s, IsToken (Token s)) => Source s
- type Tokens s = Tokens s
- type Token s = Token s
- type Errors s = NonEmpty (Error s)
- data Error s
- data ErrorItem s
- = Tokens (Tokens s)
- | Label String
- | EndOfInput
- 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)
- data Associativity
- newtype Precedence = Precedence Int
- data Fixity n = Fixity {
- associativity :: Associativity
- precedence :: Precedence
- symbol :: n
- 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 ExtParser s a = Tokens s -> Either String a
- 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.
Location, a range of positions in source code.
Instances
Eq Location Source # | |
Data Location Source # | |
Defined in Language.Egison.Parser.Pattern.Prim.Location 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 # | |
Generic 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-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))) |
Position in source code.
Instances
Eq Position Source # | |
Data Position Source # | |
Defined in Language.Egison.Parser.Pattern.Prim.Location 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 # | |
Generic 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-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 IsToken c where Source #
Provide a set of tokens needed to parse pattern expressions.
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 isSpace :: Char -> Bool Source # parenRight :: Char Source # underscore :: Char Source # exclamation :: Char Source # bracketLeft :: Char Source # bracketRight :: Char Source # |
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)
eof, tokens, consTokens, snocTokens
Parse error.
Token representation in Error
.
class Source s => Parsable a s mode where Source #
Type class providing functions for parsing.
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 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
newtype Precedence Source #
A precedence of infix operators.
Instances
Fixity of infix operators.
Fixity | |
|
data ParseMode n v e s Source #
Parser configuration.
ParseMode | |
|
Instances
Source s => Parsable (Expr n v e) s (ParseMode n v e s) Source # | |
Defined in Language.Egison.Parser.Pattern 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 # |
type ExtParser s a = Tokens s -> Either String a Source #
is a type for externally provided parser of ExtParser
s aa
.
Orphan instances
Source s => Parsable (Expr n v e) s (ParseMode n v e s) Source # | |
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 # |