aboutsummaryrefslogtreecommitdiff
path: root/src/boot
diff options
context:
space:
mode:
Diffstat (limited to 'src/boot')
-rw-r--r--src/boot/ast.boot21
-rw-r--r--src/boot/parser.boot4
-rw-r--r--src/boot/translator.boot4
3 files changed, 24 insertions, 5 deletions
diff --git a/src/boot/ast.boot b/src/boot/ast.boot
index ba6c3d1d..5fe33191 100644
--- a/src/boot/ast.boot
+++ b/src/boot/ast.boot
@@ -74,7 +74,7 @@ structure Ast ==
Module(%String) -- module declaration
Import(%String) -- import module
ImportSignature(Name, Signature) -- import function declaration
- TypeAlias(Name, %List, %List) -- type alias definition
+ TypeAlias(%Head, %List) -- type alias definition
Signature(Name, Mapping) -- op: S -> T
Mapping(Ast, %List) -- (S1, S2) -> T
SuffixDot(Ast) -- x .
@@ -119,6 +119,12 @@ structure Ast ==
-- expression.
$inDefIS := false
+
+quote x ==
+ ["QUOTE",x]
+
+--%
+
bfGenSymbol: () -> %Symbol
bfGenSymbol()==
$GenVarCounter:=$GenVarCounter+1
@@ -1160,6 +1166,19 @@ bfThrow e ==
not atom first e => bpTrap()
["THROW",["QUOTE",first e],:rest e]
+--% Type alias definition
+
+backquote(form,params) ==
+ null params => quote form
+ atom form =>
+ form in params => form
+ quote form
+ ["LIST",:[backquote(t,params) for t in form]]
+
+genTypeAlias(head,body) ==
+ [op,:args] := head
+ ["DEFTYPE",op,args,backquote(body,args)]
+
--% Native datatype translation
coreSymbol: %Symbol -> %Symbol
coreSymbol s ==
diff --git a/src/boot/parser.boot b/src/boot/parser.boot
index 10970e82..6eeaa392 100644
--- a/src/boot/parser.boot
+++ b/src/boot/parser.boot
@@ -443,9 +443,9 @@ bpImport() ==
-- type-alias-definition:
-- identifier <=> logical-expression
bpTypeAliasDefition() ==
- (bpName() or bpTrap()) and
+ (bpTerm() or bpTrap()) and
bpEqKey "TDEF" and bpLogical() and
- bpPush TypeAlias(bpPop2(), nil, bpPop1())
+ bpPush TypeAlias(bpPop2(), bpPop1())
++ Parse a signature declaration
++ Signature:
diff --git a/src/boot/translator.boot b/src/boot/translator.boot
index b5245d92..8222cab4 100644
--- a/src/boot/translator.boot
+++ b/src/boot/translator.boot
@@ -418,8 +418,8 @@ bpOutItem()==
ImportSignature(x, sig) =>
bpPush genImportDeclaration(x, sig)
- TypeAlias(t, args, rhs) =>
- bpPush [["DEFTYPE", t, args, ["QUOTE", rhs]]]
+ TypeAlias(lhs, rhs) =>
+ bpPush [genTypeAlias(lhs,rhs)]
ConstantDefinition(n, e) =>
bpPush [["DEFCONSTANT", n, e]]