aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2008-04-09 22:03:04 +0000
committerdos-reis <gdr@axiomatics.org>2008-04-09 22:03:04 +0000
commit7e086ab1ad79547dc9c93e56f38d0834c9f0080c (patch)
treeb74f603053a2bc4d23dc99838a7184a29feb8d90 /src
parent84f8896fc28ddbcd0e5cfd65202005cfc12d9dfd (diff)
downloadopen-axiom-7e086ab1ad79547dc9c93e56f38d0834c9f0080c.tar.gz
* boot/translator.boot (bpOutItem): Tidy.
* boot/parser.boot (bpTypeAliasDefition): Support parameterized alias. * boot/ast.boot (quote): New. (backquote): Likewise. (genTypeAlias): Likewise.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog8
-rw-r--r--src/boot/ast.boot21
-rw-r--r--src/boot/parser.boot4
-rw-r--r--src/boot/translator.boot4
4 files changed, 32 insertions, 5 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index a7790991..7298ed24 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,11 @@
+2008-04-09 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
+ * boot/translator.boot (bpOutItem): Tidy.
+ * boot/parser.boot (bpTypeAliasDefition): Support parameterized alias.
+ * boot/ast.boot (quote): New.
+ (backquote): Likewise.
+ (genTypeAlias): Likewise.
+
2008-04-08 Gabriel Dos Reis <gdr@cs.tamu.edu>
* interp/nlib.lisp (recompile-lib-file-if-necessary): Remove.
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]]