Hets - the Heterogeneous Tool Set

Copyright(c) Christian Maeder and Uni Bremen 2002-2005
LicenseGPLv2 or higher, see LICENSE.txt
MaintainerChristian.Maeder@dfki.de
Stabilityprovisional
Portabilityportable
Safe HaskellNone

HasCASL.ParseTerm

Contents

Description

parser for HasCASL kinds, types, terms, patterns and equations

Synopsis

key sign tokens

colT :: AParser st Token Source #

a colon not followed by a question mark

parser for bracketed lists

bracketParser :: AParser st a -> AParser st Token -> AParser st Token -> AParser st Token -> ([a] -> Range -> b) -> AParser st b Source #

a generic bracket parser

mkBrackets :: AParser st a -> ([a] -> Range -> b) -> AParser st b Source #

parser for square brackets

mkBraces :: AParser st a -> ([a] -> Range -> b) -> AParser st b Source #

parser for braces

kinds

parseClassId :: AParser st Kind Source #

parse a simple class name or the type universe as kind

parseSimpleKind :: AParser st Kind Source #

do parseClassId or a kind in parenthessis

parseExtKind :: AParser st (Variance, Kind) Source #

do parseSimpleKind and check for an optional Variance

arrowKind :: (Variance, Kind) -> AParser st Kind Source #

parse a (right associative) function kind for a given argument kind

kind :: AParser st Kind Source #

parse a function kind but reject an extended kind

extKind :: AParser st (Variance, Kind) Source #

parse a function kind but accept an extended kind

type variables

allIsNonVar :: [(Id, Variance)] -> Bool Source #

typeKind :: Bool -> [(Id, Variance)] -> [Token] -> AParser st [TypeArg] Source #

makeTypeArgs :: [(Id, Variance)] -> [Token] -> Variance -> VarKind -> Range -> [TypeArg] Source #

add the Kind to all extVar and yield a TypeArg

parenTypeArg :: AParser st (TypeArg, [Token]) Source #

a singleTypeArg put in parentheses

typeArg :: AParser st (TypeArg, [Token]) Source #

a singleTypeArg possibly put in parentheses

parse special identifier tokens

type TokenMode = [String] Source #

aToken :: TokenMode -> AParser st Token Source #

parse a Token of an Id (to be declared) but exclude the signs in TokenMode

idToken :: AParser st Token Source #

just aToken only excluding basic HasCASL keywords

type patterns

typePatternToken :: AParser st TypePattern Source #

those (top-level) Tokens (less than idToken) that may appear in TypePatterns as TypePatternToken.

primTypePattern :: AParser st TypePattern Source #

a typePatternToken or something in braces (a typePattern), in square brackets (a typePatternOrId covering compound lists) or parenthesis (typePatternArg)

types a parsed type may also be interpreted as a kind (by the mixfix analysis)

typeToken :: AParser st Type Source #

type tokens with some symbols removed

primTypeOrId :: AParser st Type Source #

TypeTokens within BracketTypes may recusively be idTokens. Parenthesis may group a mixfix type or may be interpreted as a kind later on in a GEN-VAR-DECL.

typeOrId :: AParser st Type Source #

several primTypeOrIds possibly yielding a MixfixType and possibly followed by a kindAnno.

kindAnno :: Type -> AParser st Type Source #

a Kind annotation starting with colT.

primType :: AParser st Type Source #

a typeToken' or a BracketType. Square brackets may contain typeOrId.

lazyType :: AParser st Type Source #

a primType possibly preceded by quMarkT

mixType :: AParser st Type Source #

several lazyTypes (as MixfixType) possibly followed by kindAnno

prodType :: AParser st Type Source #

mixType possibly interspersed with crossT

parseType :: AParser st Type Source #

a (right associativ) function type

arrowT :: AParser st Id Source #

parse one of the four possible Arrows

varDecls and genVarDecls

varDecls :: AParser st [VarDecl] Source #

comma separated var with varDeclType

varDeclType :: [Id] -> [Token] -> AParser st [VarDecl] Source #

a type (parseType) following a colon

makeVarDecls :: [Id] -> [Token] -> Type -> Range -> [VarDecl] Source #

attach the Type to every Var

genVarDecls :: AParser st [GenVarDecl] Source #

either like varDecls or declared type variables. A GenVarDecl may later become a GenTypeVarDecl.

patterns

tokenPattern :: TokenMode -> AParser st Term Source #

different legal TermTokens possibly excluding funS or equalS for case or let patterns resp.

typedPattern :: TokenMode -> AParser st Term Source #

a possibly typed (parseType) pattern

asPattern :: TokenMode -> AParser st Term Source #

top-level pattern (possibly AsPattern)

pattern :: AParser st Term Source #

an unrestricted asPattern

myChoice :: [(AParser st Token, a)] -> AParser st (a, Token) Source #

lamPattern :: AParser st [Term] Source #

patterns between lamS and lamDot

terms

tToken :: TokenMode -> AParser st Token Source #

Tokens that may occur in Terms including literals scanFloat, scanString but excluding ifS, whenS and elseS to allow a quantifier after whenS. In case-terms also barS will be excluded on the top-level.

data InMode Source #

how the keyword inS should be treated

Constructors

NoIn

next inS belongs to letS

WithIn

inS is the element test

baseTerm :: (InMode, TokenMode) -> AParser st Term Source #

all Terms that start with a unique keyword

whenTerm :: (InMode, TokenMode) -> AParser st Term Source #

whenS possibly followed by an elseS

ifTerm :: (InMode, TokenMode) -> AParser st Term Source #

ifS possibly followed by thenS and elseS yielding a MixfixTerm

termInParens :: AParser st Term Source #

unrestricted terms including qualified names

varTerm :: AParser st Term Source #

a qualified var

qualOpName :: AParser st Term Source #

a qualified operation (with opBrand)

qualPredName :: AParser st Term Source #

a qualified predicate

typeQual :: InMode -> AParser st (TypeQual, Token) Source #

a qualifier expecting a further Type. inS is rejected for NoIn

qualAndType :: InMode -> AParser st Term Source #

a qualifier plus a subsequent type as mixfix term component

typedTerm :: (InMode, TokenMode) -> AParser st Term Source #

a possibly type qualified (typeQual) primTerm or a baseTerm

hasCaslStartKeywords :: [String] Source #

keywords that start a new item

whereTerm :: (InMode, TokenMode) -> AParser st Term Source #

a mixTerm followed by whereS and equations separated by optSemi

term :: AParser st Term Source #

a whereTerm called with (WithIn, [])

exTerm :: (InMode, TokenMode) -> AParser st Term Source #

a (possibly unique) existential QuantifiedTerm

letTerm :: (InMode, TokenMode) -> AParser st Term Source #

a LetTerm with equalS excluded in patternTermPair (called with NoIn)

patternTermPair :: TokenMode -> (InMode, TokenMode) -> String -> AParser st ProgEq Source #

a customizable pattern equation