# adl-raw-syntax-translation.api -- derived from ~/src/sml/nj/smlnj-110.60/MLRISC/Tools/FakeSMLAst/ast-trans.sig
# Translation from one sort to another
# Compiled by:
#
src/lib/compiler/back/low/tools/sml-ast.lib# This api is implemented in:
#
src/lib/compiler/back/low/tools/adl-syntax/adl-raw-syntax-translation.pkgstipulate
package raw = adl_raw_syntax_form; # adl_raw_syntax_form is from
src/lib/compiler/back/low/tools/adl-syntax/adl-raw-syntax-form.pkgherein
api Adl_Raw_Syntax_Translation {
#
Map(X)
=
{ orig_name: raw::Id, # Original name
new_name: raw::Id, # New name (for duplicates)
type: raw::Type # The type associated with it
}
-> X;
Folder(X)
=
( { orig_name: raw::Id,
new_name: raw::Id,
type: raw::Type
},
X
)
-> X;
# Simplify an expression, declaration etc:
#
simplify_expression: raw::Expression -> raw::Expression;
simplify_declaration: raw::Declaration -> raw::Declaration;
simplify_pattern: raw::Pattern -> raw::Pattern;
simplify_type: raw::Type -> raw::Type;
simplify_sexp: raw::Package_Exp -> raw::Package_Exp;
strip_marks: raw::Declaration -> raw::Declaration; # Strip away all location markings.
# Translate a type to a pattern.
# Apply the map function on each naming:
#
map_ty_to_pattern
:
Map( raw::Pattern )
-> raw::Type
-> raw::Pattern
;
# Translate a type to an expression.
# Apply the map function on each identifier:
#
map_ty_to_expression
:
Map( raw::Expression )
-> raw::Type
-> raw::Expression
;
# Fold functions that does similar things as the ones above,
# i.e., it enumerates all the namings and their types.
#
fold_type: Folder(X) -> X -> raw::Type -> X;
fold_cons: Folder(X) -> X -> raw::Constructor -> X;
# Translate a constructor to a pattern:
#
map_cons_to_pattern
:
{ prefix: List( raw::Id ), # Path prefix.
id: Map( raw::Pattern ) # How to map identifiers.
}
-> raw::Constructor
-> raw::Pattern
;
# Translate a constructor to an expression
# representing its arguments:
#
map_cons_arg_to_expression
:
Map( raw::Expression ) # How to map identifiers.
-> raw::Constructor
-> raw::Expression
;
# Translate a constructor to a
# constructor expression:
#
map_cons_to_expression
:
{ prefix: List( raw::Id ), # Path prefix.
id: Map( raw::Expression ) # How to map identifiers.
}
-> raw::Constructor
-> raw::Expression
;
# Translate a constructor to a clause:
#
map_cons_to_clause
:
{ prefix: List( raw::Id ), # Path prefix.
pattern: raw::Pattern -> raw::Pattern,
expression: raw::Expression
}
-> raw::Constructor
-> raw::Clause
;
# Given a constructor, return a function
# that looks up the pattern variables and
# their types:
#
cons_namings
:
raw::Constructor
->
(raw::Id -> (raw::Expression, raw::Type));
};
end;