Skip to content

Commit ce2f694

Browse files
committed
Use Ada 2022 @ short hand syntax.
1 parent a1b25da commit ce2f694

8 files changed

+153
-147
lines changed

src/templates_parser-cached_files.adb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

src/templates_parser-data.adb

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,13 @@ package body Data is
189189
if Pos > Str'First and then Str (Pos - 1) /= '\' then
190190
-- This is not a quoted character
191191
if Str (Pos) = ')' then
192-
Count := Count - 1;
192+
Count := @ - 1;
193193
elsif Str (Pos) = '(' then
194-
Count := Count + 1;
194+
Count := @ + 1;
195195
end if;
196196
end if;
197-
Pos := Pos - 1;
197+
198+
Pos := @ - 1;
198199
end loop;
199200

200201
if Pos = Str'First then
@@ -272,14 +273,14 @@ package body Data is
272273
loop
273274
exit when K > Str'Last;
274275

275-
I := I + 1;
276+
I := @ + 1;
276277

277278
if Str (K) = '\'
278279
and then K < Str'Last
279280
and then not (Str (K + 1) in '0' .. '9')
280281
then
281282
-- An escaped character, skip the backslash
282-
K := K + 1;
283+
K := @ + 1;
283284

284285
-- Handle some special escaped characters \n \r \t
285286

@@ -294,7 +295,7 @@ package body Data is
294295
S (I) := Str (K);
295296
end if;
296297

297-
K := K + 1;
298+
K := @ + 1;
298299
end loop;
299300

300301
return S (S'First .. I);
@@ -443,9 +444,9 @@ package body Data is
443444
raise Template_Error with "NO_DYNAMIC must be the first filter";
444445
end if;
445446

446-
K := K + 1;
447+
K := @ + 1;
447448

448-
Stop := Stop - 1;
449+
Stop := @ - 1;
449450
end loop;
450451

451452
return new Filter.Set'(FS (FS'First .. K - 1));
@@ -645,11 +646,11 @@ package body Data is
645646

646647
for K in R.Parameters'Range loop
647648
if R.Parameters (K) /= null then
648-
R.Parameters (K) := Data.Clone (R.Parameters (K));
649+
R.Parameters (K) := Data.Clone (@);
649650
end if;
650651
end loop;
651652

652-
R.Def := Clone (R.Def);
653+
R.Def := Clone (@);
653654
end if;
654655

655656
return R;
@@ -664,15 +665,16 @@ package body Data is
664665

665666
loop
666667
if N.Kind = Data.Var then
667-
N.Var := Data.Clone (N.Var);
668+
N.Var := Data.Clone (@);
668669
end if;
669670

670671
exit when N.Next = null;
671672

672-
N.Next := new Node'(N.Next.all);
673+
N.Next := new Node'(@.all);
673674
N := N.Next;
674675
end loop;
675676
end if;
677+
676678
return Root;
677679
end Clone;
678680

@@ -925,7 +927,7 @@ package body Data is
925927
begin
926928
while T /= null loop
927929
P := T;
928-
T := T.Next;
930+
T := @.Next;
929931

930932
case P.Kind is
931933
when Var => Release (P.Var);

src/templates_parser-expr.adb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -509,28 +509,28 @@ package body Expr is
509509
-- Check symbolic operators
510510
elsif Expression (Index) = '(' then
511511
Current_Token := (Kind => Open_Par);
512-
Index := Index + 1;
512+
Index := @ + 1;
513513

514514
elsif Expression (Index) = ')' then
515515
Current_Token := (Kind => Close_Par);
516-
Index := Index + 1;
516+
Index := @ + 1;
517517

518518
elsif Expression (Index) = '=' then
519519
Current_Token := (Kind => Binary_Op, Bin_Op => O_Equal);
520-
Index := Index + 1;
520+
Index := @ + 1;
521521

522522
elsif Expression (Index) = '/'
523523
and then Index < Expression'Last
524524
and then Expression (Index + 1) = '='
525525
then
526526
Current_Token := (Kind => Binary_Op, Bin_Op => O_Diff);
527-
Index := Index + 2;
527+
Index := @ + 2;
528528

529529
elsif Expression (Index) = '<' then
530530
Index := Index + 1;
531531
if Expression (Index) = '=' then
532532
Current_Token := (Kind => Binary_Op, Bin_Op => O_Einf);
533-
Index := Index + 1;
533+
Index := @ + 1;
534534
else
535535
Current_Token := (Kind => Binary_Op, Bin_Op => O_Inf);
536536
end if;
@@ -539,7 +539,7 @@ package body Expr is
539539
Index := Index + 1;
540540
if Expression (Index) = '=' then
541541
Current_Token := (Kind => Binary_Op, Bin_Op => O_Esup);
542-
Index := Index + 1;
542+
Index := @ + 1;
543543
else
544544
Current_Token := (Kind => Binary_Op, Bin_Op => O_Sup);
545545
end if;
@@ -582,7 +582,7 @@ package body Expr is
582582
exit when Expression (Index) /= '/'
583583
or else Expression (Index + 1) = '=';
584584

585-
Index := Index + 1;
585+
Index := @ + 1;
586586
end loop;
587587

588588
declare

src/templates_parser-filter.adb

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -393,16 +393,17 @@ package body Filter is
393393
or else (J + 4 <= S'Last and then S (J + 3 .. J + 4) = "/>"))
394394
then
395395
Result (K .. K + EOL'Length - 1) := EOL;
396-
K := K + EOL'Length;
396+
K := @ + EOL'Length;
397+
397398
if S (J + 3) = '>' then
398-
J := J + 4;
399+
J := @ + 4;
399400
else
400-
J := J + 5;
401+
J := @ + 5;
401402
end if;
402403
else
403404
Result (K) := S (J);
404-
K := K + 1;
405-
J := J + 1;
405+
K := @ + 1;
406+
J := @ + 1;
406407
end if;
407408

408409
exit when J > S'Last;
@@ -578,14 +579,13 @@ package body Filter is
578579
if Space = False then
579580
Space := True;
580581

581-
R := R + 1;
582+
R := @ + 1;
582583
Result (R) := ' ';
583584
end if;
584-
585585
else
586586
Space := False;
587587

588-
R := R + 1;
588+
R := @ + 1;
589589
Result (R) := S (K);
590590
end if;
591591

@@ -658,7 +658,7 @@ package body Filter is
658658
Last := Pos;
659659

660660
while Last < S'Last and then S (Last) /= '&' loop
661-
Last := Last + 1;
661+
Last := @ + 1;
662662
end loop;
663663

664664
if Last = S'Last then
@@ -860,12 +860,12 @@ package body Filter is
860860

861861
for P in reverse TS'First .. N loop
862862
Result (K) := TS (P);
863-
K := K - 1;
863+
K := @ - 1;
864864
Count := Count + 1;
865865

866866
if Count mod 3 = 0 and then P /= TS'First then
867867
Result (K) := Separator;
868-
K := K - 1;
868+
K := @ - 1;
869869
end if;
870870
end loop;
871871

@@ -997,10 +997,10 @@ package body Filter is
997997
for J in S'Range loop
998998
if S (J) = ASCII.LF then
999999
Result (K .. K + 4) := "<br/>";
1000-
K := K + 5;
1000+
K := @ + 5;
10011001
else
10021002
Result (K) := S (J);
1003-
K := K + 1;
1003+
K := @ + 1;
10041004
end if;
10051005
end loop;
10061006

@@ -1352,7 +1352,7 @@ package body Filter is
13521352

13531353
for K in S'Range loop
13541354
if not (S (K) = ' ') then
1355-
L := L + 1;
1355+
L := @ + 1;
13561356
Result (L) := S (K);
13571357
end if;
13581358
end loop;
@@ -1656,12 +1656,12 @@ package body Filter is
16561656
By => S (Matches (K).First .. Matches (K).Last));
16571657

16581658
-- Position N just after the inserted replacement text
1659-
N := N + Matches (K).Last - Matches (K).First + 1;
1659+
N := @ + Matches (K).Last - Matches (K).First + 1;
16601660
end loop;
16611661
end loop;
16621662

16631663
-- Prepend the beginning of string before the match
1664-
Result := Result
1664+
Result := @
16651665
& To_Unbounded_String (S (Current .. Matches (0).First - 1))
16661666
& Temp;
16671667

@@ -2023,15 +2023,14 @@ package body Filter is
20232023
Check_Null_Parameter (P);
20242024

20252025
for I in S'Range loop
2026-
Last := Last + 1;
2026+
Last := @ + 1;
20272027

20282028
if S (I) = ' ' then
20292029
Result (Last .. Last + Nbsp_Token'Length - 1) := Nbsp_Token;
2030-
Last := Last + Nbsp_Token'Length - 1;
2030+
Last := @ + Nbsp_Token'Length - 1;
20312031
else
20322032
Result (Last) := S (I);
20332033
end if;
2034-
20352034
end loop;
20362035

20372036
return Result (1 .. Last);
@@ -2088,7 +2087,7 @@ package body Filter is
20882087
else
20892088
-- Go to the next character
20902089

2091-
Last := Last + 1;
2090+
Last := @ + 1;
20922091
end if;
20932092
end loop;
20942093

src/templates_parser-utils.adb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -329,18 +329,18 @@ package body Templates_Parser.Utils is
329329
-- and leave this loop
330330
exit Nested_Tag;
331331
else
332-
N := N - 1;
332+
N := @ - 1;
333333
end if;
334334

335335
elsif T (Last) = '(' then
336-
N := N + 1;
336+
N := @ + 1;
337337
end if;
338338

339339
if Last = T'Last then
340340
-- Matching parent not found
341341
raise Constraint_Error;
342342
else
343-
Last := Last + 1;
343+
Last := @ + 1;
344344
end if;
345345
end loop Nested_Tag;
346346

@@ -354,7 +354,7 @@ package body Templates_Parser.Utils is
354354
and then T (Last + 1) = '"'
355355
then
356356
-- Skip this quote
357-
Last := Last + 1;
357+
Last := @ + 1;
358358

359359
elsif T (Last) = '"'
360360
and then (Last = T'Last or else T (Last + 1) /= '"')
@@ -369,7 +369,8 @@ package body Templates_Parser.Utils is
369369
-- No matching quote
370370
raise Constraint_Error;
371371
end if;
372-
Last := Last + 1;
372+
373+
Last := @ + 1;
373374
end loop Quoted_Value;
374375

375376
-- Here we must have either a ',' or ")"
@@ -381,7 +382,7 @@ package body Templates_Parser.Utils is
381382
end if;
382383
end if;
383384

384-
K := K + 1;
385+
K := @ + 1;
385386
end loop;
386387

387388
return Result;

0 commit comments

Comments
 (0)