[Yhc] Could you please explain the interface to the type checker?

Malcolm Wallace Malcolm.Wallace at cs.york.ac.uk
Fri Feb 16 06:49:58 EST 2007


Bernie Pope <bjpop at csse.unimelb.edu.au> wrote:

> I'm contemplating the possibility of using Chameleon as a front end 
> (well type checker) for yhc.

Interesting idea.  Could be useful.

> I don't want to tread on anyone's toes, so if you have a fancy new
> type  checker in the pipeline I would like to hear about that too.

No-one is currently working on replacing the type system in yhc.

> Would one of you be able to describe the interface of the type checker
> (which I presume is Type.typeTopDecls)?

typeTopDecls :: ((TokenId,IdKind) -> Id) 
             -> Maybe [Id]
             -> IntState
             -> [ClassCode (Exp Id) Id]
             -> Decls Id 
             -> ([ClassCode (Exp Id) Id],Decls Id,IntState)

First argument
        ((TokenId,IdKind) -> Id) 
is a mapping from the literal name (+ IdKind = function,method,class
etc) of an identifier to its Id (lookup key) in the symbol table.
Second arg is the current list of defaults:
        Maybe [Id]
Third arg is the running state of the compiler
        IntState
It contains the symbol table, command-line flags, and any accumulated
error messages.
Fourth arg
        [ClassCode (Exp Id) Id]
and fifth arg
        Decls Id 
are the abstract syntax tree, with strongly-connected component analysis
already performed, and all class and instance decls hoisted out into a
separate list.
The Result
	([ClassCode (Exp Id) Id],Decls Id,IntState)
is a new AST, and a new running state.  Any type errors have been
written into the IntState.

Regards,
    Malcolm


More information about the Yhc mailing list