AAda Compiler Node Package

28
Jan
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
-- manage the node tree
with aada_compiler_token_package;
 
package aada_compiler_node_package is
 
  type compiler_node_index is range 0 .. 3;
  type compiler_node(children: compiler_node_index := 0) is limited private;
  type compiler_node_access is access compiler_node;
  type compiler_node_access_array is array(compiler_node_index range <>)
                                            of compiler_node_access;
  type compiler_node_handle is private;
 
  -- initialize the node token
  procedure init(node: in out compiler_node;
                 token: in aada_compiler_token_package.compiler_token_type);
 
  -- unlink (detach) a node from its parent and siblings
  procedure unlink(node: in out compiler_node_access);
 
  -- parent/child handling
  procedure parent(node: in out compiler_node_access;
                   parent: in out compiler_node_access;
                   child_index: in compiler_node_index := 1);
  function parent(node: in compiler_node_access) return compiler_node_access;
  function child(node: in compiler_node_access;
                 child_index: in compiler_node_index := 1)
                                                return compiler_node_access;
 
  -- attached "next" as the next node of "node"
  procedure next(node: in out compiler_node_access;
                 next: in out compiler_node_access);
  function next(node: in compiler_node_access) return compiler_node_access;
  function last(node: in compiler_node_access) return compiler_node_access;
 
  -- attached "previous" as the previous node of "node"
  -- if node was the first in the list, also change the parent
  procedure previous(node: in out compiler_node_access;
                     previous: in out compiler_node_access);
  function previous(node: in compiler_node_access)
                                           return compiler_node_access;
  function first(node: in compiler_node_access) return compiler_node_access;
 
  -- create a node inside a handle
  procedure create_node(node_handle: in out compiler_node_handle;
                     token: in aada_compiler_token_package.compiler_token_type;
                     children: in compiler_node_index := 0);
  procedure init(node_handle: compiler_node_handle;
                 token: in aada_compiler_token_package.compiler_token_type);
  procedure parent(node_handle: in out compiler_node_handle;
                   parent_handle: in out compiler_node_handle;
                   child_index: in compiler_node_index := 1);
  procedure next(node_handle: in out compiler_node_handle;
                 next_handle: in out compiler_node_handle);
 
private
 
  type compiler_node(children: compiler_node_index := 0) is
    record
      parent: compiler_node_access := null;
      index: compiler_node_index := 0; -- parent.child(node.index)
      next: compiler_node_access := null;
      previous: compiler_node_access := null;
      child: compiler_node_access_array(1 .. children) := (others => null);
      token: aada_compiler_token_package.compiler_token_type;
    end record;
 
  -- used between the parser procedures to hold a node access
  type compiler_node_handle is
    record
      node: compiler_node_access := null;
    end record;
 
end aada_compiler_node_package;
 
-- vim: ts=2 sw=2 et syntax=ada
Project aada v1.0-338 (Project id #3)
Process Done (Last compiled on 2012/01/13 01:21:26)
Description Alexis Ada Compiler written in Ada (my first attempt was in C++ which is not correct for an Ada compiler.)