Skip to content

Commit 8289bd3

Browse files
committed
Merge branch 'po/ada2022' into 'master'
po/ada2022 - migrate templates parser to Ada 2022 See merge request eng/toolchain/templates-parser!6
2 parents 86afce8 + f581587 commit 8289bd3

15 files changed

+477
-501
lines changed

src/templates_parser-cached_files.adb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ package body Cached_Files is
6363
procedure Add
6464
(Filename : String;
6565
T : Tree;
66-
Old : out Tree)
66+
Old : out Tree)
6767
is
6868
L_Filename : constant Unbounded_String := To_Unbounded_String (Filename);
6969

@@ -128,7 +128,7 @@ package body Cached_Files is
128128
-- Tree is used, mark it as obsoleted, it will be removed
129129
-- when no more used by the Release call.
130130
Old.Obsolete := True;
131-
Old.Used := Old.Used + 1;
131+
Old.Used := @ + 1;
132132

133133
-- But current tree is not used, it has been posted here
134134
-- for futur use. But if replaced right away it should be
@@ -152,7 +152,7 @@ package body Cached_Files is
152152

153153
Files (S + 1 .. Index + 1) := Files (S .. Index);
154154

155-
Index := Index + 1;
155+
Index := @ + 1;
156156

157157
Files (S) := T;
158158

@@ -255,6 +255,7 @@ package body Cached_Files is
255255
pragma Assert (T.Info.Next /= T.C_Info);
256256
Release (T.C_Info, Include => False);
257257
end if;
258+
258259
Templates_Parser_Tasking.Unlock;
259260
exception
260261
when others =>
@@ -319,6 +320,7 @@ package body Cached_Files is
319320
if not Result then
320321
return False;
321322
end if;
323+
322324
P := P.Next;
323325
end loop;
324326

src/templates_parser-data.adb

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
------------------------------------------------------------------------------
22
-- Templates Parser --
33
-- --
4-
-- Copyright (C) 1999-2019, AdaCore --
4+
-- Copyright (C) 1999-2024, AdaCore --
55
-- --
66
-- This library is free software; you can redistribute it and/or modify --
77
-- it under terms of the GNU General Public License as published by the --
@@ -27,8 +27,6 @@
2727
-- covered by the GNU Public License. --
2828
------------------------------------------------------------------------------
2929

30-
pragma Ada_2012;
31-
3230
with Ada.Text_IO;
3331

3432
separate (Templates_Parser)
@@ -191,12 +189,13 @@ package body Data is
191189
if Pos > Str'First and then Str (Pos - 1) /= '\' then
192190
-- This is not a quoted character
193191
if Str (Pos) = ')' then
194-
Count := Count - 1;
192+
Count := @ - 1;
195193
elsif Str (Pos) = '(' then
196-
Count := Count + 1;
194+
Count := @ + 1;
197195
end if;
198196
end if;
199-
Pos := Pos - 1;
197+
198+
Pos := @ - 1;
200199
end loop;
201200

202201
if Pos = Str'First then
@@ -274,14 +273,14 @@ package body Data is
274273
loop
275274
exit when K > Str'Last;
276275

277-
I := I + 1;
276+
I := @ + 1;
278277

279278
if Str (K) = '\'
280279
and then K < Str'Last
281280
and then not (Str (K + 1) in '0' .. '9')
282281
then
283282
-- An escaped character, skip the backslash
284-
K := K + 1;
283+
K := @ + 1;
285284

286285
-- Handle some special escaped characters \n \r \t
287286

@@ -296,7 +295,7 @@ package body Data is
296295
S (I) := Str (K);
297296
end if;
298297

299-
K := K + 1;
298+
K := @ + 1;
300299
end loop;
301300

302301
return S (S'First .. I);
@@ -445,9 +444,9 @@ package body Data is
445444
raise Template_Error with "NO_DYNAMIC must be the first filter";
446445
end if;
447446

448-
K := K + 1;
447+
K := @ + 1;
449448

450-
Stop := Stop - 1;
449+
Stop := @ - 1;
451450
end loop;
452451

453452
return new Filter.Set'(FS (FS'First .. K - 1));
@@ -474,6 +473,7 @@ package body Data is
474473
-- ??? check for string literal
475474
exit when Tag (Stop + 1) = '(' or else Stop = Tag'First;
476475
end loop;
476+
477477
MP_Start := Stop + 1;
478478
end if;
479479

@@ -647,11 +647,11 @@ package body Data is
647647

648648
for K in R.Parameters'Range loop
649649
if R.Parameters (K) /= null then
650-
R.Parameters (K) := Data.Clone (R.Parameters (K));
650+
R.Parameters (K) := Data.Clone (@);
651651
end if;
652652
end loop;
653653

654-
R.Def := Clone (R.Def);
654+
R.Def := Clone (@);
655655
end if;
656656

657657
return R;
@@ -666,15 +666,16 @@ package body Data is
666666

667667
loop
668668
if N.Kind = Data.Var then
669-
N.Var := Data.Clone (N.Var);
669+
N.Var := Data.Clone (@);
670670
end if;
671671

672672
exit when N.Next = null;
673673

674-
N.Next := new Node'(N.Next.all);
674+
N.Next := new Node'(@.all);
675675
N := N.Next;
676676
end loop;
677677
end if;
678+
678679
return Root;
679680
end Clone;
680681

@@ -870,6 +871,7 @@ package body Data is
870871
else
871872
Text_IO.Put (Value);
872873
end if;
874+
873875
if Value'Length > 0 then
874876
NL := Value (Value'Last) = ASCII.LF;
875877
else
@@ -927,7 +929,7 @@ package body Data is
927929
begin
928930
while T /= null loop
929931
P := T;
930-
T := T.Next;
932+
T := @.Next;
931933

932934
case P.Kind is
933935
when Var => Release (P.Var);
@@ -953,6 +955,7 @@ package body Data is
953955
for K in P'Range loop
954956
P (K) := Data.Parse (To_String (Parameters (K)), 0);
955957
end loop;
958+
956959
return P;
957960
end To_Data_Parameters;
958961

src/templates_parser-debug.adb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ package body Templates_Parser.Debug is
6565
else
6666
Print (N.VS.all, K + 1);
6767
end if;
68+
6869
N := N.Next;
6970
end loop;
7071

src/templates_parser-expr.adb

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
------------------------------------------------------------------------------
22
-- Templates Parser --
33
-- --
4-
-- Copyright (C) 1999-2019, AdaCore --
4+
-- Copyright (C) 1999-2024, AdaCore --
55
-- --
66
-- This library is free software; you can redistribute it and/or modify --
77
-- it under terms of the GNU General Public License as published by the --
@@ -27,8 +27,6 @@
2727
-- covered by the GNU Public License. --
2828
------------------------------------------------------------------------------
2929

30-
pragma Ada_2012;
31-
3230
with Ada.Text_IO;
3331

3432
separate (Templates_Parser)
@@ -312,7 +310,7 @@ package body Expr is
312310
end F_Xor;
313311

314312
Op_Table : constant array (Expr.Ops) of Ops_Fct :=
315-
(Expr.O_And => F_And'Access,
313+
[Expr.O_And => F_And'Access,
316314
Expr.O_Or => F_Or'Access,
317315
Expr.O_Xor => F_Xor'Access,
318316
Expr.O_Sup => F_Sup'Access,
@@ -322,10 +320,10 @@ package body Expr is
322320
Expr.O_Equal => F_Equ'Access,
323321
Expr.O_Diff => F_Diff'Access,
324322
Expr.O_In => F_In'Access,
325-
Expr.O_Cat => F_Cat'Access);
323+
Expr.O_Cat => F_Cat'Access];
326324

327325
U_Op_Table : constant array (Expr.U_Ops) of U_Ops_Fct :=
328-
(Expr.O_Not => F_Not'Access);
326+
[Expr.O_Not => F_Not'Access];
329327

330328
begin
331329
case E.Kind is
@@ -511,28 +509,28 @@ package body Expr is
511509
-- Check symbolic operators
512510
elsif Expression (Index) = '(' then
513511
Current_Token := (Kind => Open_Par);
514-
Index := Index + 1;
512+
Index := @ + 1;
515513

516514
elsif Expression (Index) = ')' then
517515
Current_Token := (Kind => Close_Par);
518-
Index := Index + 1;
516+
Index := @ + 1;
519517

520518
elsif Expression (Index) = '=' then
521519
Current_Token := (Kind => Binary_Op, Bin_Op => O_Equal);
522-
Index := Index + 1;
520+
Index := @ + 1;
523521

524522
elsif Expression (Index) = '/'
525523
and then Index < Expression'Last
526524
and then Expression (Index + 1) = '='
527525
then
528526
Current_Token := (Kind => Binary_Op, Bin_Op => O_Diff);
529-
Index := Index + 2;
527+
Index := @ + 2;
530528

531529
elsif Expression (Index) = '<' then
532530
Index := Index + 1;
533531
if Expression (Index) = '=' then
534532
Current_Token := (Kind => Binary_Op, Bin_Op => O_Einf);
535-
Index := Index + 1;
533+
Index := @ + 1;
536534
else
537535
Current_Token := (Kind => Binary_Op, Bin_Op => O_Inf);
538536
end if;
@@ -541,15 +539,15 @@ package body Expr is
541539
Index := Index + 1;
542540
if Expression (Index) = '=' then
543541
Current_Token := (Kind => Binary_Op, Bin_Op => O_Esup);
544-
Index := Index + 1;
542+
Index := @ + 1;
545543
else
546544
Current_Token := (Kind => Binary_Op, Bin_Op => O_Sup);
547545
end if;
548546

549547
elsif Expression (Index) = '"' then
550548
-- This is a string, return it
551-
Current_Token
552-
:= (Kind => Value, Start => Index + 1, Stop => Index);
549+
Current_Token :=
550+
(Kind => Value, Start => Index + 1, Stop => Index);
553551

554552
loop
555553
if Current_Token.Stop = Expression'Last then
@@ -560,6 +558,7 @@ package body Expr is
560558
Current_Token.Stop := Current_Token.Stop + 1;
561559
end if;
562560
end loop;
561+
563562
Index := Current_Token.Stop + 2;
564563

565564
else
@@ -584,7 +583,7 @@ package body Expr is
584583
exit when Expression (Index) /= '/'
585584
or else Expression (Index + 1) = '=';
586585

587-
Index := Index + 1;
586+
Index := @ + 1;
588587
end loop;
589588

590589
declare
@@ -634,13 +633,13 @@ package body Expr is
634633
Error ("variable end not found");
635634

636635
else
637-
Current_Token
638-
:= (Kind => Var, Start => I, Stop => Index - 1);
636+
Current_Token :=
637+
(Kind => Var, Start => I, Stop => Index - 1);
639638
end if;
640639

641640
else
642-
Current_Token
643-
:= (Kind => Value, Start => I, Stop => Index - 1);
641+
Current_Token :=
642+
(Kind => Value, Start => I, Stop => Index - 1);
644643
end if;
645644
end;
646645
end if;
@@ -685,6 +684,7 @@ package body Expr is
685684
end case;
686685

687686
Next_Token;
687+
688688
if Current_Token.Kind = Binary_Op
689689
and then Current_Token.Bin_Op = O_Cat
690690
then
@@ -704,6 +704,7 @@ package body Expr is
704704
when Open_Par =>
705705
Next_Token;
706706
Result := Expr;
707+
707708
if Current_Token.Kind = Close_Par then
708709
Next_Token;
709710
return Result;

0 commit comments

Comments
 (0)