aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2008-04-19 04:36:36 +0000
committerdos-reis <gdr@axiomatics.org>2008-04-19 04:36:36 +0000
commit20b621ddcdf7dcd0c730ff5fc4a446ea1f829951 (patch)
tree24e6cbe431a2f46020c21857473fe0ad8e34ed1e
parent35ef2226d840fbc726f944afd053abd56fa0ee75 (diff)
downloadopen-axiom-20b621ddcdf7dcd0c730ff5fc4a446ea1f829951.tar.gz
* boot/ast.boot (%DefaultValue): New %Ast node.
(bfParameterList): New. (bfInsertLet): Use it. (bfInsertLet1): Handle parameter with default values. * boot/parser.boot (bpRegularBVItemTail): Split from bpRegularBVItem. (bpRegularBVItem): Tidy.
-rwxr-xr-xconfigure18
-rw-r--r--configure.ac2
-rw-r--r--configure.ac.pamphlet2
-rw-r--r--src/ChangeLog10
-rw-r--r--src/boot/ast.boot38
-rw-r--r--src/boot/parser.boot31
6 files changed, 68 insertions, 33 deletions
diff --git a/configure b/configure
index 1c3c232e..a565923c 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.60 for OpenAxiom 1.2.0-2008-04-13.
+# Generated by GNU Autoconf 2.60 for OpenAxiom 1.2.0-2008-04-18.
#
# Report bugs to <open-axiom-bugs@lists.sf.net>.
#
@@ -713,8 +713,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='OpenAxiom'
PACKAGE_TARNAME='openaxiom'
-PACKAGE_VERSION='1.2.0-2008-04-13'
-PACKAGE_STRING='OpenAxiom 1.2.0-2008-04-13'
+PACKAGE_VERSION='1.2.0-2008-04-18'
+PACKAGE_STRING='OpenAxiom 1.2.0-2008-04-18'
PACKAGE_BUGREPORT='open-axiom-bugs@lists.sf.net'
ac_unique_file="src/Makefile.pamphlet"
@@ -1402,7 +1402,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures OpenAxiom 1.2.0-2008-04-13 to adapt to many kinds of systems.
+\`configure' configures OpenAxiom 1.2.0-2008-04-18 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1472,7 +1472,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of OpenAxiom 1.2.0-2008-04-13:";;
+ short | recursive ) echo "Configuration of OpenAxiom 1.2.0-2008-04-18:";;
esac
cat <<\_ACEOF
@@ -1576,7 +1576,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-OpenAxiom configure 1.2.0-2008-04-13
+OpenAxiom configure 1.2.0-2008-04-18
generated by GNU Autoconf 2.60
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -1590,7 +1590,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by OpenAxiom $as_me 1.2.0-2008-04-13, which was
+It was created by OpenAxiom $as_me 1.2.0-2008-04-18, which was
generated by GNU Autoconf 2.60. Invocation command line was
$ $0 $@
@@ -25801,7 +25801,7 @@ exec 6>&1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by OpenAxiom $as_me 1.2.0-2008-04-13, which was
+This file was extended by OpenAxiom $as_me 1.2.0-2008-04-18, which was
generated by GNU Autoconf 2.60. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -25850,7 +25850,7 @@ Report bugs to <bug-autoconf@gnu.org>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
-OpenAxiom config.status 1.2.0-2008-04-13
+OpenAxiom config.status 1.2.0-2008-04-18
configured by $0, generated by GNU Autoconf 2.60,
with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
diff --git a/configure.ac b/configure.ac
index 2f2d99b3..780d1ef9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,6 @@
sinclude(config/open-axiom.m4)
sinclude(config/aclocal.m4)
-AC_INIT([OpenAxiom], [1.2.0-2008-04-13],
+AC_INIT([OpenAxiom], [1.2.0-2008-04-18],
[open-axiom-bugs@lists.sf.net])
AC_CONFIG_AUX_DIR(config)
diff --git a/configure.ac.pamphlet b/configure.ac.pamphlet
index b8859c5b..2b13a0dd 100644
--- a/configure.ac.pamphlet
+++ b/configure.ac.pamphlet
@@ -1092,7 +1092,7 @@ information:
<<Autoconf init>>=
sinclude(config/open-axiom.m4)
sinclude(config/aclocal.m4)
-AC_INIT([OpenAxiom], [1.2.0-2008-04-13],
+AC_INIT([OpenAxiom], [1.2.0-2008-04-18],
[open-axiom-bugs@lists.sf.net])
@
diff --git a/src/ChangeLog b/src/ChangeLog
index 8863e00b..70baa3c2 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,15 @@
2008-04-18 Gabriel Dos Reis <gdr@cs.tamu.edu>
+ * boot/ast.boot (%DefaultValue): New %Ast node.
+ (bfParameterList): New.
+ (bfInsertLet): Use it.
+ (bfInsertLet1): Handle parameter with default values.
+ * boot/parser.boot (bpRegularBVItemTail): Split from bpRegularBVItem.
+ (bpRegularBVItem): Tidy.
+
+2008-04-18 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
+ * boot/ast.boot:
* interp/define.boot ($mutableDomain): Define.
(compDefineFunctor): Initialize it before compiling a functor.
diff --git a/src/boot/ast.boot b/src/boot/ast.boot
index 5fe33191..ab37de68 100644
--- a/src/boot/ast.boot
+++ b/src/boot/ast.boot
@@ -82,6 +82,7 @@ structure Ast ==
EqualName(Name) -- =x -- patterns
Colon(Name) -- :x
QualifiedName(Name, Name) -- m::x
+ %DefaultValue(%Name,%Ast) -- opt. value for function param.
Bracket(Ast) -- [x, y]
UnboundedSegment(Ast) -- 3..
BoundedSgement(Ast, Ast) -- 2..4
@@ -838,6 +839,22 @@ shoeComp x==
if EQCAR(a,"LAMBDA")
then ["DEFUN",CAR x,CADR a,:CDDR a]
else ["DEFMACRO",CAR x,CADR a,:CDDR a]
+
+
+++ Translate function parameter list to Lisp.
+++ We are processing a function definition. `p2' is the list of
+++ parameters we have seen so far, and we are about to add a
+++ parameter `p1'. Check that the new specification is coherent
+++ with the previous one. In particular, check that restrictions
+++ on parameters with default values are satisfied. Return the
+++ new augmented parameter list.
+bfParameterList(p1,p2) ==
+ p2=nil and not atom p1 => p1
+ p1 is ["&OPTIONAL",:.] =>
+ p2 isnt ["&OPTIONAL",:.] => bpSpecificErrorHere '"default value required"
+ [first p1,:rest p1,:rest p2]
+ p2 is ["&OPTIONAL",:.] => [p1,first p2,:rest p2]
+ [p1,:p2]
bfInsertLet(x,body)==
if null x
@@ -850,20 +867,17 @@ bfInsertLet(x,body)==
else
[b,norq,name1,body1]:= bfInsertLet1 (car x,body)
[b1,norq1,name2,body2]:= bfInsertLet (cdr x,body1)
- [b or b1,cons(norq,norq1),cons(name1,name2),body2]
+ [b or b1,cons(norq,norq1),bfParameterList(name1,name2),body2]
bfInsertLet1(y,body)==
- if y is ["L%T",l,r]
- then [false,nil,l,bfMKPROGN [bfLET(r,l),body]]
- else if IDENTP y
- then [false,nil,y,body]
- else
- if y is ["BVQUOTE",b]
- then [true,"QUOTE",b,body]
- else
- g:=bfGenSymbol()
- ATOM y => [false,nil,g,body]
- [false,nil,g,bfMKPROGN [bfLET(compFluidize y,g),body]]
+ y is ["L%T",l,r] => [false,nil,l,bfMKPROGN [bfLET(r,l),body]]
+ IDENTP y => [false,nil,y,body]
+ y is ["BVQUOTE",b] => [true,"QUOTE",b,body]
+ g:=bfGenSymbol()
+ ATOM y => [false,nil,g,body]
+ case y of
+ %DefaultValue(p,v) => [false,nil,["&OPTIONAL",[p,v]],body]
+ otherwise => [false,nil,g,bfMKPROGN [bfLET(compFluidize y,g),body]]
shoeCompTran x==
lamtype:=CAR x
diff --git a/src/boot/parser.boot b/src/boot/parser.boot
index 6eeaa392..af8098b2 100644
--- a/src/boot/parser.boot
+++ b/src/boot/parser.boot
@@ -981,17 +981,28 @@ bpPatternTail()==
and bpPush append (bpPop2(),bpPop1()) or true)
-- BOUND VARIABLE
+
+++ We are parsing parameters in a function definition. We have
+++ just seen a parameter name; we are attempting to see whether
+++ it might be followed by a type annotation, or whether it actually
+++ a form with a specific pattern structure, or whether it has
+++ a default value.
+bpRegularBVItemTail() ==
+ bpEqKey "COLON" and (bpApplication() or bpTrap()) and
+ bpPush bfTagged(bpPop2(), bpPop1())
+ or bpEqKey "BEC" and (bpPattern() or bpTrap()) and
+ bpPush bfAssign(bpPop2(),bpPop1())
+ or bpEqKey "IS" and (bpPattern() or bpTrap()) and
+ bpPush bfAssign(bpPop2(),bpPop1())
+ or bpEqKey "DEF" and (bpApplication() or bpTrap()) and
+ bpPush %DefaultValue(bpPop2(), bpPop1())
+
+
bpRegularBVItem() ==
- bpBVString() or
- bpConstTok() or
- (bpName() and
- (bpEqKey "COLON" and (bpApplication() or bpTrap())
- and bpPush bfTagged(bpPop2(), bpPop1()) or
- bpEqKey "BEC" and (bpPattern() or bpTrap())
- and bpPush bfAssign(bpPop2(),bpPop1()) or
- (bpEqKey "IS" and (bpPattern() or bpTrap())
- and bpPush bfAssign(bpPop2(),bpPop1())) or true))
- or bpBracketConstruct function bpPatternL
+ bpBVString()
+ or bpConstTok()
+ or (bpName() and (bpRegularBVItemTail() or true))
+ or bpBracketConstruct function bpPatternL
bpBVString()==
EQ(shoeTokType $stok,"STRING") and