aboutsummaryrefslogtreecommitdiff
path: root/src/interp
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2013-06-02 08:46:56 +0000
committerdos-reis <gdr@axiomatics.org>2013-06-02 08:46:56 +0000
commit486d78fbea91e07509bc81249c44ae6014ef1d46 (patch)
treeadbf1e1c3c7ebf8bbbcfc621c187787505cf3736 /src/interp
parentc3af9dc192b5fa2ced867c777dcaa4c09cfa48ad (diff)
downloadopen-axiom-486d78fbea91e07509bc81249c44ae6014ef1d46.tar.gz
Make parser non-dependent on constructor databases.
Diffstat (limited to 'src/interp')
-rw-r--r--src/interp/c-doc.boot10
-rw-r--r--src/interp/compiler.boot25
-rw-r--r--src/interp/postpar.boot4
3 files changed, 34 insertions, 5 deletions
diff --git a/src/interp/c-doc.boot b/src/interp/c-doc.boot
index 5c87a1ed..ba640875 100644
--- a/src/interp/c-doc.boot
+++ b/src/interp/c-doc.boot
@@ -1,6 +1,6 @@
-- Copyright (c) 1991-2002, The Numerical Algorithms Group Ltd.
-- All rights reserved.
--- Copyright (C) 2007-2011, Gabriel Dos Reis.
+-- Copyright (C) 2007-2013, Gabriel Dos Reis.
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
@@ -136,10 +136,16 @@ collectAndDeleteAssoc x ==
y.rest := s
res
+instantiateNiladicsInDoc! docList ==
+ for [x,:.] in docList | x is [.,:.] repeat
+ x.opSig := instantiateNiladicsInList! x.opSig
+ docList
+
finalizeDocumentation db ==
ctor := dbConstructor db
unusedCommentLineNumbers := [x for (x := [n,:r]) in $COMBLOCKLIST | r]
- docList := substitute("$","%",transDocList($op,$docList))
+ docList := instantiateNiladicsInDoc!
+ substitute!("$","%",transDocList($op,$docList))
if u := [sig for [sig,:doc] in docList | null doc] then
for y in u repeat
y is 'constructor => noHeading := true
diff --git a/src/interp/compiler.boot b/src/interp/compiler.boot
index 3bcb0399..e6b9f2c8 100644
--- a/src/interp/compiler.boot
+++ b/src/interp/compiler.boot
@@ -2797,6 +2797,30 @@ preprocessParseTree pt ==
displayPreCompilationErrors()
nil
+++ Mutate parse form `pf' so that references to niladic constructors
+++ appear in instantiation form.
+instantiateNiladics! pf ==
+ ident? pf and niladicConstructor? pf => [pf]
+ do
+ pf isnt [.,:.] or pf.op is 'QUOTE => nil
+ pf.op in '(DEF MDEF) =>
+ -- Note: Normally, we wouldn't want to touch the definiendum;
+ -- except that some operators such as 'case' take flags,
+ -- so we want to solve them if they are types.
+ if second(pf) is [.,:.] then
+ second(pf).args := instantiateNiladicsInList! second(pf).args
+ third(pf) := instantiateNiladicsInList! third pf
+ fourth(pf) := instantiateNiladics! fourth pf
+ pf.op is 'SIGNATURE => third(pf) := instantiateNiladicsInList! third pf
+ pf.op isnt [.,:.] => pf.args := instantiateNiladicsInList! pf.args
+ instantiateNiladicsInList! pf
+ pf
+
+instantiateNiladicsInList! l ==
+ for xs in tails l repeat
+ xs.first := instantiateNiladics! first xs
+ l
+
++ Takes a parse tree `pt', typecheck it and compile it down
++ to VM instructions.
compileParseTree pt ==
@@ -2815,6 +2839,7 @@ compileParseTree pt ==
$returnMode: local := $EmptyMode
$exitModeStack: local := [] -- Used by the compiler proper
$leaveLevelStack: local := []
+ pf := instantiateNiladics! pf
if T := compTopLevel(pf,$EmptyMode,$InteractiveFrame) then
$InteractiveFrame := T.env
finishLine $OutputStream
diff --git a/src/interp/postpar.boot b/src/interp/postpar.boot
index eeebbfe0..7cdf7674 100644
--- a/src/interp/postpar.boot
+++ b/src/interp/postpar.boot
@@ -167,9 +167,7 @@ postAtom x ==
x is 0 => $Zero
x is 1 => $One
x is "," => "%Comma"
- ident? x =>
- niladicConstructor? x => [x]
- normalizeName x
+ ident? x => normalizeName x
x
postBlock: %ParseTree -> %ParseForm