home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.c++:18961 comp.lang.eiffel:1416
- Newsgroups: comp.lang.c++,comp.lang.eiffel
- Path: sparky!uunet!wupost!cs.uiuc.edu!sparc0b!ctaylor
- From: ctaylor@cs.uiuc.edu (Conrad Taylor)
- Subject: Help with Simula program conversion...???
- Message-ID: <C0pGss.CoJ@cs.uiuc.edu>
- Sender: news@cs.uiuc.edu
- Organization: University of Illinois at Urbana-Champaign
- Date: Mon, 11 Jan 1993 19:58:03 GMT
- Lines: 258
-
-
-
- Yes, I was wondering if anyone would be so kind to assist me in the
- conversion of a very small program to Eiffel or Pascal or C? I don't have
- any backround in Simula and there's not a Simula system on the machines that
- I'm working. Thanks in advance to all that reply to this post.
-
- -Conrad
-
- ps: My e-mail is ctaylor@silver.lcs.mit.edu or
- taylor1@wse.eecs.uic.edu.
-
- The code is as follows:
-
- ----------------------------------------------------------------
- "comment" ------------- tree printing algorithms -----------;
-
- head "class" genhead;
- "begin"
- "integer" arcs;
- "end" *** genhead ***;
-
- link "class" node(p);
- "ref"(individu) p;
- "begin"
- "integer" tarcs,barcs;
- "integer" dup,pos;
-
- "procedure" into(l); "ref"(genhead) l;
- "begin"
- "ref"(node) pp;
- "integer" i;
- "this" link.into(l);
- pp:-pred;
- "if" pp=="none" "then" pos:=-999999
- "else" pos:=pp.pos+2;
- i:=1;
- "while"("if" pp=/="none"
- "then" pp.p =/= p
- "else" "false")
- "do" "begin" pp:-pp.pred; i:=i+1 "end";
- "if" pp=/="none" "then" dup:=i;
- "end";
-
- "procedure" printyear(e); "ref"(event) e;
- "inspect" e "do"
- "if" year=0 "then" outchar($?$) "else" outint(year,4)
- "otherwise" outchar($?$);
-
- "procedure" outkey(ln,w); "integer" ln,w;
- "begin"
- "integer" npos;
- npos:= sysout.pos+w;
- outchar($ $);
- "inspect" p "do"
- "if" ln=1 "then"
- "begin" outtext(nom); printref "end"
- "else""if" ln=2 "then"
- outtext(prenom)
- "else""if" dup "ne" 0 "then"
- outtext(""<--dup--"")
- "else""begin"
- outchar($($);
- printyear(birth);
- outchar($-$);
- printyear(death);
- outchar($)$);
- "end";
- setpos(npos);
- "end" *** outkey ***;
-
- "end" *** node ***;
-
- "procedure" treeprint;
- "if" "not" liste.empty "then"
- "begin"
- "ref"(genhead) "array" generation[- 20:20];
- "integer" firstgen,lastgen;
- "procedure" checkgen(g); "integer" g;
- "if" generation[g]=="none" "then"
- "begin"
- generation[g]:-"new" genhead;
- "if" g>lastgen"then" lastgen:=g
- "else""if" g<firstgen "then" firstgen:=g;
- "end" *** checkgen ***;
-
- "text" vertline,horline,leftend,rightend,cross;
- "procedure" outblank; setpos(pos+keywidth);
-
- "integer" l,c,r,
- arcs,
- minpos,maxpos,
- startpos,endpos,p,np,i,
- keywidth,pagewidth,
- g,line;
-
- "ref"(node) "procedure" position(p,g,pos);
- "ref"(individu) p;
- "integer" g, pos;
- "begin"
- "ref"(node) pnode,pn,lnode,rnode;
- "ref"(individu) pere,mere;
-
- "procedure" insert(set,member);
- "name" set; "integer" set,member;
- set:= or(set,member);
-
- pnode:- "new" node(p);
- checkgen(g);
- pnode.into(generation[g]);
- "if" pnode.pos>pos "then" pos:=pnode.pos;
-
- "if" pnode.dup=0 "then"
- "begin"
- "inspect" mariage[p.parents] "do"
- "begin"
- pere:- person[husband];
- mere:- person[wife];
- "end";
- "if" pere=="none" "and" mere == "none" "then"
- pnode.pos:=pos
- "else"
- "begin"
- "if" pere=/="none" "and" mere=/="none" "then"
- "begin"
- lnode:-position(pere,g-1,pos-1);
- rnode:-position(mere,g-1,pos+1);
- "end"
- "else"
- lnode:-rnode:-
- position("if" pere=="none""then" mere "else" pere,
- g-1,pos);
- pos:=(lnode.pos+rnode.pos) "div" 2;
- "if" pos>pnode.pos
- "then" pnode.pos := pos
- "else" pos := pnode.pos ;
- insert(pnode.tarcs,c);
- "for" pn:-("if" lnode.pos<rnode.pos
- "then" lnode "else" rnode),
- pn.suc "while" pn=/="none" "do"
- "begin"
- pn.barcs:= or(pn.barcs,c);
- "if" pn.pos<pos "then"
- "begin" insert(pn.barcs,r); insert(pnode.tarcs,l) "end"
- "else""if" pn.pos>pos "then"
- "begin" insert(pn.barcs,l); insert(pnode.tarcs,r) "end";
- "end"
- "end"
- "end"
- "else""if" pnode.dup < 3 "then"
- "begin"
- pn:-("if" pnode.dup=1 "then" pnode.pred "else" pnode.pred.pred);
- "if" pnode.dup=1 "or" pnode.pred"qua"node.barcs "ne" c "then"
- "begin"
- pnode.out; pnode:-pn;
- pos:=pnode.pos;
- "end"
- "else" pnode.pos:=pos;
- "end";
-
- "if" pos>maxpos "then" maxpos:= pos "else"
- "if" pos<minpos "then" minpos:= pos;
- position:- pnode;
- "end" *** position ***;
-
- "ref"(genhead) h;
- "ref"(node) tl,bl;
-
- l:=1; c:=2; r:=4;
- vertline :- copy("" ! "");
- horline :- copy(""----------"");
- leftend :- copy("" +-----"");
- rightend :- copy(""----+ "");
- cross :- copy(""----+-----"");
- keywidth := 10;
- pagewidth:= 132 "div" keywidth -1;
- lpp:=150; linesperpage(151);
-
- tl:-position(liste.first ,0,0);
- generation[lastgen+1] :- "new" genhead;
- "for" i:= firstgen "step" 1 "until" lastgen+1 "do"
- "begin"
- tl:-"new" node("none"); tl.pos:= 999999;
- tl "qua" link .into(generation[i]);
- "end";
-
- startpos := minpos;
- "while" startpos <= maxpos "do"
- "begin"
- newpage;
- endpos := startpos+pagewidth;
- "for" g:= firstgen "step" 1 "until" lastgen "do"
- "begin"
- h:- generation [g];
- bl:- generation [g+1].first;
- "for" i:=1 "step" 1 "until" 6 "do"
- "begin"
- tl:-h.first;
- p:= startpos;
- "while" p < endpos "do"
- "begin"
- np:=tl.pos;
- "if" i < 6 "then"
- "begin"
- "if" np>= endpos "then" p:= endpos
- "else" "if" p "ne" np "then" outblank
- "else""if" i=1 "and" and(c,tl.tarcs) "ne" 0 "or"
- i=5 "and" and(c,tl.barcs) "ne" 0 "then"
- outtext(vertline)
- "else""if" i>1 "and" i<5 "then" tl.outkey(i-1,keywidth)
- "else" outblank;
-
- "if" p=np "then" tl:-tl.suc;
- "end"
- "else""begin"
- "if" np>bl.pos "then" np:=bl.pos;
- "if" p "ne" np "then" arcs:= h.arcs
- "else""begin"
- arcs:=0;
- "if" tl.pos=p "then""begin"
- arcs:= or(arcs,tl.barcs); tl:- tl.suc;
- tl.pred.out;
- "end";
- "if" bl.pos = p "then""begin"
- arcs := or(arcs,bl.tarcs); bl:-bl.suc;
- "end";
- "if" and(c,arcs)=0
- "then" arcs:= h.arcs
- "else""if" and(r,arcs)=r "then"
- h.arcs:= l+r
- "else"
- h.arcs:=0;
- "end";
-
- "if" arcs = l+r+c "then" outtext(cross)
- "else""if" arcs = l+r "then" outtext(horline)
- "else""if" and(l,arcs) = l "then" outtext(rightend)
- "else""if" and(r,arcs) = r "then" outtext(leftend)
- "else""if" and(c,arcs) = c "then" outtext(vertline)
- "else""if" np>= endpos "then" p:= endpos
- "else" outblank;
- "end";
- p:=p+1;
- "end";
- nl(1);
- "end";
- "end";
- startpos:= endpos;
- "end";
- lpp:=63; lines per page(64);
- "end" *** treeprint ***;
-
-
-
-
-
-
-
-