Top Prev Next Up Down TEST
ExLamda
Example of the squeeze option (squ) in a Pattern.matches call
001| with
Ada.Text_IO;
002| with Y2018.Text.Core; use
Y2018.Text.Core;
003| with Y2018.Text.Core.Str; use
Y2018.Text.Core.Str;
004| with Y2018.Text.Core.CVarPack; use
Y2018.Text.Core.CVarPack;
005| with Y2018.Text.Jets; use
Y2018.Text.Jets;
006| with Y2018.Text.Jets.MatchPack;
007| with Y2018.Text.Jets.PatternPack;
008| --with DSECT;
009| procedure ExLamda is
010|
__p:PatternPack.Pattern_AC:=PatternPack.compileM("^([\d]+)([\d]+)"c);
011| __m : MatchPack.Match_TY;
012| __line:CFix:="123456789"c;
013| __startPos:Integer:=1;
014| __nextPos:Integer;
015| begin
016| __for cnt
in 0..1 loop
017| _____if
PatternPack.matches(p,startPos,nextPos,line,m,cnt) then
018| ________declare
019|
___________r:I_A_ARRAY:=MatchPack.getMatch(m);
020| ________begin
021| ___________for i in r'first(1) ..
r'last(1) loop
022|
______________Ada.Text_IO.Put_Line(Integer'image(cnt)
& " SUCCESS " & subIA(line,r(i)));
023| ___________end loop;
024| ________end;
025| _____else
026| ________Ada.Text_IO.Put_Line(Integer'image(cnt) & " FAIL");
027| _____end if;
028| __end loop;
029| __Ada.Text_IO.Put_Line ("*** End
of ExLamda ***");
030| end ExLamda;
Result
Running export LD_LIBRARY_PATH=lib;bin/exlamda in TEST
directory.
Note the diffrence between cnt=0 and cnt=1.
001| 0 FAIL
002| 1 SUCCESS 123456789
003| 1 SUCCESS 12345678
004| 1 SUCCESS 9
005| *** End of ExLamda ***