Top Prev Next Up Down TEST

ExIota

Example of grouping and capturing, and one failure pattern 30.


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 ExIota is
010| __p:PatternPack.Pattern_AC;
011| __m : MatchPack.Match_TY;
012| __line:CFix:="abcdefghijk"c;
013| __nextPos:Integer;
014| __found:Boolean;
015| begin
016| __for j in 1 .. 30 loop
017| _____found:=TRUE;
018| _____case j is
019| ________when 1 =>
020| ___________p:=PatternPack.compileM("^(.)"c);
021| ________when 2 =>
022| ___________p:=PatternPack.compileM("^(?:.)"c); -- non capture
023| ________when 3 =>
024| ___________p:=PatternPack.compileM("^(.*)"c);
025| ________when 4 =>
026| ___________p:=PatternPack.compileM("^(?:.*)"c); -- non capture
027| ________when 5 =>
028| ___________p:=PatternPack.compileM("^(.*?)g"c);
029| ________when 6 =>
030| ___________p:=PatternPack.compileM("^(?:.*?)g"c); -- non capture
031| ________when 7 =>
032| ___________p:=PatternPack.compileM("^(.?)"c);
033| ________when 8 =>
034| ___________p:=PatternPack.compileM("^(?:.?)"c); -- non capture
035| ________when 9 =>
036| ___________p:=PatternPack.compileM("^(.+?)g"c);
037| ________when 10 =>
038| ___________p:=PatternPack.compileM("^(.*?)g"c);
039| ________when 11 =>
040| ___________p:=PatternPack.compileM("^(.{5}).*"c);
041| ________when 12 =>
042| ___________p:=PatternPack.compileM("([b-f]{5}?).*"c);
043| ________when 13 =>
044| ___________p:=PatternPack.compileM("([b-f]{5})"c);
045| ________when 14 =>
046| ___________p:=PatternPack.compileM("^([m-n]{4}?).*"c);
047| ________when 15 =>
048| ___________p:=PatternPack.compileM("^(.{5:6}).*"c);
049| ________when 16 =>
050| ___________p:=PatternPack.compileM("^([a-e]{5:6}).*"c);
051| ________when 17 =>
052| ___________p:=PatternPack.compileM("^([a-f]{5:6}).*"c);
053| ________when 18 =>
054| ___________p:=PatternPack.compileM("^([a-j]{5,6}).*"c);
055| ________when 19 =>
056| ___________p:=PatternPack.compileM("^([a-f]{:6}).*"c);
057| ________when 20 =>
058| ___________p:=PatternPack.compileM("^([m-n]{:6}).*"c);
059| ________when 21 =>
060| ___________p:=PatternPack.compileM("^([a-c]{1:}).*"c);
061| ________when 22 =>
062| ___________p:=PatternPack.compileM("^([a-f]{:6}?).*"c);
063| ________when 23 =>
064| ___________p:=PatternPack.compileM("^.*?(g[m-n]{:6}?.).*"c);
065| ________when 24 =>
066| ___________p:=PatternPack.compileM("^.*?(g[m-n]{1:6}?.).*"c);
067| ________when 30 =>
068| ___________p:=PatternPack.compileM("^([m-n]{1})"c); -- FAIL
069| ________when others =>
070| ___________found:=FALSE;
071| _____end case;
072| _____if found = FALSE then
073| ________null;
074| _____elsif PatternPack.matches(p,1,nextPos,line,m) then
075| ________declare
076| ___________r:I_A_ARRAY:=MatchPack.getMatch(m);
077| ________begin
078| ___________Ada.Text_IO.Put_Line(Integer'Image(j) & " =" & subIA(line,r(0)) & "<");
079| ___________if r'length(1) > 1 then
080| ______________Ada.Text_IO.Put_Line(Integer'Image(j) & " >" & subIA(line,r(1)) & "<");
081| ___________else
082| ______________Ada.Text_IO.Put_Line(Integer'Image(j) & " no capture");
083| ___________end if;
084| ________end;
085| _____else
086| ________Ada.Text_IO.Put_Line(Integer'Image(j) & " FAIL");
087| ________Ada.Text_IO.Put_Line(Integer'Image(j) & " ....");
088| _____end if;
089| __end loop;
090| __Ada.Text_IO.Put_Line ("*** End of ExIota ***");
091| end ExIota;

Result

Running export LD_LIBRARY_PATH=lib;bin/exiota in TEST directory.
Note the result number 30 at lines 049 and 050 is the result of a 'no match'. The text 'no capture' is shown for results without a capture parenteses.

001| 1 =a<
002| 1 >a<
003| 2 =a<
004| 2 no capture
005| 3 =abcdefghijk<
006| 3 >abcdefghijk<
007| 4 =abcdefghijk<
008| 4 no capture
009| 5 =abcdefg<
010| 5 >abcdef<
011| 6 =abcdefg<
012| 6 no capture
013| 7 =a<
014| 7 >a<
015| 8 =a<
016| 8 no capture
017| 9 =abcdefg<
018| 9 >abcdef<
019| 10 =abcdefg<
020| 10 >abcdef<
021| 11 =abcdefghijk<
022| 11 >abcde<
023| 12 =bcdefghijk<
024| 12 >bcdef<
025| 13 =bcdef<
026| 13 >bcdef<
027| 14 =abcdefghijk<
028| 14 ><
029| 15 =abcdefghijk<
030| 15 >abcdef<
031| 16 =abcdefghijk<
032| 16 >abcde<
033| 17 =abcdefghijk<
034| 17 >abcdef<
035| 18 =abcdefghijk<
036| 18 >abcdef<
037| 19 =abcdefghijk<
038| 19 >abcdef<
039| 20 =abcdefghijk<
040| 20 ><
041| 21 =abcdefghijk<
042| 21 >abc<
043| 22 =abcdefghijk<
044| 22 ><
045| 23 =abcdefghijk<
046| 23 >gh<
047| 24 =abcdefghijk<
048| 24 >gh<
049| 30 FAIL
050| 30 ....
051| *** End of ExIota ***