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

Safe HaskellNone
LanguageHaskell98

DDC.Core.Parser

Contents

Description

Core language parser.

Synopsis

Documentation

type Parser n a = Parser (Token n) a Source #

A parser of core language tokens.

data Context n Source #

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

Constructors

Context 

Fields

contextOfProfile :: Profile n -> Context n Source #

Slurp an initital Context from a language Profile.

Types

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

Parse a type.

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

Parse a type application.

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

Parse a variable, constructor or parenthesised type.

Modules

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

Parse a core module.

pModuleName :: Pretty n => Parser n ModuleName Source #

Parse a module name.

Expressions

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

Parse a core language expression.

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

Parse a function application.

pExpAtom :: Ord n => Context n -> 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) 

funTypeOfParams Source #

Arguments

:: Context n 
-> [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.

expOfParams Source #

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 n -> Parser n [ParamSpec n] Source #

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

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

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

Witnesses

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

Parse a witness expression.

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

Parse a witness application.

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

Parse a variable, constructor or parenthesised witness.

Constructors

pCon :: Parser n n Source #

Parse a constructor name.

pConSP :: Parser n (n, SourcePos) Source #

Parse a constructor name.

pLit :: Parser n (Literal, Bool) Source #

Parse a literal.

pLitSP :: Parser n ((Literal, Bool), SourcePos) Source #

Parse a numeric literal, with source position.

Variables

pIndex :: Parser n Int Source #

Parse a deBruijn index.

pIndexSP :: Parser n (Int, SourcePos) Source #

Parse a deBruijn index, with source position.

pVar :: Parser n n Source #

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 n Source #

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 :: TokenAtom -> Parser n () Source #

Parse an atomic token.

pTokSP :: TokenAtom -> Parser n SourcePos Source #

Parse an atomic token, yielding its source position.

pTokAs :: TokenAtom -> a -> Parser n a Source #

Parse an atomic token and return some value.