some more code
This commit is contained in:
parent
7fd7a82104
commit
a5d83f52bb
@ -1,5 +1,6 @@
|
|||||||
with H3.Runes;
|
with H3.Runes;
|
||||||
with H3.Strings;
|
with H3.Strings;
|
||||||
|
with H3.Trees;
|
||||||
with Ada.Finalization;
|
with Ada.Finalization;
|
||||||
with Ada.Text_IO;
|
with Ada.Text_IO;
|
||||||
|
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
|
with Ada.Unchecked_Deallocation;
|
||||||
|
|
||||||
package body H3.Trees is
|
package body H3.Trees is
|
||||||
|
|
||||||
procedure Add_Node (Tr: in out Tree; N: in Node) is
|
procedure New_Node (Tr: in out Tree; Code: Node_Code) is
|
||||||
|
N: Node_Pointer;
|
||||||
begin
|
begin
|
||||||
--Tr.Nodes,
|
N := new Node(Code);
|
||||||
|
N.Next := Tr.Top;
|
||||||
null;
|
Tr.Top := N;
|
||||||
end Add_Node;
|
end New_Node;
|
||||||
|
|
||||||
procedure Free_Node (Tr: in out Tree; N: in out Node) is
|
procedure Free_Node (Tr: in out Tree; N: in out Node) is
|
||||||
begin
|
begin
|
||||||
@ -16,4 +18,15 @@ package body H3.Trees is
|
|||||||
null;
|
null;
|
||||||
end Free_Node;
|
end Free_Node;
|
||||||
|
|
||||||
|
-- ------------------------------------------------------------------
|
||||||
|
|
||||||
|
overriding procedure Initialize (C: in out Tree) is
|
||||||
|
begin
|
||||||
|
null;
|
||||||
|
end Initialize;
|
||||||
|
|
||||||
|
overriding procedure Finalize (C: in out Tree) is
|
||||||
|
begin
|
||||||
|
null;
|
||||||
|
end Finalize;
|
||||||
end H3.Trees;
|
end H3.Trees;
|
||||||
|
@ -1,23 +1,25 @@
|
|||||||
use H3.Arrays;
|
with Ada.Finalization;
|
||||||
|
|
||||||
package H3.Trees is
|
package H3.Trees is
|
||||||
|
|
||||||
-- parse tree
|
|
||||||
|
|
||||||
--package A is new H3.Arrays(XXXX, 0);
|
--package A is new H3.Arrays(XXXX, 0);
|
||||||
|
|
||||||
type Node_Code is (
|
type Node_Code is (
|
||||||
NODE_ASSIGN,
|
NODE_ASSIGN,
|
||||||
NODE_CALL,
|
NODE_CALL,
|
||||||
NODE_CLASS
|
NODE_CLASS,
|
||||||
NODE_IF,
|
NODE_IF,
|
||||||
NODE_FUN,
|
NODE_FUN,
|
||||||
NODE_VOID,
|
NODE_VOID,
|
||||||
NODE_WHILE
|
NODE_WHILE
|
||||||
);
|
);
|
||||||
|
|
||||||
|
type Node;
|
||||||
|
type Node_Pointer is access Node;
|
||||||
|
|
||||||
type Node(Code: Node_Code := NODE_VOID) is record
|
type Node(Code: Node_Code := NODE_VOID) is record
|
||||||
-- Loc: location.
|
-- Loc: location.
|
||||||
|
Next: Node_Pointer;
|
||||||
case Code is
|
case Code is
|
||||||
when NODE_ASSIGN =>
|
when NODE_ASSIGN =>
|
||||||
null;
|
null;
|
||||||
@ -33,11 +35,18 @@ package H3.Trees is
|
|||||||
null;
|
null;
|
||||||
when NODE_WHILE =>
|
when NODE_WHILE =>
|
||||||
null;
|
null;
|
||||||
|
end case;
|
||||||
end record;
|
end record;
|
||||||
|
|
||||||
type Tree is record
|
|
||||||
Next_Node: System_Index := System_Index'First;
|
|
||||||
Toplevel_Node := Node
|
|
||||||
end Tree;
|
|
||||||
|
|
||||||
|
|
||||||
|
-- parse tree
|
||||||
|
type Tree is new Ada.Finalization.Limited_Controlled with record
|
||||||
|
--Next_Node: System_Index := System_Index'First;
|
||||||
|
--Toplevel_Node := Node;
|
||||||
|
Top: Node_Pointer := null;
|
||||||
|
end record;
|
||||||
|
|
||||||
|
overriding procedure Initialize (C: in out Tree);
|
||||||
|
overriding procedure Finalize (C: in out Tree);
|
||||||
end H3.Trees;
|
end H3.Trees;
|
||||||
|
Loading…
Reference in New Issue
Block a user