Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Language.Giml.Syntax.Parser
Description
Parsing Giml
Here's an example Giml program that we are going to parse:
type List a = | Nil {} | Cons { head : a, tail : List a } end def length(xs) := do case xs of | Nil {} -> 0 | Cons { head = _, tail = rest } -> do def res := add(1, length(rest)) res end end end def main() := do ffi("console.log", length(Cons { head = 1, tail = Cons { head = 2, tail = Nil {} } })) end
Synopsis
- data ReplResult a
- = ReplExpr (Expr Ann)
- | ReplDefinition (Definition Ann)
- | EarlyEOF a
- type Ann = SourcePos
- type ParseErr = ParseErrorBundle Text Void
- type Parser = Parsec Void Text
- getAnn :: Parser Ann
- runParser :: CompilePhase Text env b m => Parser a -> FilePath -> Text -> m a
- runParser' :: Parser a -> FilePath -> Text -> Either ParseErr a
- runReplParser :: FilePath -> Text -> Either ParseErr (ReplResult Text)
- parseREPL :: Parser (ReplResult ())
- replParseTermDef :: Parser (TermDef Ann)
- sc :: Parser ()
- lexeme :: Parser a -> Parser a
- newline :: Parser ()
- newlines :: Parser ()
- newlines1 :: Parser ()
- symbol :: Text -> Parser ()
- equals :: Parser ()
- arrow :: Parser ()
- backarrow :: Parser ()
- lambda :: Parser ()
- underscore :: Parser ()
- comma :: Parser ()
- bar :: Parser ()
- harddot :: Parser ()
- colon :: Parser ()
- between :: Char -> Char -> Parser a -> Parser a
- parens :: Parser a -> Parser a
- brackets :: Parser a -> Parser a
- braces :: Parser a -> Parser a
- stringLiteral :: Parser Text
- number :: Parser Lit
- reservedWords :: [Text]
- rword :: Text -> Parser Text
- reservedWord :: Parser (Int, Text)
- var :: Parser Text
- label :: Parser Text
- typevar :: Parser Text
- typename :: Parser Text
- lowername :: Parser Text
- uppername :: Parser Text
- name' :: Parser Char -> Parser Text
- withKeywordFail :: Parser a -> Parser a
- keywordFail :: Parser ()
- nameRest :: Parser Char
- parseFile :: Parser (ParsedFile Ann)
- parseDef :: Parser (Definition Ann)
- parseTypeDef :: Parser (Datatype Ann)
- parseType :: Parser Type
- parseType' :: Parser Type
- parseType'' :: Parser Type
- parseTermDef :: Parser (TermDef Ann)
- funArg :: Parser (Maybe Text)
- parseBlock :: Parser (Block Ann)
- parseStmt :: Parser (Statement Ann)
- parseExpr :: Parser (Expr Ann)
- parseExpr' :: Parser (Expr Ann)
- parseExpr'' :: Parser (Expr Ann)
- parseCaseOf :: Parser (Expr Ann)
- parsePatterns :: Parser [(Pattern, Expr Ann)]
- parsePattern :: Parser Pattern
- parseFfi :: Parser (Expr Ann)
- parseLambda :: Parser (Expr Ann)
- parseLit :: Parser Lit
- parseVariant :: Parser a -> Parser (Variant a)
- parseOpenVariant :: Parser a -> Parser (Variant a)
- parseRecord :: Parser () -> Parser a -> Maybe (Parser b) -> Parser (Record a, Maybe b)
- dummyAnn :: FilePath -> SourcePos
- ppErrors :: ParseErrorBundle Text Void -> Text
- data SourcePos = SourcePos {
- sourceName :: FilePath
- sourceLine :: !Pos
- sourceColumn :: !Pos
- unPos :: Pos -> Int
Documentation
data ReplResult a Source #
Constructors
ReplExpr (Expr Ann) | |
ReplDefinition (Definition Ann) | |
EarlyEOF a |
Instances
Show a => Show (ReplResult a) Source # | |
Defined in Language.Giml.Syntax.Parser Methods showsPrec :: Int -> ReplResult a -> ShowS # show :: ReplResult a -> String # showList :: [ReplResult a] -> ShowS # |
runParser :: CompilePhase Text env b m => Parser a -> FilePath -> Text -> m a Source #
Run a parse and prettyprint errors
runParser' :: Parser a -> FilePath -> Text -> Either ParseErr a Source #
Run a parse and preserve errors structure
runReplParser :: FilePath -> Text -> Either ParseErr (ReplResult Text) Source #
parseREPL :: Parser (ReplResult ()) Source #
underscore :: Parser () Source #
reservedWords :: [Text] Source #
withKeywordFail :: Parser a -> Parser a Source #
keywordFail :: Parser () Source #
parseType' :: Parser Type Source #
parseType'' :: Parser Type Source #
The data type SourcePos
represents source positions. It contains the
name of the source file, a line number, and a column number. Source line
and column positions change intensively during parsing, so we need to
make them strict to avoid memory leaks.
Constructors
SourcePos | |
Fields
|
Instances
Data SourcePos | |
Defined in Text.Megaparsec.Pos Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> SourcePos -> c SourcePos # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c SourcePos # toConstr :: SourcePos -> Constr # dataTypeOf :: SourcePos -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c SourcePos) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SourcePos) # gmapT :: (forall b. Data b => b -> b) -> SourcePos -> SourcePos # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SourcePos -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SourcePos -> r # gmapQ :: (forall d. Data d => d -> u) -> SourcePos -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> SourcePos -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> SourcePos -> m SourcePos # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> SourcePos -> m SourcePos # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> SourcePos -> m SourcePos # | |
Generic SourcePos | |
Read SourcePos | |
Show SourcePos | |
NFData SourcePos | |
Defined in Text.Megaparsec.Pos | |
Eq SourcePos | |
Ord SourcePos | |
Pretty SourcePos Source # | |
Defined in Language.Giml.Types.Infer.Types | |
type Rep SourcePos | |
Defined in Text.Megaparsec.Pos type Rep SourcePos = D1 ('MetaData "SourcePos" "Text.Megaparsec.Pos" "megaparsec-9.2.1-3mG6PJi4RKfH1aTzhLevhN" 'False) (C1 ('MetaCons "SourcePos" 'PrefixI 'True) (S1 ('MetaSel ('Just "sourceName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FilePath) :*: (S1 ('MetaSel ('Just "sourceLine") 'NoSourceUnpackedness 'SourceStrict 'DecidedUnpack) (Rec0 Pos) :*: S1 ('MetaSel ('Just "sourceColumn") 'NoSourceUnpackedness 'SourceStrict 'DecidedUnpack) (Rec0 Pos)))) |