From 7123c2aa973a96cfdd8a8afae08830577e66b0ee Mon Sep 17 00:00:00 2001 From: dos-reis Date: Mon, 19 May 2008 17:33:39 +0000 Subject: * boot/ast.boot: Cleanup. * boot/includer.boot: Likewise. * boot/parser.boot: Likewise. * boot/pile.boot: Likewise. * boot/scanner.boot: Likewise. * boot/tokens.boot: Likewise. * boot/translator.boot: Likewise. --- src/boot/ast.boot | 246 ++++++++++++++++++----------------- src/boot/includer.boot | 83 ++++++++---- src/boot/parser.boot | 98 +++++++------- src/boot/pile.boot | 48 ++++--- src/boot/scanner.boot | 97 +++++++++----- src/boot/strap/ast.clisp | 9 +- src/boot/strap/includer.clisp | 12 +- src/boot/strap/parser.clisp | 4 +- src/boot/strap/pile.clisp | 4 +- src/boot/strap/scanner.clisp | 3 +- src/boot/strap/tokens.clisp | 4 +- src/boot/strap/translator.clisp | 277 ++++++++++++++++++++++++++-------------- src/boot/tokens.boot | 14 +- src/boot/translator.boot | 2 +- 14 files changed, 532 insertions(+), 369 deletions(-) (limited to 'src') diff --git a/src/boot/ast.boot b/src/boot/ast.boot index 2e62c119..b0ca0ec4 100644 --- a/src/boot/ast.boot +++ b/src/boot/ast.boot @@ -39,8 +39,8 @@ -- import includer -module ast namespace BOOTTRAN +module ast ++ True means that Boot functions should be translated to use ++ hash tables to remember values. By default, functions are @@ -138,10 +138,12 @@ bfGenSymbol()== INTERN(CONCAT ('"bfVar#",STRINGIMAGE $GenVarCounter)) bfListOf: %List -> %List -bfListOf x==x +bfListOf x== + x bfColon: %Thing -> %List -bfColon x== ["COLON",x] +bfColon x== + ["COLON",x] bfColonColon: (%Symbol,%Symbol) -> %Symbol bfColonColon(package, name) == @@ -186,7 +188,7 @@ bfColonAppend(x,y) == if y is ["BVQUOTE",:a] then ["&REST",["QUOTE",:a]] else ["&REST",y] - else cons(CAR x,bfColonAppend(CDR x,y)) + else cons(first x,bfColonAppend(rest x,y)) bfDefinition: (%Thing,%Thing,%Thing) -> %List bfDefinition(bflhsitems, bfrhs,body) == @@ -214,9 +216,9 @@ compFluid id == compFluidize x== IDENTP x and bfBeginsDollar x=>compFluid x - ATOM x =>x + atom x =>x EQCAR(x,"QUOTE")=>x - cons(compFluidize(CAR x),compFluidize(CDR x)) + cons(compFluidize(first x),compFluidize(rest x)) bfTuple x== ["TUPLE",:x] @@ -254,19 +256,19 @@ bfMakeCons l == bfFor(bflhs,U,step) == if EQCAR (U,'tails) - then bfForTree('ON, bflhs, CADR U) + then bfForTree('ON, bflhs, second U) else if EQCAR(U,"SEGMENT") - then bfSTEP(bflhs,CADR U,step,CADDR U) + then bfSTEP(bflhs,second U,step,third U) else bfForTree('IN, bflhs, U) bfForTree(OP,lhs,whole)== whole:=if bfTupleP whole then bfMakeCons cdr whole else whole - ATOM lhs =>bfINON [OP,lhs,whole] - lhs:=if bfTupleP lhs then CADR lhs else lhs + atom lhs =>bfINON [OP,lhs,whole] + lhs:=if bfTupleP lhs then second lhs else lhs EQCAR(lhs,"L%T") => - G:=CADR lhs - [:bfINON [OP,G,whole],:bfSuchthat bfIS(G,CADDR lhs)] + G:=second lhs + [:bfINON [OP,G,whole],:bfSuchthat bfIS(G,third lhs)] G:=bfGenSymbol() [:bfINON [OP,G,whole],:bfSuchthat bfIS(G,lhs)] @@ -274,14 +276,14 @@ bfForTree(OP,lhs,whole)== bfSTEP(id,fst,step,lst)== initvar:=[id] initval:=[fst] - inc:=if ATOM step + inc:=if atom step then step else g1:=bfGenSymbol() initvar:=cons(g1,initvar) initval:=cons(step,initval) g1 - final:=if ATOM lst + final:=if atom lst then lst else g2:=bfGenSymbol() @@ -327,13 +329,13 @@ bfIterators x==["ITERATORS",:x] bfCross x== ["CROSS",:x] bfLp(iters,body)== - EQCAR (iters,"ITERATORS")=>bfLp1(CDR iters,body) - bfLpCross(CDR iters,body) + EQCAR (iters,"ITERATORS")=>bfLp1(rest iters,body) + bfLpCross(rest iters,body) bfLpCross(iters,body)== if null cdr iters - then bfLp(car iters,body) - else bfLp(car iters,bfLpCross(cdr iters,body)) + then bfLp(first iters,body) + else bfLp(first iters,bfLpCross(rest iters,body)) bfSep(iters)== if null iters @@ -344,7 +346,7 @@ bfSep(iters)== [append(i,j) for i in f for j in r] bfReduce(op,y)== - a:=if EQCAR(op,"QUOTE") then CADR op else op + a:=if EQCAR(op,"QUOTE") then second op else op op:=bfReName a init:=GET(op,"SHOETHETA") g:=bfGenSymbol() @@ -367,7 +369,7 @@ bfReduceCollect(op,y)== then body:=y.1 itl:=y.2 - a:=if EQCAR(op,"QUOTE") then CADR op else op + a:=if EQCAR(op,"QUOTE") then second op else op op:=bfReName a init:=GET(op,"SHOETHETA") bfOpReduce(op,init,body,itl) @@ -406,7 +408,7 @@ bfListReduce(op,y,itl)== bfLp1(iters,body)== [vars,inits,sucs,filters,exits,value]:=bfSep bfAppend iters nbody:=if null filters then body else bfAND [:filters,body] - value:=if null value then "NIL" else car value + value:=if null value then "NIL" else first value exits:= ["COND",[bfOR exits,["RETURN",value]], ['(QUOTE T),nbody]] loop := ["LOOP",exits,:sucs] @@ -415,10 +417,10 @@ bfLp1(iters,body)== loop bfLp2(extrait,itl,body)== - EQCAR (itl,"ITERATORS")=>bfLp1(cons(extrait,CDR itl),body) - iters:=cdr itl + EQCAR (itl,"ITERATORS")=>bfLp1(cons(extrait,rest itl),body) + iters:=rest itl bfLpCross - ([["ITERATORS",extrait,:CDAR iters],:CDR iters],body) + ([["ITERATORS",extrait,:CDAR iters],:rest iters],body) bfOpReduce(op,init,y,itl)== g:=bfGenSymbol() @@ -438,7 +440,7 @@ bfOpReduce(op,init,y,itl)== extrait:= [[[g],[init],[],[],[],[g]]] bfMKPROGN [['L%T,g1,y],bfLp2(extrait,itl,body)] else - init:=car init + init:=first init extrait:= [[[g],[init],[],[],[],[g]]] bfLp2(extrait,itl,body) @@ -463,21 +465,22 @@ bfLocal(a,b)== bfTake(n,x)== null x=>x n=0 => nil - cons(car x,bfTake(n-1,cdr x)) + cons(first x,bfTake(n-1,rest x)) bfDrop(n,x)== null x or n=0 =>x - bfDrop(n-1,cdr x) + bfDrop(n-1,rest x) -bfDefSequence l == ['SEQ,: l] +bfDefSequence l == + ['SEQ,: l] bfReturnNoName a == ["RETURN",a] bfSUBLIS(p,e)== - ATOM e=>bfSUBLIS1(p,e) + atom e=>bfSUBLIS1(p,e) EQCAR(e,"QUOTE")=>e - cons(bfSUBLIS(p,car e),bfSUBLIS(p,cdr e)) + cons(bfSUBLIS(p,first e),bfSUBLIS(p,rest e)) +++ Returns e/p, where e is an atom. We assume that the +++ DEFs form a system admitting a fix point; otherwise we may @@ -486,15 +489,15 @@ bfSUBLIS(p,e)== +++ We don't enforce that restriction though. bfSUBLIS1(p,e)== null p =>e - f:=CAR p - EQ(CAR f,e)=> bfSUBLIS(p, CDR f) + f:=first p + EQ(first f,e)=> bfSUBLIS(p, rest f) bfSUBLIS1(cdr p,e) defSheepAndGoats(x)== EQCAR (x,"DEF") => [def,op,args,body]:=x argl:=if bfTupleP args - then cdr args + then rest args else [args] if null argl then @@ -505,20 +508,21 @@ defSheepAndGoats(x)== opassoc:=[[op,:op1]] defstack:=[["DEF",op1,args,body]] [opassoc,defstack,[]] - EQCAR (x,"SEQ") => defSheepAndGoatsList(cdr x) + EQCAR (x,"SEQ") => defSheepAndGoatsList(rest x) [[],[],[x]] defSheepAndGoatsList(x)== if null x then [[],[],[]] else - [opassoc,defs,nondefs] := defSheepAndGoats car x - [opassoc1,defs1,nondefs1] := defSheepAndGoatsList cdr x + [opassoc,defs,nondefs] := defSheepAndGoats first x + [opassoc1,defs1,nondefs1] := defSheepAndGoatsList rest x [append(opassoc,opassoc1),append(defs,defs1), append(nondefs,nondefs1)] --% LET -bfLetForm(lhs,rhs) == ['L%T,lhs,rhs] +bfLetForm(lhs,rhs) == + ['L%T,lhs,rhs] bfLET1(lhs,rhs) == IDENTP lhs => bfLetForm(lhs,rhs) @@ -527,26 +531,26 @@ bfLET1(lhs,rhs) == rhs1 := bfLET2(lhs,rhs) EQCAR(rhs1,'L%T) => bfMKPROGN [rhs1,rhs] EQCAR(rhs1,'PROGN) => APPEND(rhs1,[rhs]) - if IDENTP CAR rhs1 then rhs1 := CONS(rhs1,NIL) + if IDENTP first rhs1 then rhs1 := CONS(rhs1,NIL) bfMKPROGN [:rhs1,rhs] - CONSP(rhs) and EQCAR(rhs,'L%T) and IDENTP(name := CADR rhs) => + CONSP(rhs) and EQCAR(rhs,'L%T) and IDENTP(name := second rhs) => -- handle things like [a] := x := foo - l1 := bfLET1(name,CADDR rhs) + l1 := bfLET1(name,third rhs) l2 := bfLET1(lhs,name) - EQCAR(l2,'PROGN) => bfMKPROGN [l1,:CDR l2] - if IDENTP CAR l2 then l2 := cons(l2,nil) + EQCAR(l2,'PROGN) => bfMKPROGN [l1,:rest l2] + if IDENTP first l2 then l2 := cons(l2,nil) bfMKPROGN [l1,:l2,name] g := INTERN CONCAT('"LETTMP#",STRINGIMAGE $letGenVarCounter) $letGenVarCounter := $letGenVarCounter + 1 rhs1 := ['L%T,g,rhs] let1 := bfLET1(lhs,g) - EQCAR(let1,'PROGN) => bfMKPROGN [rhs1,:CDR let1] - if IDENTP CAR let1 then let1 := CONS(let1,NIL) + EQCAR(let1,'PROGN) => bfMKPROGN [rhs1,:rest let1] + if IDENTP first let1 then let1 := CONS(let1,NIL) bfMKPROGN [rhs1,:let1,g] bfCONTAINED(x,y)== EQ(x,y) => true - ATOM y=> false + atom y=> false bfCONTAINED(x,car y) or bfCONTAINED(x,cdr y) bfLET2(lhs,rhs) == @@ -556,19 +560,19 @@ bfLET2(lhs,rhs) == lhs is ['L%T,a,b] => a := bfLET2(a,rhs) null (b := bfLET2(b,rhs)) => a - ATOM b => [a,b] - CONSP CAR b => CONS(a,b) + atom b => [a,b] + CONSP first b => CONS(a,b) [a,b] lhs is ['CONS,var1,var2] => var1 = "DOT" or (CONSP(var1) and EQCAR(var1,'QUOTE)) => bfLET2(var2,addCARorCDR('CDR,rhs)) l1 := bfLET2(var1,addCARorCDR('CAR,rhs)) null var2 or EQ(var2,"DOT") =>l1 - if CONSP l1 and ATOM CAR l1 then l1 := cons(l1,nil) + if CONSP l1 and atom first l1 then l1 := cons(l1,nil) IDENTP var2 => [:l1,bfLetForm(var2,addCARorCDR('CDR,rhs))] l2 := bfLET2(var2,addCARorCDR('CDR,rhs)) - if CONSP l2 and ATOM CAR l2 then l2 := cons(l2,nil) + if CONSP l2 and atom first l2 then l2 := cons(l2,nil) APPEND(l1,l2) lhs is ['APPEND,var1,var2] => patrev := bfISReverse(var2,var1) @@ -576,10 +580,10 @@ bfLET2(lhs,rhs) == g := INTERN CONCAT('"LETTMP#", STRINGIMAGE $letGenVarCounter) $letGenVarCounter := $letGenVarCounter + 1 l2 := bfLET2(patrev,g) - if CONSP l2 and ATOM CAR l2 then l2 := cons(l2,nil) + if CONSP l2 and atom first l2 then l2 := cons(l2,nil) var1 = "DOT" => [['L%T,g,rev],:l2] last l2 is ['L%T, =var1, val1] => - [['L%T,g,rev],:REVERSE CDR REVERSE l2, + [['L%T,g,rev],:REVERSE rest REVERSE l2, bfLetForm(var1,['NREVERSE,val1])] [['L%T,g,rev],:l2,bfLetForm(var1,['NREVERSE,var1])] lhs is ["EQUAL",var1] => @@ -605,18 +609,18 @@ bfLET(lhs,rhs) == addCARorCDR(acc,expr) == NULL CONSP expr => [acc,expr] acc = 'CAR and EQCAR(expr,'REVERSE) => - ["CAR",["LAST",:CDR expr]] - -- cons('last,CDR expr) + ["CAR",["LAST",:rest expr]] + -- cons('last,rest expr) funs := '(CAR CDR CAAR CDAR CADR CDDR CAAAR CADAR CAADR CADDR CDAAR CDDAR CDADR CDDDR) - p := bfPosition(CAR expr,funs) + p := bfPosition(first expr,funs) p = -1 => [acc,expr] funsA := '(CAAR CADR CAAAR CADAR CAADR CADDR CAAAAR CAADAR CAAADR CAADDR CADAAR CADDAR CADADR CADDDR) funsR := '(CDAR CDDR CDAAR CDDAR CDADR CDDDR CDAAAR CDADAR CDAADR CDADDR CDDAAR CDDDAR CDDADR CDDDDR) - if acc = 'CAR then CONS(funsA.p,CDR expr) - else CONS(funsR.p,CDR expr) + if acc = 'CAR then CONS(funsA.p,rest expr) + else CONS(funsR.p,rest expr) bfPosition(x,l) == bfPosn(x,l,0) bfPosn(x,l,n) == @@ -638,21 +642,21 @@ bfIS(left,right)== bfISReverse(x,a) == x is ['CONS,:.] => - NULL CADDR x => ['CONS,CADR x, a] - y := bfISReverse(CADDR x, NIL) - RPLACA(CDDR y,['CONS,CADR x,a]) + null third x => ['CONS,second x, a] + y := bfISReverse(third x, NIL) + RPLACA(CDDR y,['CONS,second x,a]) y bpSpecificErrorHere '"Error in bfISReverse" bpTrap() bfIS1(lhs,rhs) == - NULL rhs => + null rhs => ['NULL,lhs] STRINGP rhs => ['EQ,lhs,['QUOTE,INTERN rhs]] NUMBERP rhs => ["EQUAL",lhs,rhs] - ATOM rhs => + atom rhs => ['PROGN,bfLetForm(rhs,lhs),''T] rhs is ['QUOTE,a] => IDENTP a => ['EQ,lhs,rhs] @@ -693,7 +697,7 @@ bfIS1(lhs,rhs) == $isGenVarCounter := $isGenVarCounter + 1 rev := bfAND [['CONSP,lhs],['PROGN,['L%T,g,['REVERSE,lhs]],''T]] l2 := bfIS1(g,patrev) - if CONSP l2 and ATOM CAR l2 then l2 := cons(l2,nil) + if CONSP l2 and atom first l2 then l2 := cons(l2,nil) a = "DOT" => bfAND [rev,:l2] bfAND [rev,:l2,['PROGN,bfLetForm(a,['NREVERSE,a]),''T]] bpSpecificErrorHere '"bad IS code is generated" @@ -701,7 +705,7 @@ bfIS1(lhs,rhs) == bfApplication(bfop, bfarg) == if bfTupleP bfarg - then cons(bfop,CDR bfarg) + then cons(bfop,rest bfarg) else cons(bfop,[bfarg]) @@ -720,7 +724,7 @@ bfApplication(bfop, bfarg) == -- return the meaning of the x in Old Boot. bfGetOldBootName x == - a := GET(x, "OLD-BOOT") => car a + a := GET(x, "OLD-BOOT") => first a x -- returns true if x has same meaning in both Old Boot and New Boot. @@ -730,7 +734,7 @@ bfSameMeaning x == -- returns the meaning of x in the appropriate Boot dialect. bfReName x== newName := - a := GET(x,"SHOERENAME") => car a + a := GET(x,"SHOERENAME") => first a x $translatingOldBoot and not bfSameMeaning x => oldName := bfGetOldBootName x @@ -759,25 +763,25 @@ bfNOT x== ["NOT",x] bfFlatten(op, x) == - EQCAR(x,op) => CDR x + EQCAR(x,op) => rest x [x] bfOR l == null l => NIL - null cdr l => CAR l + null rest l => first l ["OR",:[:bfFlatten("OR",c) for c in l]] bfAND l == null l=> 'T - null cdr l => CAR l + null rest l => first l ["AND",:[:bfFlatten("AND",c) for c in l]] -defQuoteId x== EQCAR(x,"QUOTE") and IDENTP CADR x +defQuoteId x== EQCAR(x,"QUOTE") and IDENTP second x bfSmintable x== INTEGERP x or CONSP x and - MEMQ(CAR x, '(SIZE LENGTH)) + MEMQ(first x, '(SIZE LENGTH)) bfQ(l,r)== if bfSmintable l or bfSmintable r @@ -812,16 +816,16 @@ bfGargl argl== if null argl then [[],[],[],[]] else - [a,b,c,d]:=bfGargl cdr argl - if car argl="&REST" - then [cons(car argl,b),b,c, - cons(["CONS",["QUOTE","LIST"],car d],cdr d)] + [a,b,c,d]:=bfGargl rest argl + if first argl="&REST" + then [cons(first argl,b),b,c, + cons(["CONS",["QUOTE","LIST"],first d],rest d)] else f:=bfGenSymbol() - [cons(f,a),cons(f,b),cons(car argl,c),cons(f,d)] + [cons(f,a),cons(f,b),cons(first argl,c),cons(f,d)] bfDef1 [defOp,op,args,body] == - argl:=if bfTupleP args then cdr args else [args] + argl:=if bfTupleP args then rest args else [args] [quotes,control,arglp,body]:=bfInsertLet (argl,body) quotes=>shoeLAM(op,arglp,control,body) [[op,["LAMBDA",arglp,body]]] @@ -840,12 +844,14 @@ bfDef(defOp,op,args,body) == bfTuple [:shoeComps bfDef1 d for d in cons([defOp,op,args,body],$wheredefs)] -shoeComps x==[shoeComp def for def in x] +shoeComps x== + [shoeComp def for def in x] + shoeComp x== - a:=shoeCompTran CADR x + a:=shoeCompTran second x if EQCAR(a,"LAMBDA") - then ["DEFUN",CAR x,CADR a,:CDDR a] - else ["DEFMACRO",CAR x,CADR a,:CDDR a] + then ["DEFUN",first x,second a,:CDDR a] + else ["DEFMACRO",first x,second a,:CDDR a] ++ Translate function parameter list to Lisp. @@ -872,8 +878,8 @@ bfInsertLet(x,body)== then [true,"QUOTE",["&REST",b],body] else [false,nil,x,body] else - [b,norq,name1,body1]:= bfInsertLet1 (car x,body) - [b1,norq1,name2,body2]:= bfInsertLet (cdr x,body1) + [b,norq,name1,body1]:= bfInsertLet1 (first x,body) + [b1,norq1,name2,body2]:= bfInsertLet (rest x,body1) [b or b1,cons(norq,norq1),bfParameterList(name1,name2),body2] bfInsertLet1(y,body)== @@ -881,14 +887,14 @@ bfInsertLet1(y,body)== IDENTP y => [false,nil,y,body] y is ["BVQUOTE",b] => [true,"QUOTE",b,body] g:=bfGenSymbol() - ATOM y => [false,nil,g,body] + 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 - args :=CADR x + lamtype:=first x + args :=second x body :=CDDR x $fluidVars:local:=nil $locVars:local:=nil @@ -935,18 +941,18 @@ shoeFluids x== if EQCAR(x,"QUOTE") then [] else - if ATOM x + if atom x then nil - else append(shoeFluids car x,shoeFluids cdr x) + else append(shoeFluids first x,shoeFluids rest x) shoeATOMs x== if null x then nil - else if ATOM x + else if atom x then [x] - else append(shoeATOMs car x,shoeATOMs cdr x) + else append(shoeATOMs first x,shoeATOMs rest x) shoeCompTran1 x== - ATOM x=> + atom x=> IDENTP x and bfBeginsDollar x=> $dollarVars:= MEMQ(x,$dollarVars)=>$dollarVars @@ -967,19 +973,19 @@ shoeCompTran1 x== cons(l,$dollarVars) EQCAR(l,"FLUID")=> $fluidVars:= - MEMQ(CADR l,$fluidVars)=>$fluidVars - cons(CADR l,$fluidVars) - RPLACA (CDR x,CADR l) + MEMQ(second l,$fluidVars)=>$fluidVars + cons(second l,$fluidVars) + RPLACA (rest x,second l) MEMQ(U,'(PROG LAMBDA))=> newbindings:=nil - for y in CADR x repeat + for y in second x repeat not MEMQ(y,$locVars)=> $locVars:=cons(y,$locVars) newbindings:=cons(y,newbindings) res:=shoeCompTran1 CDDR x $locVars:=[y for y in $locVars | not MEMQ(y,newbindings)] - shoeCompTran1 car x - shoeCompTran1 cdr x + shoeCompTran1 first x + shoeCompTran1 rest x bfTagged(a,b)== null $op => Signature(a,b) -- surely a toplevel decl @@ -992,12 +998,12 @@ bfTagged(a,b)== ["THE",b,a] bfAssign(l,r)== - if bfTupleP l then bfSetelt(CADR l,CDDR l ,r) else bfLET(l,r) + if bfTupleP l then bfSetelt(second l,CDDR l ,r) else bfLET(l,r) bfSetelt(e,l,r)== - if null cdr l + if null rest l then defSETELT(e,car l,r) - else bfSetelt(bfElt(e,car l),cdr l,r) + else bfSetelt(bfElt(e,first l),rest l,r) bfElt(expr,sel)== y:=SYMBOLP sel and GET(sel,"SHOESELFUNCTION") @@ -1014,30 +1020,31 @@ defSETELT(var,sel,expr)== ["SETF",["ELT",var,sel],expr] bfIfThenOnly(a,b)== - b1:=if EQCAR (b,"PROGN") then CDR b else [b] + b1:=if EQCAR (b,"PROGN") then rest b else [b] ["COND",[a,:b1]] bfIf(a,b,c)== - b1:=if EQCAR (b,"PROGN") then CDR b else [b] - EQCAR (c,"COND") => ["COND",[a,:b1],:CDR c] - c1:=if EQCAR (c,"PROGN") then CDR c else [c] + b1:=if EQCAR (b,"PROGN") then rest b else [b] + EQCAR (c,"COND") => ["COND",[a,:b1],:rest c] + c1:=if EQCAR (c,"PROGN") then rest c else [c] ["COND",[a,:b1],['(QUOTE T),:c1]] -bfExit(a,b)== ["COND",[a,["IDENTITY",b]]] +bfExit(a,b)== + ["COND",[a,["IDENTITY",b]]] bfMKPROGN l== a:=[:bfFlattenSeq c for c in tails l] null a=> nil - null CDR a=> CAR a + null rest a=> first a ["PROGN",:a] bfFlattenSeq x == null x=>NIL - f:=CAR x - ATOM f =>if CDR x then nil else [f] + f:=first x + atom f =>if rest x then nil else [f] EQCAR(f,"PROGN") => - CDR x=> [i for i in CDR f| not ATOM i] - CDR f + rest x=> [i for i in rest f| not atom i] + rest f [f] bfSequence l == @@ -1051,7 +1058,7 @@ bfSequence l == null rest l => f:=first l if EQCAR(f,"PROGN") - then bfSequence CDR f + then bfSequence rest f else f bfMKPROGN [first l,bfSequence rest l] null aft => ["COND",:transform] @@ -1070,7 +1077,8 @@ bfWhere (context,expr)== -- null exp => nil -- cons(exp,shoeReadLispString(s,ind)) -bfReadLisp string==bfTuple shoeReadLispString (string,0) +bfReadLisp string == + bfTuple shoeReadLispString (string,0) bfCompHash(op,argl,body) == auxfn:= INTERN CONCAT (PNAME op,'";") @@ -1119,7 +1127,7 @@ bfNameOnly x== bfNameArgs: (%Thing,%Thing) -> %List bfNameArgs (x,y)== - y:=if EQCAR(y,"TUPLE") then CDR y else [y] + y:=if EQCAR(y,"TUPLE") then rest y else [y] cons(x,y) bfStruct: (%Thing,%List) -> %List @@ -1128,13 +1136,13 @@ bfStruct(name,arglist)== bfCreateDef: %Thing -> %List bfCreateDef x== - if null cdr x + if null rest x then - f:=car x + f:=first x ["DEFCONSTANT",f,["LIST",["QUOTE",f]]] else - a:=[bfGenSymbol() for i in cdr x] - ["DEFUN",car x,a,["CONS",["QUOTE",car x],["LIST",:a]]] + a:=[bfGenSymbol() for i in rest x] + ["DEFUN",first x,a,["CONS",["QUOTE",first x],["LIST",:a]]] bfCaseItem: (%Thing,%Thing) -> %List bfCaseItem(x,y) == @@ -1155,12 +1163,12 @@ bfCaseItems(g,x) == bfCI: (%Thing,%Thing,%Thing) -> %List bfCI(g,x,y)== - a:=cdr x + a:=rest x if null a - then [car x,y] + then [first x,y] else b:=[[i,bfCARCDR(j,g)] for i in a for j in 0..] - [car x,["LET",b,y]] + [first x,["LET",b,y]] bfCARCDR: (%Short,%Thing) -> %List bfCARCDR(n,g) == diff --git a/src/boot/includer.boot b/src/boot/includer.boot index 27f0c5ab..481f099c 100644 --- a/src/boot/includer.boot +++ b/src/boot/includer.boot @@ -38,8 +38,8 @@ -- import tokens -module includer namespace BOOTTRAN +module includer -- BOOT INCLUDER @@ -77,7 +77,8 @@ PNAME x == char x == CHAR(PNAME x, 0) -EQCAR(x,y)== CONSP x and EQ(first x,y) +EQCAR(x,y)== + CONSP x and EQ(first x,y) -- returns the string representation of object X. STRINGIMAGE x == @@ -106,7 +107,8 @@ shoeReadLine stream == shoeConsole line == WRITE_-LINE(line, _*TERMINAL_-IO_*) -shoeSpaces n == MAKE_-FULL_-CVEC(n, '".") +shoeSpaces n == + MAKE_-FULL_-CVEC(n, '".") --% @@ -140,9 +142,14 @@ bpIgnoredFromTo(pos1, pos2) == -- Line inclusion support. -lineNo p==CDAAR p -lineString p==CAAAR p -lineCharacter p==rest p +lineNo p == + CDAAR p + +lineString p == + CAAAR p + +lineCharacter p == + rest p shoePackageStartsAt (lines,sz,name,stream)== bStreamNull stream => [[],['nullstream]] @@ -181,12 +188,13 @@ $bStreamNil:=["nullstream"] bStreamNull x== null x or EQCAR (x,"nullstream") => true while EQCAR(x,"nonnullstream") repeat - st:=APPLY(CADR x,CDDR x) + st:=apply(second x,CDDR x) RPLACA(x,first st) RPLACD(x,rest st) EQCAR(x,"nullstream") -bMap(f,x)==bDelay(function bMap1, [f,x]) +bMap(f,x) == + bDelay(function bMap1, [f,x]) bMap1(:z)== [f,x]:=z @@ -203,25 +211,29 @@ shoeFileMap(f, fn)== shoeInclude bAddLineNumber(bMap(f,bRgen a),bIgen 0) -bDelay(f,x)==cons("nonnullstream",[f,:x]) +bDelay(f,x) == + cons("nonnullstream",[f,:x]) -bAppend(x,y)==bDelay(function bAppend1,[x,y]) +bAppend(x,y) == + bDelay(function bAppend1,[x,y]) bAppend1(:z)== if bStreamNull first z - then if bStreamNull CADR z + then if bStreamNull second z then ["nullstream"] - else CADR z - else cons(CAAR z,bAppend(CDAR z,CADR z)) + else second z + else cons(CAAR z,bAppend(CDAR z,second z)) -bNext(f,s)==bDelay(function bNext1,[f,s]) +bNext(f,s) == + bDelay(function bNext1,[f,s]) bNext1(f,s)== bStreamNull s=> ["nullstream"] - h:= APPLY(f, [s]) + h:= apply(f, [s]) bAppend(first h,bNext(f,rest h)) -bRgen s==bDelay(function bRgen1,[s]) +bRgen s == + bDelay(function bRgen1,[s]) bRgen1(:s) == a:=shoeReadLine first s @@ -231,13 +243,15 @@ bRgen1(:s) == ["nullstream"] else cons(a,bRgen first s) -bIgen n==bDelay(function bIgen1,[n]) +bIgen n == + bDelay(function bIgen1,[n]) bIgen1(:n)== n:=first n+1 cons(n,bIgen n) -bAddLineNumber(f1,f2)==bDelay(function bAddLineNumber1,[f1,f2]) +bAddLineNumber(f1,f2) == + bDelay(function bAddLineNumber1,[f1,f2]) bAddLineNumber1(:f)== [f1,f2] := f @@ -247,13 +261,20 @@ bAddLineNumber1(:f)== -shoeFileInput fn==shoeFileMap(function IDENTITY,fn) +shoeFileInput fn == + shoeFileMap(function IDENTITY,fn) -shoePrefixLisp x== strconc('")lisp",x) -shoeLispFileInput fn== shoeFileMap(function shoePrefixLisp,fn) +shoePrefixLisp x == + strconc('")lisp",x) + +shoeLispFileInput fn== + shoeFileMap(function shoePrefixLisp,fn) -shoePrefixLine x== strconc('")line",x) -shoeLineFileInput fn== shoeFileMap(function shoePrefixLine,fn) +shoePrefixLine x== + strconc('")line",x) + +shoeLineFileInput fn== + shoeFileMap(function shoePrefixLine,fn) shoePrefix?(prefix,whole) == #prefix > #whole => false @@ -291,14 +312,14 @@ shoeBiteOff x== shoeFileName x== a:=shoeBiteOff x null a => '"" - c:=shoeBiteOff CADR a + c:=shoeBiteOff second a null c => first a strconc(first a,'".",first c) shoeFnFileName x== a:=shoeBiteOff x null a => ['"",'""] - c:=shoeFileName CADR a + c:=shoeFileName second a null c => [first a,'""] [first a, c] @@ -306,7 +327,9 @@ shoeFunctionFileInput [fun,fn]== shoeOpenInputFile (a,fn, shoeInclude bAddLineNumber( shoeFindLines(fn,fun,a),bIgen 0)) -shoeInclude s== bDelay(function shoeInclude1,[s]) +shoeInclude s == + bDelay(function shoeInclude1,[s]) + shoeInclude1 s== bStreamNull s=> s [h,:t] :=s @@ -337,7 +360,9 @@ shoeSimpleLine(h) == shoeLineSyntaxError(h) nil -shoeThen(keep,b,s)== bDelay(function shoeThen1,[keep,b,s]) +shoeThen(keep,b,s) == + bDelay(function shoeThen1,[keep,b,s]) + shoeThen1(keep,b,s)== bPremStreamNull s=> s [h,:t] :=s @@ -361,7 +386,9 @@ shoeThen1(keep,b,s)== keep1 and b1 => bAppend(shoeSimpleLine h,shoeThen(keep,b,t)) shoeThen(keep,b,t) -shoeElse(keep,b,s)== bDelay(function shoeElse1,[keep,b,s]) +shoeElse(keep,b,s) == + bDelay(function shoeElse1,[keep,b,s]) + shoeElse1(keep,b,s)== bPremStreamNull s=> s [h,:t] :=s diff --git a/src/boot/parser.boot b/src/boot/parser.boot index 129b3c91..1cf9330f 100644 --- a/src/boot/parser.boot +++ b/src/boot/parser.boot @@ -42,8 +42,8 @@ import includer import scanner import ast -module parser namespace BOOTTRAN +module parser ++ true when the current function definition has its parameters @@ -54,7 +54,7 @@ bpFirstToken()== $stok:= if null $inputStream then shoeTokConstruct("ERROR","NOMORE",shoeTokPosn $stok) - else CAR $inputStream + else first $inputStream $ttok:=shoeTokPart $stok true @@ -62,7 +62,7 @@ bpFirstTok()== $stok:= if null $inputStream then shoeTokConstruct("ERROR","NOMORE",shoeTokPosn $stok) - else CAR $inputStream + else first $inputStream $ttok:=shoeTokPart $stok $bpParenCount>0 and EQCAR($stok,"KEY") => EQ($ttok,"SETTAB")=> @@ -77,42 +77,42 @@ bpFirstTok()== true bpNext() == - $inputStream := CDR($inputStream) + $inputStream := rest($inputStream) bpFirstTok() bpNextToken() == - $inputStream := CDR($inputStream) + $inputStream := rest($inputStream) bpFirstToken() bpState()== [$inputStream,$stack,$bpParenCount,$bpCount] --cons($inputStream,$stack) bpRestore(x)== - $inputStream:=CAR x + $inputStream:=first x bpFirstToken() - $stack:=CADR x - $bpParenCount:=CADDR x + $stack:=second x + $bpParenCount:=third x $bpCount:=CADDDR x true -bpPush x==$stack:=CONS(x,$stack) +bpPush x==$stack:=[x,:$stack] bpPushId()== - $stack:=CONS(bfReName $ttok,$stack) + $stack:= [bfReName $ttok,:$stack] bpPop1()== - a:=CAR $stack - $stack:=CDR $stack + a:=first $stack + $stack:=rest $stack a bpPop2()== - a:=CADR $stack + a:=second $stack RPLACD($stack,CDDR $stack) a bpPop3()== - a:=CADDR $stack - RPLACD(CDR $stack,CDDDR $stack) + a:=third $stack + RPLACD(rest $stack,CDDDR $stack) a bpIndentParenthesized f== @@ -122,7 +122,7 @@ bpIndentParenthesized f== then $bpParenCount:=$bpParenCount+1 bpNext() - if APPLY(f,nil) and bpFirstTok() and + if apply(f,nil) and bpFirstTok() and (bpEqPeek "CPAREN" or bpParenTrap(a)) then $bpParenCount:=$bpParenCount-1 @@ -147,7 +147,7 @@ bpParenthesized f== a:=$stok if bpEqKey "OPAREN" then - if APPLY(f,nil) and (bpEqKey "CPAREN" or bpParenTrap(a)) + if apply(f,nil) and (bpEqKey "CPAREN" or bpParenTrap(a)) then true else if bpEqKey "CPAREN" then @@ -160,7 +160,7 @@ bpBracket f== a:=$stok if bpEqKey "OBRACK" then - if APPLY(f,nil) and (bpEqKey "CBRACK" or bpBrackTrap(a)) + if apply(f,nil) and (bpEqKey "CBRACK" or bpBrackTrap(a)) then bpPush bfBracket bpPop1 () else if bpEqKey "CBRACK" then bpPush [] @@ -171,21 +171,21 @@ bpPileBracketed f== if bpEqKey "SETTAB" then if bpEqKey "BACKTAB" then true - else if APPLY(f,nil) and + else if apply(f,nil) and (bpEqKey "BACKTAB" or bpPileTrap()) then bpPush bfPile bpPop1() else false else false bpListof(f,str1,g)== - if APPLY(f,nil) + if apply(f,nil) then - if bpEqKey str1 and (APPLY(f,nil) or bpTrap()) + if bpEqKey str1 and (apply(f,nil) or bpTrap()) then a:=$stack $stack:=nil - while bpEqKey str1 and (APPLY(f,nil) or bpTrap()) repeat 0 - $stack:=cons(NREVERSE $stack,a) + while bpEqKey str1 and (apply(f,nil) or bpTrap()) repeat 0 + $stack:=[NREVERSE $stack,:a] bpPush FUNCALL(g, [bpPop3(),bpPop2(),:bpPop1()]) else true @@ -194,52 +194,52 @@ bpListof(f,str1,g)== -- to do , bpListofFun(f,h,g)== - if APPLY(f,nil) + if apply(f,nil) then - if APPLY(h,nil) and (APPLY(f,nil) or bpTrap()) + if apply(h,nil) and (apply(f,nil) or bpTrap()) then a:=$stack $stack:=nil - while APPLY(h,nil) and (APPLY(f,nil) or bpTrap()) repeat 0 - $stack:=cons(NREVERSE $stack,a) + while apply(h,nil) and (apply(f,nil) or bpTrap()) repeat 0 + $stack:=[NREVERSE $stack,:a] bpPush FUNCALL(g, bfListOf [bpPop3(),bpPop2(),:bpPop1()]) else true else false bpList(f,str1,g)== - if APPLY(f,nil) + if apply(f,nil) then - if bpEqKey str1 and (APPLY(f,nil) or bpTrap()) + if bpEqKey str1 and (apply(f,nil) or bpTrap()) then a:=$stack $stack:=nil - while bpEqKey str1 and (APPLY(f,nil) or bpTrap()) repeat 0 - $stack:=cons(NREVERSE $stack,a) + while bpEqKey str1 and (apply(f,nil) or bpTrap()) repeat 0 + $stack:=[NREVERSE $stack,:a] bpPush FUNCALL(g, [bpPop3(),bpPop2(),:bpPop1()]) else bpPush FUNCALL(g, [bpPop1()]) else bpPush FUNCALL(g, []) bpOneOrMore f== - APPLY(f,nil)=> + apply(f,nil)=> a:=$stack $stack:=nil - while APPLY(f,nil) repeat 0 - $stack:=cons(NREVERSE $stack,a) - bpPush cons(bpPop2(),bpPop1()) + while apply(f,nil) repeat 0 + $stack:=[NREVERSE $stack,:a] + bpPush [bpPop2(),:bpPop1()] false -- s must transform the head of the stack bpAnyNo s== - while APPLY(s,nil) repeat 0 + while apply(s,nil) repeat 0 true -- AndOr(k,p,f)= k p bpAndOr(keyword,p,f)== - bpEqKey keyword and (APPLY(p,nil) or bpTrap()) + bpEqKey keyword and (apply(p,nil) or bpTrap()) and bpPush FUNCALL(f, bpPop1()) bpConditional f== @@ -248,17 +248,17 @@ bpConditional f== then if bpEqKey "SETTAB" then if bpEqKey "THEN" - then (APPLY(f,nil) or bpTrap()) and bpElse(f) and bpEqKey "BACKTAB" + then (apply(f,nil) or bpTrap()) and bpElse(f) and bpEqKey "BACKTAB" else bpMissing "THEN" else if bpEqKey "THEN" - then (APPLY(f,nil) or bpTrap()) and bpElse(f) + then (apply(f,nil) or bpTrap()) and bpElse(f) else bpMissing "then" else false bpElse(f)== a:=bpState() if bpBacksetElse() - then (APPLY(f,nil) or bpTrap()) and + then (apply(f,nil) or bpTrap()) and bpPush bfIf(bpPop3(),bpPop2(),bpPop1()) else bpRestore a @@ -309,7 +309,7 @@ bpListAndRecover(f)== c:=$inputStream while not done repeat -- $trapped:local:=false - found:=try APPLY(f,nil) catch TRAPPOINT + found:=try apply(f,nil) catch TRAPPOINT if found="TRAPPED" then $inputStream:=c @@ -334,7 +334,7 @@ bpListAndRecover(f)== else bpNext() c:=$inputStream - b:=cons(bpPop1(),b) + b:=[bpPop1(),:b] $stack:=a bpPush NREVERSE b @@ -518,8 +518,8 @@ bpSexp()== bpSexp1()== bpFirstTok() and bpSexp() and - (bpEqKey "DOT" and bpSexp() and bpPush CONS (bpPop2(),bpPop1())or - bpSexp1() and bpPush CONS (bpPop2(),bpPop1())) or + (bpEqKey "DOT" and bpSexp() and bpPush [bpPop2(),:bpPop1()] or + bpSexp1() and bpPush [bpPop2(),:bpPop1()]) or bpPush nil bpPrimary1() == @@ -581,7 +581,7 @@ bpInfGeneric s== bpInfKey s and (bpEqKey "BACKSET" or true) bpRightAssoc(o,p)== a:=bpState() - if APPLY(p,nil) + if apply(p,nil) then while bpInfGeneric o and (bpRightAssoc(o,p) or bpTrap()) repeat bpPush bfInfApplication(bpPop2(),bpPop2(),bpPop1()) @@ -591,10 +591,10 @@ bpRightAssoc(o,p)== false bpLeftAssoc(operations,parser)== - if APPLY(parser,nil) + if apply(parser,nil) then while bpInfGeneric(operations) and - (APPLY(parser,nil) or bpTrap()) + (apply(parser,nil) or bpTrap()) repeat bpPush bfInfApplication(bpPop2(),bpPop2(),bpPop1()) true @@ -807,7 +807,7 @@ bpDefinition()== false bpStoreName()== - $op := car $stack + $op := first $stack $wheredefs := nil $typings := nil $returnType := true -- assume we may return anything @@ -1059,7 +1059,7 @@ bpAssignLHS()== or bpEqKey "DOT" and bpList(function bpPrimary,"DOT", function bfListOf) and bpChecknull() and - bpPush bfTuple(cons(bpPop2(),bpPop1())) + bpPush bfTuple([bpPop2(),:bpPop1()]) or true) bpChecknull()== a:=bpPop1() diff --git a/src/boot/pile.boot b/src/boot/pile.boot index a95f4bbe..df1b0ecb 100644 --- a/src/boot/pile.boot +++ b/src/boot/pile.boot @@ -34,12 +34,17 @@ import includer import scanner -module pile namespace BOOTTRAN +module pile + +shoeFirstTokPosn t == + shoeTokPosn CAAR t + +shoeLastTokPosn t== + shoeTokPosn second t -shoeFirstTokPosn t== shoeTokPosn CAAR t -shoeLastTokPosn t== shoeTokPosn CADR t -shoePileColumn t==CDR shoeTokPosn CAAR t +shoePileColumn t== + rest shoeTokPosn CAAR t -- s is a token-dq-stream @@ -49,7 +54,7 @@ shoePileInsert (s)== else toktype:=shoeTokType CAAAR s if toktype ="LISP" or toktype = "LINE" - then cons([car s],cdr s) + then cons([first s],rest s) else a:=shoePileTree(-1,s) cons([a.2],a.3) @@ -58,7 +63,7 @@ shoePileTree(n,s)== if bStreamNull s then [false,n,[],s] else - [h,t]:=[car s,cdr s] + [h,t]:=[first s,rest s] hh:=shoePileColumn h if hh > n then shoePileForests(h,hh,t) @@ -68,7 +73,7 @@ eqshoePileTree(n,s)== if bStreamNull s then [false,n,[],s] else - [h,t]:=[car s,cdr s] + [h,t]:=[first s,rest s] hh:=shoePileColumn h if hh = n then shoePileForests(h,hh,t) @@ -96,47 +101,48 @@ shoePileForests(h,n,s)== then [true,n,h,s] else shoePileForests(shoePileCtree(h,h1),n,t1) -shoePileCtree(x,y)==dqAppend(x,shoePileCforest y) +shoePileCtree(x,y) == + dqAppend(x,shoePileCforest y) -- only enshoePiles forests with >=2 trees shoePileCforest x== if null x then [] - else if null cdr x - then car x + else if null rest x + then first x else - a:=car x + a:=first x b:=shoePileCoagulate(a,rest x) - if null cdr b - then car b + if null rest b + then first b else shoeEnPile shoeSeparatePiles b shoePileCoagulate(a,b)== if null b then [a] else - c:=car b + c:=first b if EQ(shoeTokPart CAAR c,"THEN") or EQ(shoeTokPart CAAR c,"ELSE") - then shoePileCoagulate (dqAppend(a,c),cdr b) + then shoePileCoagulate (dqAppend(a,c),rest b) else - d:=CADR a + d:=second a e:=shoeTokPart d if EQCAR(d,"KEY") and (GET(e,"SHOEINF") or EQ(e,"COMMA") or EQ(e,"SEMICOLON")) - then shoePileCoagulate(dqAppend(a,c),cdr b) + then shoePileCoagulate(dqAppend(a,c),rest b) else cons(a,shoePileCoagulate(c,rest b)) shoeSeparatePiles x== if null x then [] - else if null cdr x - then car x + else if null rest x + then first x else - a:=car x + a:=first x semicolon:=dqUnit shoeTokConstruct("KEY", "BACKSET",shoeLastTokPosn a) - dqConcat [a,semicolon,shoeSeparatePiles cdr x] + dqConcat [a,semicolon,shoeSeparatePiles rest x] shoeEnPile x== dqConcat [dqUnit shoeTokConstruct("KEY","SETTAB",shoeFirstTokPosn x), diff --git a/src/boot/scanner.boot b/src/boot/scanner.boot index 90a7945f..10067959 100644 --- a/src/boot/scanner.boot +++ b/src/boot/scanner.boot @@ -42,7 +42,9 @@ namespace BOOTTRAN double x == FLOAT(x, 1.0) -dqUnit s==(a:=[s];CONS(a,a)) +dqUnit s== + a := [s] + [a,:a] dqAppend(x,y)== if null x @@ -50,8 +52,8 @@ dqAppend(x,y)== else if null y then x else - RPLACD (CDR x,CAR y) - RPLACD (x, CDR y) + RPLACD (rest x,first y) + RPLACD (x, rest y) x dqConcat ld== @@ -61,22 +63,32 @@ dqConcat ld== then first ld else dqAppend(first ld,dqConcat rest ld) -dqToList s==if null s then nil else CAR s +dqToList s == + if null s then nil else first s -shoeConstructToken(ln,lp,b,n)==[b.0,b.1,:cons(lp,n)] -shoeTokType x== CAR x -shoeTokPart x== CADR x -shoeTokPosn x== CDDR x -shoeTokConstruct(x,y,z)==[x,y,:z] +shoeConstructToken(ln,lp,b,n) == + [b.0,b.1,:cons(lp,n)] + +shoeTokType x == + first x + +shoeTokPart x == + second x + +shoeTokPosn x == + CDDR x + +shoeTokConstruct(x,y,z) == + [x,y,:z] shoeNextLine(s)== if bStreamNull s then false else $linepos:=s - $f:= CAR s - $r:= CDR s - $ln:=CAR $f + $f:= first s + $r:= rest s + $ln:=first $f $n:=STRPOSL('" ",$ln,0,true) $sz :=# $ln null $n => true @@ -84,7 +96,7 @@ shoeNextLine(s)== a:=MAKE_-FULL_-CVEC (7-REM($n,8) ,'" ") $ln.$n:='" ".0 $ln:=CONCAT(a,$ln) - s1:=cons(cons($ln,CDR $f),$r) + s1:=cons(cons($ln,rest $f),$r) shoeNextLine s1 true @@ -106,7 +118,7 @@ shoeLineToks(s)== cons([dq],$r) command:=shoeLisp? $ln=> shoeLispToken($r,command) command:=shoePackage? $ln=> - -- z:=car shoeBiteOff command + -- z:=first shoeBiteOff command a:=CONCAT('"(IN-PACKAGE ",command,'")") dq:=dqUnit shoeConstructToken ($ln,$linepos,shoeLeafLisp a,0) @@ -147,7 +159,7 @@ shoeAccumulateLines(s,string)== -- returns true if token t is closing `parenthesis'. shoeCloser t == - MEMQ(shoeKeyWord t, '(CPAREN CBRACK)) + shoeKeyWord t in '(CPAREN CBRACK) shoeToken () == ln:=$ln @@ -180,31 +192,43 @@ shoeToken () == dqUnit shoeConstructToken(ln,linepos,b,n) -- to pair badge and badgee -shoeLeafId x== ["ID",INTERN x] +shoeLeafId x == + ["ID",INTERN x] -shoeLeafKey x==["KEY",shoeKeyWord x] +shoeLeafKey x== + ["KEY",shoeKeyWord x] -shoeLeafInteger x==["INTEGER",shoeIntValue x] +shoeLeafInteger x== + ["INTEGER",shoeIntValue x] shoeLeafFloat(a,w,e)== b:=shoeIntValue CONCAT(a,w) c:= double b * EXPT(double 10, e-#w) ["FLOAT",c] -shoeLeafString x == ["STRING",x] +shoeLeafString x == + ["STRING",x] -shoeLeafLisp x == ["LISP",x] -shoeLeafLispExp x == ["LISPEXP",x] +shoeLeafLisp x == + ["LISP",x] + +shoeLeafLispExp x == + ["LISPEXP",x] -shoeLeafLine x == ["LINE",x] +shoeLeafLine x == + ["LINE",x] -shoeLeafComment x == ["COMMENT", x] +shoeLeafComment x == + ["COMMENT", x] -shoeLeafNegComment x== ["NEGCOMMENT", x] +shoeLeafNegComment x== + ["NEGCOMMENT", x] -shoeLeafError x == ["ERROR",x] +shoeLeafError x == + ["ERROR",x] -shoeLeafSpaces x == ["SPACES",x] +shoeLeafSpaces x == + ["SPACES",x] shoeLispEscape()== $n:=$n+1 @@ -357,7 +381,8 @@ shoeIdEnd(line,n)== n -shoeDigit x== DIGIT_-CHAR_-P x +shoeDigit x== + DIGIT_-CHAR_-P x shoeW(b)== n1:=$n @@ -389,7 +414,8 @@ shoeWord(esp) == shoeLeafKey w else shoeLeafId w -shoeInteger()==shoeInteger1(false) +shoeInteger() == + shoeInteger1(false) shoeInteger1(zro) == n:=$n @@ -479,13 +505,17 @@ shoeError()== STRINGIMAGE QENUM($ln,n),'" is not a Boot character")) shoeLeafError ($ln.n) -shoeOrdToNum x== DIGIT_-CHAR_-P x +shoeOrdToNum x== + DIGIT_-CHAR_-P x -shoeKeyWord st == GETHASH(st,shoeKeyTable) +shoeKeyWord st == + GETHASH(st,shoeKeyTable) -shoeKeyWordP st == not null GETHASH(st,shoeKeyTable) +shoeKeyWordP st == + not null GETHASH(st,shoeKeyTable) -shoeMatch(l,i)==shoeSubStringMatch(l,shoeDict,i) +shoeMatch(l,i) == + shoeSubStringMatch(l,shoeDict,i) shoeSubStringMatch (l,d,i)== h:= QENUM(l, i) @@ -509,5 +539,6 @@ shoeSubStringMatch (l,d,i)== else false s1 -shoePunctuation c== shoePun.c =1 +shoePunctuation c == + shoePun.c =1 diff --git a/src/boot/strap/ast.clisp b/src/boot/strap/ast.clisp index 1f555ed2..fdfc2f47 100644 --- a/src/boot/strap/ast.clisp +++ b/src/boot/strap/ast.clisp @@ -1,9 +1,9 @@ (IMPORT-MODULE "includer") -(PROVIDE "ast") - (IN-PACKAGE "BOOTTRAN") +(PROVIDE "ast") + (DEFPARAMETER |$bfClamming| NIL) (DEFTYPE |%Thing| () 'T) @@ -1159,7 +1159,7 @@ (DEFUN |bfReName| (|x|) (PROG (|oldName| |newName| |a|) - (DECLARE (SPECIAL |$translatingOldBoot|)) + (DECLARE (SPECIAL |$stok| |$translatingOldBoot|)) (RETURN (PROGN (SETQ |newName| @@ -1174,7 +1174,8 @@ ((NOT (EQUAL |newName| |oldName|)) (|warn| (LIST (PNAME |x|) " as `" (PNAME |newName|) "' differs from Old Boot `" - (PNAME |oldName|) "'")))) + (PNAME |oldName|) "' at " + (|diagnosticLocation| |$stok|))))) |oldName|)) (#0# |newName|)))))) diff --git a/src/boot/strap/includer.clisp b/src/boot/strap/includer.clisp index 60cbd62e..c4a036de 100644 --- a/src/boot/strap/includer.clisp +++ b/src/boot/strap/includer.clisp @@ -1,9 +1,9 @@ (IMPORT-MODULE "tokens") -(PROVIDE "includer") - (IN-PACKAGE "BOOTTRAN") +(PROVIDE "includer") + (DEFUN PNAME (|x|) (COND ((SYMBOLP |x|) (SYMBOL-NAME |x|)) @@ -38,6 +38,14 @@ (DEFUN |shoeSpaces| (|n|) (MAKE-FULL-CVEC |n| ".")) +(DEFUN |diagnosticLocation| (|tok|) + (PROG (|pos|) + (RETURN + (PROGN + (SETQ |pos| (|shoeTokPosn| |tok|)) + (CONCAT "line " (STRINGIMAGE (|lineNo| |pos|)) ", column " + (STRINGIMAGE (|lineCharacter| |pos|))))))) + (DEFUN |SoftShoeError| (|posn| |key|) (PROGN (|coreError| (LIST "in line " (STRINGIMAGE (|lineNo| |posn|)))) diff --git a/src/boot/strap/parser.clisp b/src/boot/strap/parser.clisp index bb8faa08..32e32b47 100644 --- a/src/boot/strap/parser.clisp +++ b/src/boot/strap/parser.clisp @@ -4,10 +4,10 @@ (IMPORT-MODULE "ast") -(PROVIDE "parser") - (IN-PACKAGE "BOOTTRAN") +(PROVIDE "parser") + (DEFPARAMETER |$sawParenthesizedHead| NIL) (DEFUN |bpFirstToken| () diff --git a/src/boot/strap/pile.clisp b/src/boot/strap/pile.clisp index 9dca94bb..8a2c8048 100644 --- a/src/boot/strap/pile.clisp +++ b/src/boot/strap/pile.clisp @@ -2,10 +2,10 @@ (IMPORT-MODULE "scanner") -(PROVIDE "pile") - (IN-PACKAGE "BOOTTRAN") +(PROVIDE "pile") + (DEFUN |shoeFirstTokPosn| (|t|) (|shoeTokPosn| (CAAR |t|))) (DEFUN |shoeLastTokPosn| (|t|) (|shoeTokPosn| (CADR |t|))) diff --git a/src/boot/strap/scanner.clisp b/src/boot/strap/scanner.clisp index 58118e34..5e527e50 100644 --- a/src/boot/strap/scanner.clisp +++ b/src/boot/strap/scanner.clisp @@ -164,7 +164,8 @@ (#0# (|shoeAccumulateLines| |$r| |string|))))) (#0# (CONS |s| |string|))))))))) -(DEFUN |shoeCloser| (|t|) (MEMQ (|shoeKeyWord| |t|) '(CPAREN CBRACK))) +(DEFUN |shoeCloser| (|t|) + (MEMBER (|shoeKeyWord| |t|) '(CPAREN CBRACK))) (DEFUN |shoeToken| () (PROG (|b| |ch| |n| |linepos| |c| |ln|) diff --git a/src/boot/strap/tokens.clisp b/src/boot/strap/tokens.clisp index 43dba7e3..c82ec5c5 100644 --- a/src/boot/strap/tokens.clisp +++ b/src/boot/strap/tokens.clisp @@ -1,9 +1,9 @@ (IMPORT-MODULE "initial-env") -(PROVIDE "tokens") - (IN-PACKAGE "BOOTTRAN") +(PROVIDE "tokens") + (DEFCONSTANT |shoeKeyWords| (LIST (LIST "and" 'AND) (LIST "by" 'BY) (LIST "case" 'CASE) (LIST "catch" 'CATCH) (LIST "cross" 'CROSS) diff --git a/src/boot/strap/translator.clisp b/src/boot/strap/translator.clisp index af8e4d74..e105dd47 100644 --- a/src/boot/strap/translator.clisp +++ b/src/boot/strap/translator.clisp @@ -460,7 +460,8 @@ (DEFUN |needsStableReference?| (|t|) (COND ((|%hasFeature| :GCL) NIL) - ((OR (|%hasFeature| :SBCL) (|%hasFeature| :CLISP)) + ((OR (|%hasFeature| :SBCL) (|%hasFeature| :CLISP) + (|%hasFeature| :ECL)) (OR (EQ |t| '|pointer|) (EQ |t| '|buffer|))) ('T T))) @@ -476,7 +477,7 @@ (|fatalError| "don't know how to coerce argument for native type")) (#0='T |a|))) - ((|%hasFeature| :CLISP) + ((OR (|%hasFeature| :CLISP) (|%hasFeature| :ECL)) (COND ((|needsStableReference?| |t|) (|fatalError| @@ -523,8 +524,9 @@ (LIST |unstableArgs| |preparedArgs|))))) (DEFUN |genImportDeclaration| (|op| |sig|) - (PROG (|forwardingFun| |foreignDecl| |n| |newArgs| |unstableArgs| - |LETTMP#1| |args| |s| |t| |m| |ISTMP#2| |op'| |ISTMP#1|) + (PROG (|bfVar#33| |forwardingFun| |foreignDecl| |n| |newArgs| + |unstableArgs| |LETTMP#1| |args| |s| |t| |m| |ISTMP#2| + |op'| |ISTMP#1|) (DECLARE (SPECIAL |$foreignsDefsForCLisp|)) (RETURN (COND @@ -751,10 +753,80 @@ (SETQ |$foreignsDefsForCLisp| (CONS |foreignDecl| |$foreignsDefsForCLisp|)) (LIST |forwardingFun|))) + ((|%hasFeature| :ECL) + (LIST (LIST 'DEFUN |op| |args| + (LIST (|bfColonColon| 'FFI 'C-INLINE) + |args| + (LET + ((|bfVar#30| NIL) + (|bfVar#29| |s|) (|x| NIL)) + (LOOP + (COND + ((OR (ATOM |bfVar#29|) + (PROGN + (SETQ |x| + (CAR |bfVar#29|)) + NIL)) + (RETURN + (NREVERSE |bfVar#30|))) + (#2# + (SETQ |bfVar#30| + (CONS (|nativeType| |x|) + |bfVar#30|)))) + (SETQ |bfVar#29| + (CDR |bfVar#29|)))) + (|nativeType| |t|) + (PROGN + (SETQ |bfVar#33| + (|genImportDeclaration,callTemplate| + |op'| (LENGTH |args|))) + (LET + ((|bfVar#31| (CAR |bfVar#33|)) + (|bfVar#34| (CDR |bfVar#33|)) + (|bfVar#32| NIL)) + (LOOP + (COND + ((OR (ATOM |bfVar#34|) + (PROGN + (SETQ |bfVar#32| + (CAR |bfVar#34|)) + NIL)) + (RETURN |bfVar#31|)) + (#2# + (SETQ |bfVar#31| + (CONCAT |bfVar#31| + |bfVar#32|)))) + (SETQ |bfVar#34| + (CDR |bfVar#34|))))) + :ONE-LINER T)))) (#1# (|fatalError| "import declaration not implemented for this Lisp")))))))))))) +(DEFUN |genImportDeclaration,callTemplate| (|op| |n|) + (CONS (SYMBOL-NAME |op|) + (CONS "(" + (APPEND (LET ((|bfVar#36| NIL) (|bfVar#35| (- |n| 1)) + (|i| 0)) + (LOOP + (COND + ((> |i| |bfVar#35|) + (RETURN (NREVERSE |bfVar#36|))) + ('T + (SETQ |bfVar#36| + (APPEND + (REVERSE + (|genImportDeclaration,sharpArg| + |i|)) + |bfVar#36|)))) + (SETQ |i| (+ |i| 1)))) + (CONS ")" NIL))))) + +(DEFUN |genImportDeclaration,sharpArg| (|i|) + (COND + ((EQL |i| 0) (LIST "#0")) + ('T (LIST "," "#" (STRINGIMAGE |i|))))) + (DEFUN |shoeOutParse| (|stream|) (PROG (|found|) (DECLARE (SPECIAL |$bpParenCount| |$bpCount| |$returns| |$typings| @@ -809,14 +881,14 @@ ('T (LIST 'DECLAIM (LIST 'TYPE |t| |n|))))))) (DEFUN |translateSignatureDeclaration| (|d|) - (PROG (|bfVar#30| |bfVar#29|) + (PROG (|bfVar#38| |bfVar#37|) (RETURN (PROGN - (SETQ |bfVar#29| |d|) - (SETQ |bfVar#30| (CDR |bfVar#29|)) - (CASE (CAR |bfVar#29|) + (SETQ |bfVar#37| |d|) + (SETQ |bfVar#38| (CDR |bfVar#37|)) + (CASE (CAR |bfVar#37|) (|Signature| - (LET ((|n| (CAR |bfVar#30|)) (|t| (CADR |bfVar#30|))) + (LET ((|n| (CAR |bfVar#38|)) (|t| (CADR |bfVar#38|))) (|genDeclaration| |n| |t|))) (T (|coreError| "signature expected"))))))) @@ -827,17 +899,17 @@ (SETQ |expr'| (CDR (CDR (|shoeCompTran| (LIST 'LAMBDA (LIST '|x|) |expr|))))) - (LET ((|bfVar#31| |expr'|) (|t| NIL)) + (LET ((|bfVar#39| |expr'|) (|t| NIL)) (LOOP (COND - ((OR (ATOM |bfVar#31|) - (PROGN (SETQ |t| (CAR |bfVar#31|)) NIL)) + ((OR (ATOM |bfVar#39|) + (PROGN (SETQ |t| (CAR |bfVar#39|)) NIL)) (RETURN NIL)) ('T (COND ((AND (CONSP |t|) (EQ (CAR |t|) 'DECLARE)) (IDENTITY (RPLACA |t| 'DECLAIM)))))) - (SETQ |bfVar#31| (CDR |bfVar#31|)))) + (SETQ |bfVar#39| (CDR |bfVar#39|)))) (|shoeEVALANDFILEACTQ| (COND ((< 1 (LENGTH |expr'|)) (CONS 'PROGN |expr'|)) @@ -847,69 +919,69 @@ (COND (|export?| |d|) ('T |d|))) (DEFUN |translateToplevel| (|b| |export?|) - (PROG (|lhs| |t| |ISTMP#2| |n| |ISTMP#1| |sig| |bfVar#37| |bfVar#36| + (PROG (|lhs| |t| |ISTMP#2| |n| |ISTMP#1| |sig| |bfVar#45| |bfVar#44| |xs|) (DECLARE (SPECIAL |$foreignsDefsForCLisp| |$currentModuleName|)) (RETURN (COND ((AND (CONSP |b|) (EQ (CAR |b|) 'TUPLE) (PROGN (SETQ |xs| (CDR |b|)) #0='T)) - (LET ((|bfVar#33| NIL) (|bfVar#32| |xs|) (|x| NIL)) + (LET ((|bfVar#41| NIL) (|bfVar#40| |xs|) (|x| NIL)) (LOOP (COND - ((OR (ATOM |bfVar#32|) - (PROGN (SETQ |x| (CAR |bfVar#32|)) NIL)) - (RETURN (NREVERSE |bfVar#33|))) + ((OR (ATOM |bfVar#40|) + (PROGN (SETQ |x| (CAR |bfVar#40|)) NIL)) + (RETURN (NREVERSE |bfVar#41|))) (#1='T - (SETQ |bfVar#33| + (SETQ |bfVar#41| (CONS (|maybeExportDecl| |x| |export?|) - |bfVar#33|)))) - (SETQ |bfVar#32| (CDR |bfVar#32|))))) + |bfVar#41|)))) + (SETQ |bfVar#40| (CDR |bfVar#40|))))) ('T (PROGN - (SETQ |bfVar#36| |b|) - (SETQ |bfVar#37| (CDR |bfVar#36|)) - (CASE (CAR |bfVar#36|) + (SETQ |bfVar#44| |b|) + (SETQ |bfVar#45| (CDR |bfVar#44|)) + (CASE (CAR |bfVar#44|) (|Signature| - (LET ((|op| (CAR |bfVar#37|)) (|t| (CADR |bfVar#37|))) + (LET ((|op| (CAR |bfVar#45|)) (|t| (CADR |bfVar#45|))) (LIST (|maybeExportDecl| (|genDeclaration| |op| |t|) |export?|)))) (|%Module| - (LET ((|m| (CAR |bfVar#37|)) (|ds| (CADR |bfVar#37|))) + (LET ((|m| (CAR |bfVar#45|)) (|ds| (CADR |bfVar#45|))) (PROGN (SETQ |$currentModuleName| |m|) (SETQ |$foreignsDefsForCLisp| NIL) (CONS (LIST 'PROVIDE (STRING |m|)) - (LET ((|bfVar#35| NIL) (|bfVar#34| |ds|) + (LET ((|bfVar#43| NIL) (|bfVar#42| |ds|) (|d| NIL)) (LOOP (COND - ((OR (ATOM |bfVar#34|) + ((OR (ATOM |bfVar#42|) (PROGN - (SETQ |d| (CAR |bfVar#34|)) + (SETQ |d| (CAR |bfVar#42|)) NIL)) - (RETURN (NREVERSE |bfVar#35|))) + (RETURN (NREVERSE |bfVar#43|))) (#1# - (SETQ |bfVar#35| + (SETQ |bfVar#43| (CONS (|translateToplevel| |d| T) - |bfVar#35|)))) - (SETQ |bfVar#34| (CDR |bfVar#34|)))))))) + |bfVar#43|)))) + (SETQ |bfVar#42| (CDR |bfVar#42|)))))))) (|Import| - (LET ((|m| (CAR |bfVar#37|))) + (LET ((|m| (CAR |bfVar#45|))) (LIST (LIST 'IMPORT-MODULE (STRING |m|))))) (|ImportSignature| - (LET ((|x| (CAR |bfVar#37|)) - (|sig| (CADR |bfVar#37|))) + (LET ((|x| (CAR |bfVar#45|)) + (|sig| (CADR |bfVar#45|))) (|genImportDeclaration| |x| |sig|))) (|%TypeAlias| - (LET ((|lhs| (CAR |bfVar#37|)) - (|rhs| (CADR |bfVar#37|))) + (LET ((|lhs| (CAR |bfVar#45|)) + (|rhs| (CADR |bfVar#45|))) (LIST (|maybeExportDecl| (|genTypeAlias| |lhs| |rhs|) |export?|)))) (|ConstantDefinition| - (LET ((|lhs| (CAR |bfVar#37|)) - (|rhs| (CADR |bfVar#37|))) + (LET ((|lhs| (CAR |bfVar#45|)) + (|rhs| (CADR |bfVar#45|))) (PROGN (SETQ |sig| NIL) (COND @@ -934,8 +1006,8 @@ (LIST 'DEFCONSTANT |lhs| |rhs|) |export?|))))) (|%Assignment| - (LET ((|lhs| (CAR |bfVar#37|)) - (|rhs| (CADR |bfVar#37|))) + (LET ((|lhs| (CAR |bfVar#45|)) + (|rhs| (CADR |bfVar#45|))) (PROGN (SETQ |sig| NIL) (COND @@ -960,7 +1032,7 @@ (LIST 'DEFPARAMETER |lhs| |rhs|) |export?|))))) (|namespace| - (LET ((|n| (CAR |bfVar#37|))) + (LET ((|n| (CAR |bfVar#45|))) (LIST (LIST 'IN-PACKAGE (STRING |n|))))) (T (LIST (|translateToplevelExpression| |b|)))))))))) @@ -1001,11 +1073,11 @@ (COND ((NULL |a|) (CONCAT |s| |str|)) ('T |s|)))))) (DEFUN |shoeRemoveStringIfNec| (|str| |s|) - (PROG (|a|) + (PROG (|n|) (RETURN (PROGN - (SETQ |a| (STRPOS |str| |s| 0 NIL)) - (COND ((NULL |a|) |s|) ('T (SUBSTRING |s| 0 |a|))))))) + (SETQ |n| (SEARCH |str| |s| :FROM-END T)) + (COND ((NULL |n|) |s|) ('T (SUBSTRING |s| 0 |n|))))))) (DEFUN DEFUSE (|fn|) (PROG (|infn|) @@ -1014,6 +1086,14 @@ (SETQ |infn| (CONCAT |fn| ".boot")) (|shoeOpenInputFile| |a| |infn| (|shoeDfu| |a| |fn|)))))) +(DEFPARAMETER |$bootDefined| NIL) + +(DEFPARAMETER |$bootDefinedTwice| NIL) + +(DEFPARAMETER |$bootUsed| NIL) + +(DEFPARAMETER |$lispWordTable| NIL) + (DEFUN |shoeDfu| (|a| |fn|) (PROG (|out|) (DECLARE (SPECIAL |$bfClamming| |$GenVarCounter| @@ -1045,17 +1125,17 @@ (PROGN (|shoeFileLine| "DEFINED and not USED" |stream|) (SETQ |a| - (LET ((|bfVar#39| NIL) - (|bfVar#38| (HKEYS |$bootDefined|)) (|i| NIL)) + (LET ((|bfVar#47| NIL) + (|bfVar#46| (HKEYS |$bootDefined|)) (|i| NIL)) (LOOP (COND - ((OR (ATOM |bfVar#38|) - (PROGN (SETQ |i| (CAR |bfVar#38|)) NIL)) - (RETURN (NREVERSE |bfVar#39|))) + ((OR (ATOM |bfVar#46|) + (PROGN (SETQ |i| (CAR |bfVar#46|)) NIL)) + (RETURN (NREVERSE |bfVar#47|))) (#0='T (AND (NOT (GETHASH |i| |$bootUsed|)) - (SETQ |bfVar#39| (CONS |i| |bfVar#39|))))) - (SETQ |bfVar#38| (CDR |bfVar#38|))))) + (SETQ |bfVar#47| (CONS |i| |bfVar#47|))))) + (SETQ |bfVar#46| (CDR |bfVar#46|))))) (|bootOut| (SSORT |a|) |stream|) (|shoeFileLine| " " |stream|) (|shoeFileLine| "DEFINED TWICE" |stream|) @@ -1063,29 +1143,29 @@ (|shoeFileLine| " " |stream|) (|shoeFileLine| "USED and not DEFINED" |stream|) (SETQ |a| - (LET ((|bfVar#41| NIL) (|bfVar#40| (HKEYS |$bootUsed|)) + (LET ((|bfVar#49| NIL) (|bfVar#48| (HKEYS |$bootUsed|)) (|i| NIL)) (LOOP (COND - ((OR (ATOM |bfVar#40|) - (PROGN (SETQ |i| (CAR |bfVar#40|)) NIL)) - (RETURN (NREVERSE |bfVar#41|))) + ((OR (ATOM |bfVar#48|) + (PROGN (SETQ |i| (CAR |bfVar#48|)) NIL)) + (RETURN (NREVERSE |bfVar#49|))) (#0# (AND (NOT (GETHASH |i| |$bootDefined|)) - (SETQ |bfVar#41| (CONS |i| |bfVar#41|))))) - (SETQ |bfVar#40| (CDR |bfVar#40|))))) - (LET ((|bfVar#42| (SSORT |a|)) (|i| NIL)) + (SETQ |bfVar#49| (CONS |i| |bfVar#49|))))) + (SETQ |bfVar#48| (CDR |bfVar#48|))))) + (LET ((|bfVar#50| (SSORT |a|)) (|i| NIL)) (LOOP (COND - ((OR (ATOM |bfVar#42|) - (PROGN (SETQ |i| (CAR |bfVar#42|)) NIL)) + ((OR (ATOM |bfVar#50|) + (PROGN (SETQ |i| (CAR |bfVar#50|)) NIL)) (RETURN NIL)) (#0# (PROGN (SETQ |b| (CONCAT (PNAME |i|) " is used in ")) (|bootOutLines| (SSORT (GETHASH |i| |$bootUsed|)) |stream| |b|)))) - (SETQ |bfVar#42| (CDR |bfVar#42|)))))))) + (SETQ |bfVar#50| (CDR |bfVar#50|)))))))) (DEFUN |shoeDefUse| (|s|) (LOOP @@ -1181,16 +1261,16 @@ (#1# (CONS |nee| |$bootDefinedTwice|))))) ('T (HPUT |$bootDefined| |nee| T))) (|defuse1| |e| |niens|) - (LET ((|bfVar#43| |$used|) (|i| NIL)) + (LET ((|bfVar#51| |$used|) (|i| NIL)) (LOOP (COND - ((OR (ATOM |bfVar#43|) - (PROGN (SETQ |i| (CAR |bfVar#43|)) NIL)) + ((OR (ATOM |bfVar#51|) + (PROGN (SETQ |i| (CAR |bfVar#51|)) NIL)) (RETURN NIL)) ('T (HPUT |$bootUsed| |i| (CONS |nee| (GETHASH |i| |$bootUsed|))))) - (SETQ |bfVar#43| (CDR |bfVar#43|)))))))) + (SETQ |bfVar#51| (CDR |bfVar#51|)))))))) (DEFUN |defuse1| (|e| |y|) (PROG (|ndol| |dol| |LETTMP#1| |b| |a| |ISTMP#1|) @@ -1228,14 +1308,14 @@ (SETQ |LETTMP#1| (|defSeparate| |a|)) (SETQ |dol| (CAR |LETTMP#1|)) (SETQ |ndol| (CADR |LETTMP#1|)) - (LET ((|bfVar#44| |dol|) (|i| NIL)) + (LET ((|bfVar#52| |dol|) (|i| NIL)) (LOOP (COND - ((OR (ATOM |bfVar#44|) - (PROGN (SETQ |i| (CAR |bfVar#44|)) NIL)) + ((OR (ATOM |bfVar#52|) + (PROGN (SETQ |i| (CAR |bfVar#52|)) NIL)) (RETURN NIL)) (#2='T (HPUT |$bootDefined| |i| T))) - (SETQ |bfVar#44| (CDR |bfVar#44|)))) + (SETQ |bfVar#52| (CDR |bfVar#52|)))) (|defuse1| (APPEND |ndol| |e|) |b|))) ((AND (CONSP |y|) (EQ (CAR |y|) 'QUOTE) (PROGN (SETQ |a| (CDR |y|)) #1#)) @@ -1244,14 +1324,14 @@ (PROGN (SETQ |a| (CDR |y|)) #1#)) NIL) (#0# - (LET ((|bfVar#45| |y|) (|i| NIL)) + (LET ((|bfVar#53| |y|) (|i| NIL)) (LOOP (COND - ((OR (ATOM |bfVar#45|) - (PROGN (SETQ |i| (CAR |bfVar#45|)) NIL)) + ((OR (ATOM |bfVar#53|) + (PROGN (SETQ |i| (CAR |bfVar#53|)) NIL)) (RETURN NIL)) (#2# (|defuse1| |e| |i|))) - (SETQ |bfVar#45| (CDR |bfVar#45|))))))))) + (SETQ |bfVar#53| (CDR |bfVar#53|))))))))) (DEFUN |defSeparate| (|x|) (PROG (|x2| |x1| |LETTMP#1| |f|) @@ -1287,13 +1367,13 @@ (GETHASH |x| |$lispWordTable|)) (DEFUN |bootOut| (|l| |outfn|) - (LET ((|bfVar#46| |l|) (|i| NIL)) + (LET ((|bfVar#54| |l|) (|i| NIL)) (LOOP (COND - ((OR (ATOM |bfVar#46|) (PROGN (SETQ |i| (CAR |bfVar#46|)) NIL)) + ((OR (ATOM |bfVar#54|) (PROGN (SETQ |i| (CAR |bfVar#54|)) NIL)) (RETURN NIL)) ('T (|shoeFileLine| (CONCAT " " (PNAME |i|)) |outfn|))) - (SETQ |bfVar#46| (CDR |bfVar#46|))))) + (SETQ |bfVar#54| (CDR |bfVar#54|))))) (DEFUN CLESSP (|s1| |s2|) (NOT (SHOEGREATERP |s1| |s2|))) @@ -1344,18 +1424,18 @@ (PROGN (|shoeFileLine| "USED and where DEFINED" |stream|) (SETQ |c| (SSORT (HKEYS |$bootUsed|))) - (LET ((|bfVar#47| |c|) (|i| NIL)) + (LET ((|bfVar#55| |c|) (|i| NIL)) (LOOP (COND - ((OR (ATOM |bfVar#47|) - (PROGN (SETQ |i| (CAR |bfVar#47|)) NIL)) + ((OR (ATOM |bfVar#55|) + (PROGN (SETQ |i| (CAR |bfVar#55|)) NIL)) (RETURN NIL)) ('T (PROGN (SETQ |a| (CONCAT (PNAME |i|) " is used in ")) (|bootOutLines| (SSORT (GETHASH |i| |$bootUsed|)) |stream| |a|)))) - (SETQ |bfVar#47| (CDR |bfVar#47|)))))))) + (SETQ |bfVar#55| (CDR |bfVar#55|)))))))) (DEFUN FBO (|name| |fn|) (|shoeGeneralFC| #'BO |name| |fn|)) @@ -1396,16 +1476,16 @@ (SETQ |filename| (CONCAT "/tmp/" |filename| ".boot")) (|shoeOpenOutputFile| |stream| |filename| - (LET ((|bfVar#48| |lines|) (|line| NIL)) + (LET ((|bfVar#56| |lines|) (|line| NIL)) (LOOP (COND - ((OR (ATOM |bfVar#48|) + ((OR (ATOM |bfVar#56|) (PROGN - (SETQ |line| (CAR |bfVar#48|)) + (SETQ |line| (CAR |bfVar#56|)) NIL)) (RETURN NIL)) ('T (|shoeFileLine| |line| |stream|))) - (SETQ |bfVar#48| (CDR |bfVar#48|))))) + (SETQ |bfVar#56| (CDR |bfVar#56|))))) T)) ('T NIL)))))) @@ -1420,20 +1500,20 @@ (RETURN (PROGN (SETQ |dq| (CAR |str|)) - (CONS (LIST (LET ((|bfVar#50| NIL) - (|bfVar#49| (|shoeDQlines| |dq|)) + (CONS (LIST (LET ((|bfVar#58| NIL) + (|bfVar#57| (|shoeDQlines| |dq|)) (|line| NIL)) (LOOP (COND - ((OR (ATOM |bfVar#49|) + ((OR (ATOM |bfVar#57|) (PROGN - (SETQ |line| (CAR |bfVar#49|)) + (SETQ |line| (CAR |bfVar#57|)) NIL)) - (RETURN (NREVERSE |bfVar#50|))) + (RETURN (NREVERSE |bfVar#58|))) ('T - (SETQ |bfVar#50| - (CONS (CAR |line|) |bfVar#50|)))) - (SETQ |bfVar#49| (CDR |bfVar#49|))))) + (SETQ |bfVar#58| + (CONS (CAR |line|) |bfVar#58|)))) + (SETQ |bfVar#57| (CDR |bfVar#57|))))) (CDR |str|)))))) (DEFUN |stripm| (|x| |pk| |bt|) @@ -1570,12 +1650,13 @@ (DEFUN |getIntermediateLispFile| (|file| |options|) (PROG (|out|) - (DECLARE (SPECIAL |$faslType|)) + (DECLARE (SPECIAL |$effectiveFaslType|)) (RETURN (PROGN (SETQ |out| (NAMESTRING (|getOutputPathname| |options|))) (COND - (|out| (CONCAT (|shoeRemoveStringIfNec| |$faslType| |out|) + (|out| (CONCAT (|shoeRemoveStringIfNec| |$effectiveFaslType| + |out|) ".clisp")) ('T (|defaultBootToLispFile| |file|))))))) @@ -1596,6 +1677,7 @@ (BOOTTOCL |file| (|getIntermediateLispFile| |file| |options|))) (COND + ((NOT (EQL (|errorCount|) 0)) NIL) (|intFile| (PROGN (SETQ |objFile| @@ -1637,8 +1719,7 @@ ((|%hasFeature| :CLISP) (EVAL (LIST (|bfColonColon| 'FFI 'DEFAULT-FOREIGN-LIBRARY) |m|))) ('T - (|systemError| - "don't know how to load a dynamically linked module")))) + (|coreError| "don't know how to load a dynamically linked module")))) (DEFUN |loadSystemRuntimeCore| () (DECLARE (SPECIAL |$NativeModuleExt|)) diff --git a/src/boot/tokens.boot b/src/boot/tokens.boot index 9502190d..53dc38a9 100644 --- a/src/boot/tokens.boot +++ b/src/boot/tokens.boot @@ -33,8 +33,8 @@ -- import initial_-env -module tokens namespace BOOTTRAN +module tokens ++ Table of Boot keywords and their token name. shoeKeyWords == [ _ @@ -102,7 +102,7 @@ shoeKeyWords == [ _ shoeKeyTableCons()== KeyTable:=MAKE_-HASHTABLE("CVEC") for st in shoeKeyWords repeat - HPUT(KeyTable,CAR st,CADR st) + HPUT(KeyTable,first st,second st) KeyTable shoeKeyTable:=shoeKeyTableCons() @@ -196,7 +196,7 @@ for i in [ _ ["GE" ,">="], _ ["SHOENE" ,"^="] _ ]_ - repeat SETF (GET(CAR i,'SHOEINF),CADR i) + repeat SETF (GET(first i,'SHOEINF),second i) ++ List of monoid operations and their neutral elements. @@ -225,7 +225,7 @@ for i in [ _ ["OR", NIL] _ ] - repeat SETF (GET(CAR i,'SHOETHETA),CDR i) + repeat SETF (GET(first i,'SHOETHETA),CDR i) for i in [ _ ["and", "AND"] , _ @@ -286,7 +286,7 @@ for i in [ _ ["SHOENE", "/="], _ ["T", "T$"] _ ] - repeat SETF (GET(CAR i,'SHOERENAME),CDR i) + repeat SETF (GET(first i,'SHOERENAME),CDR i) -- For code written in `Old Boot', we would like to warn about -- the difference in renaming. @@ -357,7 +357,7 @@ for i in [ _ ["IN", "member"], _ ["UNION", "union"]_ ] - repeat SETF (GET(CAR i,'OLD_-BOOT),CDR i) + repeat SETF (GET(first i,'OLD_-BOOT),CDR i) -- The following difference in renaming are verified to be OK. for i in [ _ @@ -410,4 +410,4 @@ for i in [ _ ["streamName", "CADR"] , _ ["target", "CAR"] _ ] _ - repeat SETF (GET(CAR i,'SHOESELFUNCTION),CADR i) + repeat SETF (GET(first i,'SHOESELFUNCTION),second i) diff --git a/src/boot/translator.boot b/src/boot/translator.boot index fbfd8035..f49cf0c4 100644 --- a/src/boot/translator.boot +++ b/src/boot/translator.boot @@ -310,7 +310,7 @@ shoeFileTrees(s,st)== while not bStreamNull s repeat a:= first s if EQCAR (a,"+LINE") - then shoeFileLine(CADR a,st) + then shoeFileLine(second a,st) else REALLYPRETTYPRINT(a,st) TERPRI st -- cgit v1.2.3