ddc-core-0.4.1.2: Disciplined Disciple Compiler core language and type checker.

Safe HaskellNone

DDC.Core.Parser

Contents

Description

Core language parser.

Synopsis

Documentation

type Parser n a = Parser (Tok n) aSource

A parser of core language tokens.

data Context Source

Configuration and information from the context. Used for context sensitive parsing.

contextOfProfile :: Profile n -> ContextSource

Slurp an initital Context from a language Profile.

Types

pType :: Ord n => Context -> Parser n (Type n)Source

Parse a type.

pTypeApp :: Ord n => Context -> Parser n (Type n)Source

Parse a type application.

pTypeAtom :: Ord n => Context -> Parser n (Type n)Source

Parse a variable, constructor or parenthesised type.

Modules

pModule :: (Ord n, Pretty n) => Context -> Parser n (Module SourcePos n)Source

Parse a core module.

pModuleName :: Pretty n => Parser n ModuleNameSource

Parse a module name.

Expressions

pExp :: Ord n => Context -> Parser n (Exp SourcePos n)Source

Parse a core language expression.

pExpApp :: Ord n => Context -> Parser n (Exp SourcePos n)Source

Parse a function application.

pExpAtom :: Ord n => Context -> Parser n (Exp SourcePos n)Source

Parse a variable, constructor or parenthesised expression.

Function Parameters

data ParamSpec n Source

Specification of a function parameter. We can determine the contribution to the type of the function, as well as its expression based on the parameter.

Constructors

ParamType (Bind n) 
ParamWitness (Bind n) 
ParamValue (Bind n) (Type n) (Type n) 

funTypeOfParamsSource

Arguments

:: Context 
-> [ParamSpec n]

Spec of parameters.

-> Type n

Type of body.

-> Type n

Type of whole function.

Build the type of a function from specifications of its parameters, and the type of the body.

expOfParamsSource

Arguments

:: a 
-> [ParamSpec n]

Spec of parameters.

-> Exp a n

Body of function.

-> Exp a n

Expression of whole function.

Build the expression of a function from specifications of its parameters, and the expression for the body.

pBindParamSpecAnnot :: Ord n => Context -> Parser n [ParamSpec n]Source

Parse a function parameter specification, requiring a full type (or kind) annotation.

pBindParamSpec :: Ord n => Context -> Parser n [ParamSpec n]Source

Parse a function parameter specification, with an optional type (or kind) annotation.

Witnesses

pWitness :: Ord n => Context -> Parser n (Witness SourcePos n)Source

Parse a witness expression.

pWitnessApp :: Ord n => Context -> Parser n (Witness SourcePos n)Source

Parse a witness application.

pWitnessAtom :: Ord n => Context -> Parser n (Witness SourcePos n)Source

Parse a variable, constructor or parenthesised witness.

Constructors

pCon :: Parser n nSource

Parse a constructor name.

pConSP :: Parser n (n, SourcePos)Source

Parse a constructor name.

pLit :: Parser n nSource

Parse a literal.

pLitSP :: Parser n (n, SourcePos)Source

Parse a literal, with source position.

Variables

pIndex :: Parser n IntSource

Parse a deBruijn index.

pIndexSP :: Parser n (Int, SourcePos)Source

Parse a deBruijn index, with source position.

pVar :: Parser n nSource

Parse a variable.

pVarSP :: Parser n (n, SourcePos)Source

Parse a variable, with source position.

pBinder :: Ord n => Parser n (Binder n)Source

Parse a binder.

pName :: Parser n nSource

Parse a constructor or variable name.

Infix operators

pOpSP :: Parser n (String, SourcePos)Source

Parse an infix operator.

pOpVarSP :: Parser n (String, SourcePos)Source

Parse an infix operator used as a variable.

Raw Tokens

pTok :: TokAtom -> Parser n ()Source

Parse an atomic token.

pTokSP :: TokAtom -> Parser n SourcePosSource

Parse an atomic token, yielding its source position.

pTokAs :: TokAtom -> a -> Parser n aSource

Parse an atomic token and return some value.