summaryrefslogtreecommitdiff
path: root/src/packrat-tokens.ads
blob: cd691b549a5c9668aa96d3942edddbef37444ceb (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


private with

    Ada.Containers.Indefinite_Holders;


generic

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

    with function "<" (Left, Right : in Element_Type) return Boolean is <>;
    with function "<" (Left, Right : in Element_Array) return Boolean is <>;

package Packrat.Tokens is


    type Token is private;
    type Token_Array is array (Positive range <>) of Token;


    function "<"
           (Left, Right : in Token)
        return Boolean;

    function "<"
           (Left, Right : in Token_Array)
        return Boolean;


    function Create
           (Ident  : in Label_Enum;
            Start  : in Positive;
            Value  : in Element_Array)
        return Token;


    --  Note: The Start index indicates where the token was found
    --        in whatever array it was lexed from. The Value does *not*
    --        have to correspond with whatever is found there.


    function Debug_String
           (This : in Token)
        return String;


    function Label
           (This : in Token)
        return Label_Enum;

    function Start
           (This : in Token)
        return Positive;

    function Value
           (This : in Token)
        return Element_Array;


private


    package Value_Holders is new Ada.Containers.Indefinite_Holders (Element_Array);


    function "<"
           (Left, Right : in Value_Holders.Holder)
        return Boolean;


    type Token is record
        Identifier  : Label_Enum;
        Start_At    : Positive;
        Token_Value : Value_Holders.Holder;
    end record;


end Packrat.Tokens;