diff options
author | dos-reis <gdr@axiomatics.org> | 2008-07-23 05:16:50 +0000 |
---|---|---|
committer | dos-reis <gdr@axiomatics.org> | 2008-07-23 05:16:50 +0000 |
commit | c5b5b8c2d510d3719704347840982b685fe8220d (patch) | |
tree | f31fb6e1451b4910b4a65296c239cbb9772a4ee1 /src/interp | |
parent | ccbb46defe28a8aa9e554d25d1542c8353a4cf4f (diff) | |
download | open-axiom-c5b5b8c2d510d3719704347840982b685fe8220d.tar.gz |
Misc cleanup.
Diffstat (limited to 'src/interp')
-rw-r--r-- | src/interp/astr.boot | 33 | ||||
-rw-r--r-- | src/interp/posit.boot | 54 |
2 files changed, 55 insertions, 32 deletions
diff --git a/src/interp/astr.boot b/src/interp/astr.boot index ecf8768a..b506c23a 100644 --- a/src/interp/astr.boot +++ b/src/interp/astr.boot @@ -33,6 +33,11 @@ import vmlisp namespace BOOT +module astr where + ncTag: %Thing -> %Symbol + ncAlist: %Thing -> %List + ncEltQ: %List -> %Thing + ncPutQ: (%List,%Thing,%Thing) -> %Thing --% Attributed Structures (astr) -- For objects which are pairs where the CAR field is either just a tag @@ -40,25 +45,25 @@ namespace BOOT -- Pick off the tag ncTag x == - not PAIRP x => ncBug('S2CB0031,[]) - x := QCAR x + atom x => ncBug('S2CB0031,[]) + x := first x IDENTP x => x - not PAIRP x => ncBug('S2CB0031,[]) - QCAR x + atom x => ncBug('S2CB0031,[]) + first x -- Pick off the property list ncAlist x == - not PAIRP x => ncBug('S2CB0031,[]) - x := QCAR x - IDENTP x => NIL - not PAIRP x => ncBug('S2CB0031,[]) - QCDR x + atom x => ncBug('S2CB0031,[]) + x := first x + IDENTP x => nil + atom x => ncBug('S2CB0031,[]) + rest x --- Get the entry for key k on x's association list ncEltQ(x,k) == r := QASSQ(k,ncAlist x) - NULL r => ncBug ('S2CB0007,[k]) - CDR r + null r => ncBug ('S2CB0007,[k]) + rest r -- Put (k . v) on the association list of x and return v -- case1: ncPutQ(x,k,v) where k is a key (an identifier), v a value @@ -70,9 +75,9 @@ ncPutQ(x,k,v) == for key in k for val in v repeat ncPutQ(x,key,val) v r := QASSQ(k,ncAlist x) - if NULL r then - r := CONS( CONS(k,v), ncAlist x) - RPLACA(x,CONS(ncTag x,r)) + if null r then + r := [[k,:v], :ncAlist x] + RPLACA(x,[ncTag x,:r]) else RPLACD(r,v) v diff --git a/src/interp/posit.boot b/src/interp/posit.boot index 0e12dbfc..77911e8b 100644 --- a/src/interp/posit.boot +++ b/src/interp/posit.boot @@ -1,6 +1,6 @@ -- Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -- All rights reserved. --- Copyright (C) 2007, Gabriel Dos Reis. +-- Copyright (C) 2007-2008, Gabriel Dos Reis. -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without @@ -34,6 +34,11 @@ import sys_-macros import astr namespace BOOT +module posit where + %Position <=> %List + tokType: %List -> %Symbol + tokPart: %List -> %Thing + tokPosn: %List -> %Position $nopos == ['noposition] @@ -52,7 +57,7 @@ pfPosOrNopos pf == poNoPosition() poIsPos? pos == - PAIRP pos and PAIRP CAR pos and LENGTH CAR pos = 5 + PAIRP pos and PAIRP first pos and #first pos = 5 lnCreate(extBl, st, gNo, :optFileStuff) == lNo := @@ -81,7 +86,7 @@ lnFileName lineObject == ncBug('"there is no file name in %1", [lineObject] ) lnFileName? lineObject == - NOT PAIRP (fN := lineObject.4) => NIL + atom (fN := lineObject.4) => nil fN lnPlaceOfOrigin lineObject == @@ -91,7 +96,8 @@ lnImmediate? lineObject == not lnFileName? lineObject poGetLineObject posn == - CAR posn + first posn + pfGetLineObject posn == poGetLineObject posn pfSourceStok x== @@ -113,23 +119,25 @@ pfSourceToken form == tokConstruct(hd,tok,:pos)== a:=cons(hd,tok) IFCAR pos => - pfNoPosition? CAR pos=> a - ncPutQ(a,"posn",CAR pos) + pfNoPosition? first pos=> a + ncPutQ(a,"posn",first pos) a a tokType x== ncTag x -tokPart x== CDR x + +tokPart x== rest x + tokPosn x== a:= QASSQ("posn",ncAlist x) - if a then CDR a else pfNoPosition() + if a then rest a else pfNoPosition() pfAbSynOp form == - hd := CAR form + hd := first form IFCAR hd or hd pfAbSynOp?(form, op) == - hd := CAR form + hd := first form EQ(hd, op) or EQCAR(hd, op) pfLeaf? form == @@ -141,10 +149,10 @@ pfLeaf(x,y,:z) == tokConstruct(x,y, IFCAR z or pfNoPosition()) pfLeafToken form == tokPart form pfLeafPosition form == tokPosn form -pfTree(x,y) == CONS(x,y) -- was ==> -pfParts form == CDR form -- was ==> -pfFirst form == CADR form -- was ==> -pfSecond form == CADDR form -- was ==> +pfTree(x,y) == [x,:y] +pfParts form == rest form +pfFirst form == second form +pfSecond form == third form pfPosn pf == pfSourcePosition pf @@ -172,44 +180,54 @@ pfSourcePositionlist x== else APPEND(pfSourcePositions first x,pfSourcePositionlist rest x) -poCharPosn posn == CDR posn +poCharPosn posn == rest posn + pfCharPosn posn == poCharPosn posn poLinePosn posn == posn => lnLocalNum poGetLineObject posn --VECP posn => CDAR posn + pfLinePosn posn == poLinePosn posn poGlobalLinePosn posn == posn => lnGlobalNum poGetLineObject posn ncBug('"old style pos objects have no global positions",[]) + pfGlobalLinePosn posn == poGlobalLinePosn posn poFileName posn == posn => lnFileName poGetLineObject posn CAAR posn + pfFileName posn == poFileName posn poFileName? posn == - posn = ['noposition] => NIL + posn = ['noposition] => nil posn => lnFileName? poGetLineObject posn CAAR posn + pfFileName? posn == poFileName? posn poPlaceOfOrigin posn == lnPlaceOfOrigin poGetLineObject posn + pfPlaceOfOrigin posn == poPlaceOfOrigin posn poNopos? posn == posn = ['noposition] + pfNopos? posn == poNopos? posn + poPosImmediate? txp== - poNopos? txp => NIL + poNopos? txp => nil lnImmediate? poGetLineObject txp + pfPosImmediate? txp == poPosImmediate? txp poImmediate? txp== lnImmediate? poGetLineObject txp + pfImmediate? txp == poImmediate? txp @@ -222,7 +240,7 @@ pfPrintSrcLines(pf) == lines := pfSourcePositions pf lno := 0 for l in lines repeat - line := car l + line := first l if lno < lnGlobalNum(line) then FORMAT(true, '" ~A~%", lnString line) lno := lnGlobalNum(line) |