File tree Expand file tree Collapse file tree 8 files changed +91
-0
lines changed
regtests/tests/0143_translate_set Expand file tree Collapse file tree 8 files changed +91
-0
lines changed Original file line number Diff line number Diff line change 1+ 1
2+ 2
3+ 3
Original file line number Diff line number Diff line change 1+ from test_support import *
2+
3+ gprbuild ('trans_set' )
4+ run ('trans_set' )
Original file line number Diff line number Diff line change 1+ -- ----------------------------------------------------------------------------
2+ -- Templates Parser --
3+ -- --
4+ -- Copyright (C) 2024, AdaCore --
5+ -- --
6+ -- This is free software; you can redistribute it and/or modify it --
7+ -- under terms of the GNU General Public License as published by the --
8+ -- Free Software Foundation; either version 3, or (at your option) any --
9+ -- later version. This software is distributed in the hope that it will --
10+ -- be useful, but WITHOUT ANY WARRANTY; without even the implied warranty --
11+ -- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
12+ -- General Public License for more details. --
13+ -- --
14+ -- You should have received a copy of the GNU General Public License --
15+ -- distributed with this software; see file COPYING3. If not, go --
16+ -- to http://www.gnu.org/licenses for a complete copy of the license. --
17+ -- ----------------------------------------------------------------------------
18+
19+ with Ada.Text_IO ;
20+
21+ with Templates_Parser ;
22+
23+ procedure Trans_Set is
24+ use Ada;
25+ use Templates_Parser;
26+ S1 : Translate_Set;
27+ S2 : Translate_Set;
28+ begin
29+ Insert (S1, Assoc (" VAR1" , 1 ));
30+ Insert (S1, Assoc (" VAR2" , 2 ));
31+
32+ Insert (S2, Assoc (" VAR3" , 3 ));
33+
34+ S1 := S1 & S2;
35+
36+ Text_IO.Put_Line (Parse (" trans_set.tmplt" , S1));
37+ end Trans_Set ;
Original file line number Diff line number Diff line change 1+ ------------------------------------------------------------------------------
2+ -- Templates Parser --
3+ -- --
4+ -- Copyright (C) 2024, AdaCore --
5+ -- --
6+ -- This is free software; you can redistribute it and/or modify it --
7+ -- under terms of the GNU General Public License as published by the --
8+ -- Free Software Foundation; either version 3, or (at your option) any --
9+ -- later version. This software is distributed in the hope that it will --
10+ -- be useful, but WITHOUT ANY WARRANTY; without even the implied warranty --
11+ -- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
12+ -- General Public License for more details. --
13+ -- --
14+ -- You should have received a copy of the GNU General Public License --
15+ -- distributed with this software; see file COPYING3. If not, go --
16+ -- to http://www.gnu.org/licenses for a complete copy of the license. --
17+ ------------------------------------------------------------------------------
18+
19+ with "templates_parser";
20+
21+ project Trans_Set is
22+
23+ for Source_Dirs use (".");
24+ for Main use ("trans_set.adb");
25+
26+ end Trans_Set;
Original file line number Diff line number Diff line change 1+ @_VAR1_@
2+ @_VAR2_@
3+ @_VAR3_@
Original file line number Diff line number Diff line change @@ -1307,6 +1307,16 @@ package body Templates_Parser is
13071307 return T;
13081308 end " &" ;
13091309
1310+ function " &" (Left, Right : Translate_Set) return Translate_Set is
1311+ T : Translate_Set := Left;
1312+ begin
1313+ for A of Right.Set.all loop
1314+ Insert (T, A);
1315+ end loop ;
1316+
1317+ return T;
1318+ end " &" ;
1319+
13101320 -- -------
13111321 -- "+" --
13121322 -- -------
Original file line number Diff line number Diff line change @@ -265,6 +265,14 @@ package Templates_Parser is
265265 -- doing [T1 := T2 & Assoc] will add Assoc into T2 and set T1 as an
266266 -- alias. This is designed this way for efficiency.
267267
268+ function " &" (Left, Right : Translate_Set) return Translate_Set;
269+ -- Merge Right Translate_Set into Left and return Left with all
270+ -- association in Right added. Note that "&" will modify its
271+ -- first parameter Left. It is intended to be used as [T := T & T2],
272+ -- doing [T1 := T2 & T3] will add all associations from T3 into T2
273+ -- and set T1 as an alias of T2. This is designed this way for
274+ -- efficiency.
275+
268276 function "+" (Item : Association) return Translate_Set
269277 with Inline => True,
270278 Post => Size (" +" 'Result) = 1 ;
You can’t perform that action at this time.
0 commit comments