summaryrefslogtreecommitdiff
path: root/src/packrat-lexer.ads
blob: 6c28bf8cbec4f23848b6d885c69ff46b5fc11236 (plain)
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
76
77
78
79
80
81
82
83
84
85


generic

    type Label_Enum is (<>);
    type Element is private;
    type Element_Array is array (Positive range <>) of Element;

    with package Gen_Tokens is new Tokens (Label_Enum, Element, Element_Array);

package Packrat.Lexer is


    type Combinator_Result is new Ada.Finalization.Controlled with private;

    type Combinator is access function
           (Input : in Element_Array;
            Start : in Positive)
        return Combinator_Result;

    type Combinator_Array is array (Positive range <>) of Combinator;


    Empty_Fail : constant Combinator_Result;


    function Create_Result
           (Length : in Natural;
            Status : in Result_Status;
            Value  : in Element_Array)
        return Combinator_Result;

    function Join
           (Left, Right : in Combinator_Result)
        return Combinator_Result;

    function "="
           (Left, Right : in Combinator_Result)
        return Boolean;

    function Status
           (This : in Combinator_Result)
        return Result_Status;

    function Debug_String
           (This : in Combinator_Result)
        return String;


private


    type Element_Array_Access is access Element_Array;


    Empty_Array : Element_Array (1 .. 0);


    type Combinator_Result is new Ada.Finalization.Controlled with record
        Length : Natural;
        Status : Result_Status;
        Value  : Element_Array_Access;
    end record;


    overriding procedure Initialize
           (This : in out Combinator_Result);

    overriding procedure Adjust
           (This : in out Combinator_Result);

    overriding procedure Finalize
           (This : in out Combinator_Result);


    Empty_Fail : constant Combinator_Result :=
       (Ada.Finalization.Controlled with
        Length => 0,
        Status => Failure,
        Value  => null);


end Packrat.Lexer;