aboutsummaryrefslogtreecommitdiff
path: root/src/boot
diff options
context:
space:
mode:
Diffstat (limited to 'src/boot')
-rw-r--r--src/boot/ast.boot20
-rw-r--r--src/boot/parser.boot12
-rw-r--r--src/boot/translator.boot13
3 files changed, 37 insertions, 8 deletions
diff --git a/src/boot/ast.boot b/src/boot/ast.boot
index 4c0c02d4..958ad11c 100644
--- a/src/boot/ast.boot
+++ b/src/boot/ast.boot
@@ -175,6 +175,11 @@ compFluidize x==
bfTuple x== ["TUPLE",:x]
bfTupleP x==EQCAR(x,"TUPLE")
+
+++ If `bf' is a tuple return its elements; otherwise `bf'.
+bfUntuple bf ==
+ bfTupleP bf => cdr bf
+ bf
bfTupleIf x==
if bfTupleP x
@@ -914,13 +919,14 @@ shoeCompTran1 x==
shoeCompTran1 cdr x
bfTagged(a,b)==
- IDENTP a =>
- EQ(b,"FLUID") => bfLET(compFluid a,NIL)
- EQ(b,"fluid") => bfLET(compFluid a,NIL)
- EQ(b,"local") => bfLET(compFluid a,NIL)
- $typings:=cons(["TYPE",b,a],$typings)
- a
- ["THE",b,a]
+ null $op => Signature(a,b) -- surely a toplevel decl
+ IDENTP a =>
+ EQ(b,"FLUID") => bfLET(compFluid a,NIL)
+ EQ(b,"fluid") => bfLET(compFluid a,NIL)
+ EQ(b,"local") => bfLET(compFluid a,NIL)
+ $typings:=cons(["TYPE",b,a],$typings)
+ a
+ ["THE",b,a]
bfAssign(l,r)==
if bfTupleP l then bfSetelt(CADR l,CDDR l ,r) else bfLET(l,r)
diff --git a/src/boot/parser.boot b/src/boot/parser.boot
index 9908a68a..9c41a07b 100644
--- a/src/boot/parser.boot
+++ b/src/boot/parser.boot
@@ -553,9 +553,19 @@ bpApplication()==
(bpApplication() and
bpPush(bfApplication(bpPop2(),bpPop1())) or true)
+++ Typing:
+++ SimpleType
+++ Mapping
+bpTyping() ==
+ bpApplication() and
+ (bpEqKey "ARROW" and (bpApplication() or bpTrap()) and
+ bpPush Mapping(bpPop1(), bfUntuple bpPop1()) or true) or bpMapping()
+
+++ Tagged:
+++ Name : Typing
bpTagged()==
bpApplication() and
- (bpEqKey "COLON" and (bpApplication() or bpTrap()) and
+ (bpEqKey "COLON" and (bpTyping() or bpTrap()) and
bpPush bfTagged(bpPop2(),bpPop1()) or true)
bpExpt()== bpRightAssoc('(POWER),function bpTagged)
diff --git a/src/boot/translator.boot b/src/boot/translator.boot
index 0fc79fa0..8d866052 100644
--- a/src/boot/translator.boot
+++ b/src/boot/translator.boot
@@ -351,7 +351,17 @@ shoeOutParse stream ==
nil
else CAR $stack
+++ Generate a global signature declaration for symbol `n'.
+genDeclaration(n,t) ==
+ t is ["Mapping",valType,argTypes] =>
+ if bfTupleP argTypes then argTypes := cdr argTypes
+ if not null argTypes and SYMBOLP argTypes
+ then argTypes := [argTypes]
+ ["DECLAIM",["FTYPE",["FUNCTION",argTypes,valType],n]]
+ ["DECLAIM",["TYPE",t,n]]
+
bpOutItem()==
+ $op := nil
bpComma() or bpTrap()
b:=bpPop1()
EQCAR(b,"TUPLE")=> bpPush cdr b
@@ -359,6 +369,9 @@ bpOutItem()==
b is ["L%T",l,r] and IDENTP l =>
bpPush [["DEFPARAMETER",l,r]]
case b of
+ Signature(op,t) =>
+ bpPush [genDeclaration(op,t)]
+
Module(m) =>
bpPush [shoeCompileTimeEvaluation ["PROVIDE", m]]