diff options
author | dos-reis <gdr@axiomatics.org> | 2011-10-19 20:57:45 +0000 |
---|---|---|
committer | dos-reis <gdr@axiomatics.org> | 2011-10-19 20:57:45 +0000 |
commit | 2227d0b0e896b63b8f27ff3ba8b9fc74495a8acb (patch) | |
tree | af68a239565e80812c1e32c6999c4d657b6b46e4 /src/interp | |
parent | 7b303a090ac77ca67771feb829a15ab3bab06122 (diff) | |
download | open-axiom-2227d0b0e896b63b8f27ff3ba8b9fc74495a8acb.tar.gz |
* interp/postpar.boot (postNormalizeName): New.
(postAtom): Use it.
(postMDef): Do not generate artificial list of nils.
Leave left-hand-side as written in source code.
* interp/compiler.boot (compMacro): Tidy.
* interp/define.boot (checkRepresentation): Likewise.
* interp/parse.boot (parseMDEF): Likewise.
* algebra/syntax.spad.pamphlet (MacroAst): Adjust.
Diffstat (limited to 'src/interp')
-rw-r--r-- | src/interp/compiler.boot | 11 | ||||
-rw-r--r-- | src/interp/define.boot | 2 | ||||
-rw-r--r-- | src/interp/parse.boot | 8 | ||||
-rw-r--r-- | src/interp/postpar.boot | 39 |
4 files changed, 35 insertions, 25 deletions
diff --git a/src/interp/compiler.boot b/src/interp/compiler.boot index 44dc7d4d..f2894cd6 100644 --- a/src/interp/compiler.boot +++ b/src/interp/compiler.boot @@ -995,7 +995,7 @@ $macroIfTrue := false compMacro(form,m,e) == $macroIfTrue: local:= true - ["MDEF",lhs,signature,specialCases,rhs] := form + ["MDEF",lhs,signature,rhs] := form if $verbose then prhs := rhs is ['CATEGORY,:.] => ['"-- the constructor category"] @@ -1007,13 +1007,14 @@ compMacro(form,m,e) == :formatUnabbreviated lhs,'" ==> ",:prhs,'"%d"] m=$EmptyMode or m=$NoValueMode => -- Macro names shall be identifiers. - not ident? lhs.op => - stackMessage('"invalid left-hand-side in macro definition",nil) - e + (lhs isnt [.,:.] and not ident? lhs) + or (lhs is [op,:.] and not ident? op) => + stackMessage('"invalid left-hand-side in macro definition",nil) + e -- We do not have the means, at this late stage, to make a distinction -- between a niladic functional macro and an identifier that is -- defined as a macro. - if lhs.args = nil then lhs := lhs.op + if lhs is [op] then lhs := op ["/throwAway",$NoValueMode,putMacro(lhs,macroExpand(rhs,e),e)] nil diff --git a/src/interp/define.boot b/src/interp/define.boot index 8c127081..5c09de68 100644 --- a/src/interp/define.boot +++ b/src/interp/define.boot @@ -740,7 +740,7 @@ checkRepresentation(addForm,body,env) == else if addForm ~= nil then stackWarning('"%1b differs from the base domain",["Rep"]) return hasAssignRep := true - stmt is ["MDEF",["Rep",:.],:.] => + stmt is ["MDEF","Rep",:.] => stackWarning('"Consider using == definition for %1b",["Rep"]) return hasAssignRep := true stmt is ["IF",.,:l] or stmt is ["SEQ",:l] or stmt is ["exit",:l] => diff --git a/src/interp/parse.boot b/src/interp/parse.boot index 2f9b94cc..a2934199 100644 --- a/src/interp/parse.boot +++ b/src/interp/parse.boot @@ -213,11 +213,9 @@ parseLhs x == parseMDEF: %ParseForm -> %Form parseMDEF t == - t isnt ["MDEF",$lhs,tList,specialList,body] => - systemErrorHere ["parseMDEF",t] - ["MDEF",parseTran $lhs,parseTypeList tList,parseTranList specialList, - parseTranCheckForRecord(body,opOf $lhs)] - + t isnt ["MDEF",$lhs,tList,body] => systemErrorHere ["parseMDEF",t] + ["MDEF",$lhs,parseTypeList tList,parseTranCheckForRecord(body,opOf $lhs)] + parseTranCheckForRecord: (%ParseForm,%ParseForm) -> %Form parseTranCheckForRecord(x,op) == x := parseTran x diff --git a/src/interp/postpar.boot b/src/interp/postpar.boot index e4148a8f..59b13294 100644 --- a/src/interp/postpar.boot +++ b/src/interp/postpar.boot @@ -162,14 +162,20 @@ postMakeCons l == postTran a ["cons",postTran first l,postMakeCons rest l] +postNormalizeName: %Symbol -> %Symbol +postNormalizeName x == + x = "T" => "T$" -- rename T in spad code to avoid clash with Lisp + x = "^" => "**" -- always use `**' internally for exponentiation + x + postAtom: %Atom -> %ParseForm postAtom x == - x=0 => $Zero - x=1 => $One - x='T => "T$" -- rename T in spad code to T$ - ident? x and niladicConstructor? x => [x] - x="," => "%Comma" - x = "^" => "**" -- always use `**' internally for exponentiation + x is 0 => $Zero + x is 1 => $One + x is "," => "%Comma" + ident? x => + niladicConstructor? x => [x] + postNormalizeName x x postBlock: %ParseTree -> %ParseForm @@ -245,21 +251,26 @@ postDefArgs argl == postMDef: %ParseTree -> %ParseForm postMDef(t) == [.,lhs,rhs] := t - lhs := postTran lhs + lhs := + ident? lhs => postNormalizeName lhs + lhs is [.,:.] => [postNormalizeName x for x in lhs] + lhs [form,targetType]:= - lhs is [":",:.] => rest lhs + lhs is [":",:.] => lhs.args [lhs,nil] - form:= - form isnt [.,:.] => [form] + newLhs := + form is [.,:.] => [(x is [":",a,:.] => a; x) for x in form] form - newLhs:= [(x is [":",a,:.] => a; x) for x in form] - typeList:= [targetType,:[(x is [":",.,t] => t; nil) for x in rest form]] - ["MDEF",newLhs,typeList,[nil for x in form],postTran rhs] + typeList := + form is [.,:.] => + [targetType,:[(x is [":",.,t] => t; nil) for x in rest form]] + nil + ["MDEF",newLhs,typeList,postTran rhs] postElt: %ParseTree -> %ParseForm postElt u == u isnt [.,a,b] => systemErrorHere ["postElt",u] - a:= postTran a + a := postTran a b is ["%Sequence",:.] => [["elt",a,"makeRecord"],:postTranList rest b] ["elt",a,postTran b] |