Yurttas/PL/IL/Ada-95/ProgUnits/A/treeop 00 p.adb

From ZCubes Wiki
Jump to navigation Jump to search
 1--
 2-- Copyright (C) 1998
 3-- All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
 4--
 5-- Permission to use, copy, modify, and distribute this 
 6-- software and its documentation for EDUCATIONAL purposes
 7-- and without fee is hereby granted provided that this 
 8-- copyright notice appears in all copies. 
 9-- 
10-- 
11 
12-- date   : January 1, 1998.
13-- author : Salih Yurttas.
14
15-- treeop_00_p.adb
16
17
18with Text_IO; use Text_IO;
19
20package body TreeOp_00_P is
21
22  procedure Enter(P : in out Ptr_Node) is
23    Ch : Character;
24  begin
25    Get(Ch);
26    Put(Ch);
27    if Ch /= '.' then
28      P := new Node;
29      P.Info := Ch;
30      Enter(P.LLink);
31      Enter(P.RLink);
32    else P := null;
33    end if;
34  end Enter;
35
36  procedure Pre_Order(P : in Ptr_Node) is
37  begin
38    if P /= null then 
39      Put(P.Info);
40      Pre_Order(P.LLink);
41      Pre_Order(P.RLink);
42    end if;
43  end Pre_Order;
44
45  procedure In_Order(P : in Ptr_Node) is
46  begin
47    if P /= null then 
48      In_Order(P.LLink);
49      Put(P.Info);
50      In_Order(P.RLink);
51    end if;
52  end In_Order;
53
54  procedure Post_Order(P : in Ptr_Node) is
55  begin
56    if P /= null then 
57      Post_Order(P.LLink);
58      Post_Order(P.RLink);
59      Put(P.Info);
60    end if;
61  end Post_Order;
62
63end TreeOp_00_P;