Commit 750c7ae8 authored by Vincent Zweije's avatar Vincent Zweije
Browse files

Refine

parent 97c8d6bf
......@@ -7,8 +7,6 @@ import rule
import syntax
import StdEnv
// $Id$
// Cocl to Sucl for functions
cts_function
:: {#FunDef}
......@@ -18,7 +16,43 @@ cts_function
, [(SuclSymbol,SuclSymbolKind)] // Kind of symbol
)
cts_function _ = abort "cts_function: not implemented"
cts_function fundefs
= foldr convert_fundef ([],[],[],[]) [fundef\\fundef<-:fundefs]
convert_fundef
:: FunDef
( [(SuclSymbol,Rule SuclTypeSymbol SuclTypeVariable)]//Type rule (derives arity)
, [(SuclSymbol,[Bool])] // Strict arguments (just main args for now)
, [(SuclSymbol,[Rule SuclSymbol SuclVariable])] // Rewrite rules
, [(SuclSymbol,SuclSymbolKind)] // Kind of symbol
)
-> ( [(SuclSymbol,Rule SuclTypeSymbol SuclTypeVariable)]//Type rule (derives arity)
, [(SuclSymbol,[Bool])] // Strict arguments (just main args for now)
, [(SuclSymbol,[Rule SuclSymbol SuclVariable])] // Rewrite rules
, [(SuclSymbol,SuclSymbolKind)] // Kind of symbol
)
convert_fundef fundef (typerulemap,strictsmap,rulesmap,kindmap)
= ( [(funsym,typerule):typerulemap]
, [(funsym,stricts):strictsmap]
, [(funsym,rules):rulesmap]
, [(funsym,kind):kindmap]
)
where {fun_symb,fun_body,fun_type,fun_kind} = fundef
funsym = SuclUser fun_symb
(typerule,stricts) = foldoptional notyperule convert_symboltype fun_type
notyperule = abort "convert: convert_fundef: fun_type is absent"
rules = convert_functionbody fun_body
kind = convert_kind fun_kind
convert_symboltype :: SymbolType -> (Rule SuclTypeSymbol SuclTypeVariable,[Bool])
convert_symboltype _ = abort "convert: convert_symboltype: not implemented"
convert_functionbody :: FunctionBody -> [Rule SuclSymbol SuclVariable]
convert_functionbody _ = abort "convert: convert_functionbody: not implemented"
convert_kind :: DefOrImpFunKind -> SuclSymbolKind
convert_kind _ = abort "convert: convert_kind: not implemented"
// SuclSymbolKind distinguishes functions, constructors, and primitives
// SuclSymbol are the Sucl symbols, such as SuclInt Int, etc.
foldoptional no yes No = no
foldoptional no yes (Yes value) = yes value
......@@ -2,8 +2,20 @@ definition module coreclean
// $Id$
from syntax import Ident
// Transitive necessities
from syntax import SymbolPtr,SymbolTableEntry,STE_Kind,Index,Level
from Heap import Ptr,PtrN,HeapN
from StdString import String
:: SuclTypeSymbol
:: SuclTypeVariable
:: SuclSymbol
= SuclUser Ident
:: SuclSymbolKind
:: SuclVariable
......@@ -2,6 +2,8 @@ implementation module coreclean
// $Id$
import syntax
:: SuclTypeSymbol
= SuclINT
......@@ -9,7 +11,7 @@ implementation module coreclean
= SuclANONYMOUS Int
:: SuclSymbol
= SuclInt Int
= SuclUser Ident
:: SuclSymbolKind
= SuclFunction
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment