File tree Expand file tree Collapse file tree 10 files changed +162
-2
lines changed
regtests/tests/0142_cursor_tag_len_1 Expand file tree Collapse file tree 10 files changed +162
-2
lines changed Original file line number Diff line number Diff line change 1+ with "templates_parser";
2+
3+ project Cursor_Tag_L1 is
4+
5+ for Languages use ("Ada");
6+
7+ for Source_Dirs use ("src");
8+ for Object_Dir use "obj";
9+ for Exec_Dir use "bin";
10+
11+ for Main use ("main.adb");
12+
13+ end Cursor_Tag_L1;
Original file line number Diff line number Diff line change 1+
2+ package body Cursor_L1.Cursors is
3+
4+ -- -------------
5+ -- Dimension --
6+ -- -------------
7+
8+ function Dimension
9+ (Cursor_Tag : not null access Cursor_Type;
10+ Var_Name : String) return Natural is
11+ begin
12+ return 1 ;
13+ end Dimension ;
14+
15+ -- ----------
16+ -- Length --
17+ -- ----------
18+
19+ function Length
20+ (Cursor_Tag : not null access Cursor_Type;
21+ Var_Name : String;
22+ Path : Templates_Parser.Dynamic.Path) return Natural is
23+ begin
24+ return Natural (Values.Length);
25+ end Length ;
26+
27+ -- ---------
28+ -- Value --
29+ -- ---------
30+
31+ function Value
32+ (Cursor_Tag : not null access Cursor_Type;
33+ Var_Name : String;
34+ Path : Templates_Parser.Dynamic.Path) return String is
35+ begin
36+ return Values.Element (Path(1 ))'Image;
37+ end Value ;
38+
39+ end Cursor_L1.Cursors ;
Original file line number Diff line number Diff line change 1+
2+ with Ada.Containers.Vectors ;
3+
4+ with Templates_Parser ;
5+
6+ package Cursor_L1.Cursors is
7+
8+ package Values_Container is new
9+ Ada.Containers.Vectors (Index_Type => Positive,
10+ Element_Type => Natural);
11+
12+ Values : Values_Container.Vector;
13+
14+
15+ type Cursor_Type is new Templates_Parser.Dynamic.Cursor_Tag with null record ;
16+
17+ -- -------------
18+ -- Dimension --
19+ -- -------------
20+
21+ function Dimension
22+ (Cursor_Tag : not null access Cursor_Type;
23+ Var_Name : String) return Natural;
24+
25+ -- ----------
26+ -- Length --
27+ -- ----------
28+
29+ function Length
30+ (Cursor_Tag : not null access Cursor_Type;
31+ Var_Name : String;
32+ Path : Templates_Parser.Dynamic.Path) return Natural;
33+
34+ -- ---------
35+ -- Value --
36+ -- ---------
37+
38+ function Value
39+ (Cursor_Tag : not null access Cursor_Type;
40+ Var_Name : String;
41+ Path : Templates_Parser.Dynamic.Path) return String;
42+
43+ Handler : aliased Cursor_L1.Cursors.Cursor_Type;
44+
45+ end Cursor_L1.Cursors ;
Original file line number Diff line number Diff line change 1+ package Cursor_L1 is
2+ end Cursor_L1 ;
Original file line number Diff line number Diff line change 1+
2+ with Ada.Command_Line ;
3+ with Ada.Exceptions ;
4+ with Ada.Text_IO ;
5+
6+ with Templates_Parser ;
7+
8+ with Cursor_L1.Cursors ;
9+
10+ procedure Main is
11+ use Ada;
12+
13+ N : constant Natural :=
14+ Natural'Value (Ada.Command_Line.Argument (1 ));
15+ Set : Templates_Parser.Translate_Set;
16+ begin
17+ for Index in 1 .. N loop
18+ Cursor_L1.Cursors.Values.Append (Index);
19+ end loop ;
20+
21+ Text_IO.Put_Line (" N:" & Natural'Image (N));
22+
23+ declare
24+ Content : constant String :=
25+ Templates_Parser.Parse
26+ (Filename => " tmplt/cl1.tmplt" ,
27+ Translations => Set,
28+ Cursor_Tag => Cursor_L1.Cursors.Handler'Access );
29+ begin
30+ Text_IO.Put_Line (Content);
31+ end ;
32+ exception
33+ when E : others =>
34+ Text_IO.Put_Line (" (FF)" & Ada.Exceptions.Exception_Information (E));
35+ end Main ;
Original file line number Diff line number Diff line change 1+ N: 5
2+ 1 2 3 4 5
3+
4+ 1
5+ 2
6+ 3
7+ 4
8+ 5
9+
10+ N: 1
11+ 1
12+
13+ 1
14+
Original file line number Diff line number Diff line change 1+ from test_support import *
2+
3+ gprbuild ('cursor_tag_l1' )
4+ run (['bin/main' , '5' ])
5+ run (['bin/main' , '1' ])
Original file line number Diff line number Diff line change 1+ # Needed even if empty, checked by the testsuite driver
Original file line number Diff line number Diff line change 1+ @_CURSOR_@
2+
3+ @@TABLE@@
4+ @_CURSOR_@
5+ @@END_TABLE@@
6+
Original file line number Diff line number Diff line change @@ -5044,8 +5044,8 @@ package body Templates_Parser is
50445044 (Cursor_Tag, Name, Path => (1 => 1 ));
50455045
50465046 if D = 1 and then L1 = 1 then
5047- -- Not a composite tag
5048- return 0 ;
5047+ -- Not a composite tag, but a standard tag
5048+ return 1 ;
50495049
50505050 elsif K = 1 then
50515051 return L1;
You can’t perform that action at this time.
0 commit comments