aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2008-07-06 18:58:35 +0000
committerdos-reis <gdr@axiomatics.org>2008-07-06 18:58:35 +0000
commit2cb102a281332ac6410c1ae3b14ceeb56d778aae (patch)
treec1a95ce8cc7d01c6a08fb4b127b6157c47996723 /src
parentb0f950ab3726cf4facbe2b94f97ffbb598963165 (diff)
downloadopen-axiom-2cb102a281332ac6410c1ae3b14ceeb56d778aae.tar.gz
* interp/parse.boot ($normalizeTree): New.
(parseNotEqual): Likewise. * interp/compiler.boot (compCompilerPredicate): New. (compileNot): Use it. * interp/define.boot (compSubDomain1): Likewise. (doItIf): Likewise. * interp/bootlex.lisp (boot): Set $nornamizeTree. * algebra/Makefile.pamphlet (axiom_algebra_layer_9): Move from layer 4 to here.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog12
-rw-r--r--src/algebra/Makefile.in4
-rw-r--r--src/algebra/Makefile.pamphlet4
-rw-r--r--src/interp/bootlex.lisp1
-rw-r--r--src/interp/compiler.boot32
-rw-r--r--src/interp/define.boot4
-rw-r--r--src/interp/parse.boot20
7 files changed, 54 insertions, 23 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 882b8c60..04485014 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,17 @@
2008-07-06 Gabriel Dos Reis <gdr@cs.tamu.edu>
+ * interp/parse.boot ($normalizeTree): New.
+ (parseNotEqual): Likewise.
+ * interp/compiler.boot (compCompilerPredicate): New.
+ (compileNot): Use it.
+ * interp/define.boot (compSubDomain1): Likewise.
+ (doItIf): Likewise.
+ * interp/bootlex.lisp (boot): Set $nornamizeTree.
+ * algebra/Makefile.pamphlet (axiom_algebra_layer_9): Move from
+ layer 4 to here.
+
+2008-07-06 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
* interp/parse.boot (parseTran): Don't set $op. Don't strip parse
tree codes.
(parseConstruct): Handle parse tree code.
diff --git a/src/algebra/Makefile.in b/src/algebra/Makefile.in
index 60409632..72318905 100644
--- a/src/algebra/Makefile.in
+++ b/src/algebra/Makefile.in
@@ -411,7 +411,7 @@ axiom_algebra_layer_3_objects = \
$(addprefix $(OUT)/, \
$(addsuffix .$(FASLEXT),$(axiom_algebra_layer_3)))
axiom_algebra_layer_4 = \
- ANON COLOR COMM COMPPROP ESCONT1 EXIT \
+ ANON COMM COMPPROP ESCONT1 EXIT \
FAMONC FORMULA1 IDPC NONE NUMINT \
ODECAT OMENC ONECOMP2 OPTCAT \
PALETTE PARPCURV PARPC2 PARSCURV PARSC2 PARSURF \
@@ -486,7 +486,7 @@ axiom_algebra_layer_9 = \
PTFUNC2 RADCAT RADCAT- RATRET RADUTIL UPXS2 \
XFALG ZLINDEP BBTREE LSAGG LSAGG- SRAGG \
SRAGG- STRICAT ODEIFTBL NIPROB ODEPROB OPTPROB \
- PDEPROB
+ PDEPROB COLOR
axiom_algebra_layer_9_nrlibs = \
diff --git a/src/algebra/Makefile.pamphlet b/src/algebra/Makefile.pamphlet
index 0012c422..c5b65e83 100644
--- a/src/algebra/Makefile.pamphlet
+++ b/src/algebra/Makefile.pamphlet
@@ -284,7 +284,7 @@ ystream.spad.pamphlet (YSTREAM)
<<layer4>>=
axiom_algebra_layer_4 = \
- ANON COLOR COMM COMPPROP ESCONT1 EXIT \
+ ANON COMM COMPPROP ESCONT1 EXIT \
FAMONC FORMULA1 IDPC NONE NUMINT \
ODECAT OMENC ONECOMP2 OPTCAT \
PALETTE PARPCURV PARPC2 PARSCURV PARSC2 PARSURF \
@@ -413,7 +413,7 @@ axiom_algebra_layer_9 = \
PTFUNC2 RADCAT RADCAT- RATRET RADUTIL UPXS2 \
XFALG ZLINDEP BBTREE LSAGG LSAGG- SRAGG \
SRAGG- STRICAT ODEIFTBL NIPROB ODEPROB OPTPROB \
- PDEPROB
+ PDEPROB COLOR
axiom_algebra_layer_9_nrlibs = \
diff --git a/src/interp/bootlex.lisp b/src/interp/bootlex.lisp
index fc446aa1..b944c653 100644
--- a/src/interp/bootlex.lisp
+++ b/src/interp/bootlex.lisp
@@ -114,6 +114,7 @@
(*fileactq-apply* (function print-defun))
(*comp370-apply* (function print-defun)))
(declare (special echo-meta *comp370-apply* *EOF* File-Closed XCape))
+ (setq |$normalizeTree| t)
(setq |$InteractiveMode| NIL)
(init-boot/spad-reader)
(with-open-stream
diff --git a/src/interp/compiler.boot b/src/interp/compiler.boot
index c759bafa..7c91d4e0 100644
--- a/src/interp/compiler.boot
+++ b/src/interp/compiler.boot
@@ -68,7 +68,8 @@ compUniquely(x,m,e) ==
CATCH("compUniquely",comp(x,m,e))
compOrCroak: (%Form,%Mode,%Env) -> %Maybe %Triple
-compOrCroak(x,m,e) == compOrCroak1(x,m,e,'comp)
+compOrCroak(x,m,e) ==
+ compOrCroak1(x,m,e,'comp)
compOrCroak1: (%Form,%Mode,%Env,%Thing) -> %Maybe %Triple
compOrCroak1(x,m,e,compFn) ==
@@ -99,6 +100,17 @@ compOrCroak1(x,m,e,compFn) ==
tc() ==
comp($x,$m,$f)
+++ The form `x' is intended to be evaluated by the compiler, e.g. in
+++ toplevel conditional definition or as sub-domain predicate.
+++ Normalize operators and compile the form.
+compCompilerPredicate: (%Form,%Env) -> %Maybe %Triple
+compCompilerPredicate(x,e) ==
+ savedNormalizeTree := $normalizeTree
+ $normalizeTree := true
+ t := compOrCroak(parseTran x, $Boolean, e)
+ $normalizeTree := savedNormalizeTree
+ t
+
comp: (%Form,%Mode,%Env) -> %Maybe %Triple
comp(x,m,e) ==
@@ -1132,16 +1144,12 @@ compImport(["import",:doms],m,e) ==
compileNot: (%Form,%Mode,%Env) -> %Maybe %Triple
compileNot(x,m,e) ==
x isnt ["not", y] => nil
- -- If there is a modemap available that can make this work, just use it.
- T := compForm(x,m,e) => T
-
- -- Otherwise, we may be in a case where we might want to apply
- -- built-in Boolean meaning. Eventually, we should not need to
- -- do this special case here.
- [xcode, xmode, xtrueEnv, xfalseEnv] := compBoolean(y, $Boolean, e)
- or return nil
- convert([["NOT", xcode], xmode, xfalseEnv], m)
-
+ -- ??? For the time being compiler values cannot handle operations
+ -- ??? selected through general modemaps, and their semantics
+ -- ??? are quite hardwired with their syntax.
+ -- ??? Eventually, we should not need to do this.
+ $compilerValue => compIf(["IF",y,"false","true"],m,e)
+ compForm(x,m,e)
--% Case
compCase: (%Form,%Mode,%Env) -> %Maybe %Triple
@@ -1562,6 +1570,8 @@ compileSpad2Cmd args ==
throwKeyedMsg("S2IZ0036",[STRCONC('")",object2String optname)])
$InteractiveMode : local := nil
+ -- avoid transformations based on syntax only
+ $normalizeTree := false
if translateOldToNew then
spad2AsTranslatorAutoloadOnceTrigger()
sayKeyedMsg("S2IZ0085", nil)
diff --git a/src/interp/define.boot b/src/interp/define.boot
index 55ea350a..e92ca4d1 100644
--- a/src/interp/define.boot
+++ b/src/interp/define.boot
@@ -1276,7 +1276,7 @@ compSubDomain1(domainForm,predicate,m,e) ==
[.,.,e]:=
compMakeDeclaration([":","#1",domainForm],$EmptyMode,addDomain(domainForm,e))
u:=
- compOrCroak(predicate,$Boolean,e) or
+ compCompilerPredicate(predicate,e) or
stackSemanticError(["predicate: ",predicate,
" cannot be interpreted with #1: ",domainForm],nil)
prefixPredicate:= lispize u.expr
@@ -1403,7 +1403,7 @@ isMacro(x,e) ==
doItIf(item is [.,p,x,y],$predl,$e) ==
olde:= $e
- [p',.,$e]:= comp(p,$Boolean,$e) or userError ['"not a Boolean:",p]
+ [p',.,$e]:= compCompilerPredicate(p,$e) or userError ['"not a Boolean:",p]
oldFLP:=$functorLocalParameters
if x^="%noBranch" then
compSingleCapsuleItem(x,$predl,getSuccessEnvironment(p,$e))
diff --git a/src/interp/parse.boot b/src/interp/parse.boot
index a706d174..d403931c 100644
--- a/src/interp/parse.boot
+++ b/src/interp/parse.boot
@@ -40,6 +40,15 @@ namespace BOOT
++ If non nil, holds the operator being being defined.
$defOp := nil
+++ When true, means that we are building a compile time value. For
+++ the parse tree transformer, this means that some assumtpions
+++ are made about certain operators, regardless of their types
+++ and semantics. For example `x >= y' is assumed to have the
+++ same semantics as `not(x < y)'. Note that this normalization
+++ is also done when this parser is used to translate Boot codes
+++ to Lisp. That usage is being phased out though.
+$normalizeTree := false
+
parseTransform: %ParseForm -> %Form
parseTransform x ==
$defOp: local:= nil
@@ -285,12 +294,10 @@ parseGreaterThan: %ParseForm -> %Form
parseGreaterThan t ==
t isnt [op,x,y] => systemErrorHere "parseGreaterThan"
[substitute("<",">",op),parseTran y,parseTran x]
-
parseGreaterEqual: %ParseForm -> %Form
parseGreaterEqual u ==
parseTran ["not",[substitute("<",">=",first u),:rest u]]
-
parseLessEqual: %ParseForm -> %Form
parseLessEqual u ==
@@ -298,7 +305,8 @@ parseLessEqual u ==
parseNotEqual: %ParseForm -> %Form
parseNotEqual u ==
- parseTran ["not",[substitute("=","^=",first u),:rest u]]
+ $normalizeTree => parseTran ["not",[substitute("=","^=",first u),:rest u]]
+ u
parseAnd: %ParseForm -> %Form
parseAnd t ==
@@ -317,7 +325,7 @@ parseOr t ==
null rest u => first u
(x:= parseTran first u) is ["not",y] =>
parseIf ["IF",y,parseOr ["or",:rest u],"true"]
- true => parseIf ["IF",x,"true",parseOr ["or",:rest u]]
+ parseIf ["IF",x,"true",parseOr ["or",:rest u]]
parseEquivalence: %ParseForm -> %Form
@@ -420,8 +428,8 @@ parseIf t ==
t isnt ["IF",p,a,b] => t
ifTran(parseTran p,parseTran a,parseTran b) where
ifTran(p,a,b) ==
- null($InteractiveMode) and p="true" => a
- null($InteractiveMode) and p="false" => b
+ not $InteractiveMode and p="true" => a
+ not $InteractiveMode and p="false" => b
p is ["not",p'] => ifTran(p',b,a)
p is ["IF",p',a',b'] => ifTran(p',ifTran(a',COPY a,COPY b),ifTran(b',a,b))
p is ["SEQ",:l,["exit",1,p']] =>