summaryrefslogtreecommitdiff
path: root/test/rat_tests-lexers.ads
blob: 6c8a4d7962f78d76fd910b137fa00a7702044783 (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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128


with

    Unit_Tests;

use

    Unit_Tests;

private with

    Packrat.Errors,
    Packrat.Traits,
    Packrat.Lexers.Debug,
    Packrat.Utilities;


package Rat_Tests.Lexers is


    function Join_Check return Test_Result;
    function Equals_Check return Test_Result;

    function Sequence_Check return Test_Result;
    function Count_Check return Test_Result;
    function Many_Check return Test_Result;
    function Many_Until_Check return Test_Result;

    function Satisfy_Check return Test_Result;
    function Satisfy_With_Check return Test_Result;
    function Match_Check return Test_Result;
    function Match_With_Check return Test_Result;
    function Multimatch_Check return Test_Result;
    function Take_Check return Test_Result;
    function Take_While_Check return Test_Result;
    function Take_Until_Check return Test_Result;

    function Line_End_Check return Test_Result;
    function Input_End_Check return Test_Result;

    Combinator_Tests : Test_Array :=
       ((+"Join", Join_Check'Access),
        (+"Equals", Equals_Check'Access),
        (+"Sequence", Sequence_Check'Access),
        (+"Count", Count_Check'Access),
        (+"Many", Many_Check'Access),
        (+"Many_Until", Many_Until_Check'Access),
        (+"Satisfy", Satisfy_Check'Access),
        (+"Satisfy With", Satisfy_With_Check'Access),
        (+"Match", Match_Check'Access),
        (+"Match With", Match_With_Check'Access),
        (+"Multimatch", Multimatch_Check'Access),
        (+"Take", Take_Check'Access),
        (+"Take While", Take_While_Check'Access),
        (+"Take Until", Take_Until_Check'Access),
        (+"Line End", Line_End_Check'Access),
        (+"Input_End", Input_End_Check'Access));


    function Stamp_Check return Test_Result;
    function Ignore_Check return Test_Result;

    function Scan_Parts_Check return Test_Result;
    function Scan_Once_Check return Test_Result;
    function Scan_With_Check return Test_Result;
    function Scan_Set_Check return Test_Result;
    function Scan_Set_With_Check return Test_Result;

    function Scan_Parts_Error_Check return Test_Result;
    function Scan_Once_Error_Check return Test_Result;
    function Scan_With_Error_Check return Test_Result;
    function Scan_Set_Error_Check return Test_Result;
    function Scan_Set_With_Error_Check return Test_Result;

    Lexer_Tests : Test_Array :=
       ((+"Stamp", Stamp_Check'Access),
        (+"Ignore", Ignore_Check'Access),
        (+"Scan_Parts", Scan_Parts_Check'Access),
        (+"Scan_Once", Scan_Once_Check'Access),
        (+"Scan_With", Scan_With_Check'Access),
        (+"Scan_Set", Scan_Set_Check'Access),
        (+"Scan_Set_With", Scan_Set_With_Check'Access),
        (+"Scan_Parts Exception", Scan_Parts_Error_Check'Access),
        (+"Scan_Once Exception", Scan_Once_Error_Check'Access),
        (+"Scan_With Exception", Scan_With_Error_Check'Access),
        (+"Scan_Set Exception", Scan_Set_Error_Check'Access),
        (+"Scan_Set_With Exception", Scan_Set_With_Error_Check'Access));


private


    package PU renames Packrat.Utilities;


    type My_Labels is (One, Two, Three);


    package Slexy_Traits is new Packrat.Traits (My_Labels, Character, String);
    package Slexy is new Packrat.Lexers (Slexy_Traits);
    package Slebug is new Slexy.Debug;


    use type Slexy.Combinator_Result;


    type Word_Enum is (Blank, Word, Whitespace);

    package Swordy_Traits is new Packrat.Traits (Word_Enum, Character, String);
    package Swordy is new Packrat.Lexers (Swordy_Traits);
    package Swolbug is new Swordy.Debug;

    use type Swordy_Traits.Tokens.Token_Type;
    use type Swordy_Traits.Tokens.Token_Array;

    function Satisfy_Letter is new Swordy.Satisfy (PU.Is_Letter);
    function Many_Letter is new Swordy.Many (Satisfy_Letter, 1);
    function Satisfy_Whitespace is new Swordy.Satisfy (PU.Is_Whitespace);
    function Many_Whitespace is new Swordy.Many (Satisfy_Whitespace, 1);

    function Stamp_Word is new Swordy.Stamp (Word, Many_Letter);
    function Ignore_Whitespace is new Swordy.Ignore (Whitespace, Many_Whitespace);


end Rat_Tests.Lexers;