Top Prev Next Up Down TEST
ExNy
Use of MapPools as character groups in patterns
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
Y2018.Text.Jets.RangeVectorPack;
009| with Y2018.Text.Util; use
Y2018.Text.Util;
010| with Y2018.Text.Util.UrvPack;
011| --with DSECT;
012| procedure ExNy is
013|
__a2fSet:RangeVectorPack.Set_TY.Set:=UrvPack.make_Set("ABCDEF"c);
014|
__j2qSet:RangeVectorPack.Set_TY.Set:=UrvPack.make_Set("JKLMNOPQ"c);
015|
__lowerCaseSet:RangeVectorPack.Set_TY.Set:=UrvPack.make_Set("abcdef"c);
016| __mp:UrvPack.MapPool;
017| __p:PatternPack.Pattern_AC:=new
PatternPack.Pattern;
018| __m : MatchPack.Match_TY;
019| __line:CFix:="J DEF 013 MNO EFJ
R"c;
020| __lineB:CFix:="Jk Def 013 Mno efj
R"c;
021| __startPos:Integer:=1;
022| __nextPos:Integer;
023| begin
024| __UrvPack.insert(mp,"Alfa"c);
025|
__Urvpack.put_Set(mp,"Alfa"c,a2fSet);
026| __UrvPack.insert(mp,"Beta"c);
027|
__Urvpack.put_Set(mp,"Beta"c,j2qSet);
028| __UrvPack.insert(mp,"Gamma"c);
029|
__Urvpack.put_Set(mp,"Gamma"c,lowerCaseSet);
030| __Ada.Text_IO.Put_Line
("*** 0:>" & line & "<");
031|
__PatternPack.compileM(p,"[\P{Alfa}]*([\p{Alfa}\p{Beta}]+)"c,UrvPack.copy_Map(mp));
032| __while
PatternPack.matches(p,startPos,nextPos,line,m) loop
033| _____declare
034|
________r:I_A_ARRAY:=MatchPack.getMatch(m);
035| _____begin
036| ________for i in r'First(1) ..
r'Last(1) loop
037| ___________Ada.Text_IO.Put_Line(Integer'Image(i) & ">" &
subIA(line,r(i)) & "<");
038| ________end loop;
039| _____end;
040| _____startPos:=nextPos;
041| __end loop;
042| __Ada.Text_IO.Put_Line
("*** 1:>" & lineB & "<");
043| __startPos:=1;
044|
__PatternPack.compileM(p,"[\P{Alfa}\P{Gamma}]*([\p{Alfa}\p{Gamma}]+)"c,UrvPack.copy_Map(mp));
045| __while
PatternPack.matches(p,startPos,nextPos,lineB,m) loop
046| _____declare
047|
________r:I_A_ARRAY:=MatchPack.getMatch(m);
048| _____begin
049| ________for i in r'First(1) ..
r'Last(1) loop
050| ___________Ada.Text_IO.Put_Line(Integer'Image(i) & ">" &
subIA(lineB,r(i)) & "<");
051| ________end loop;
052| _____end;
053| _____startPos:=nextPos;
054| __end loop;
055| __Ada.Text_IO.Put_Line
("*** 2:>" & lineB & "<");
056| __startPos:=1;
057|
__PatternPack.compileM(p,"[\P{Alfa}\P{Gamma}]*([\p{Alfa}e]+)"c,UrvPack.copy_Map(mp));
058| __while
PatternPack.matches(p,startPos,nextPos,lineB,m) loop
059| _____declare
060|
________r:I_A_ARRAY:=MatchPack.getMatch(m);
061| _____begin
062| ________for i in r'First(1) ..
r'Last(1) loop
063| ___________Ada.Text_IO.Put_Line(Integer'Image(i) & ">" &
subIA(lineB,r(i)) & "<");
064| ________end loop;
065| _____end;
066| _____startPos:=nextPos;
067| __end loop;
068| __Ada.Text_IO.Put_Line ("*** End
of ExNy ***");
069| end ExNy;
Result
Running export LD_LIBRARY_PATH=lib;bin/exny in TEST
directory.
Three different cases
001| *** 0:>J DEF 013 MNO EFJ R<
002| 0>J DEF<
003| 1>DEF<
004| 0> 013 MNO EFJ<
005| 1>EFJ<
006| ***
1:>Jk Def 013 Mno efj R<
007| 0>Jk Def<
008| 1>Def<
009| 0> 013 Mno ef<
010| 1>ef<
011| ***
2:>Jk Def 013 Mno efj R<
012| 0>Jk De<
013| 1>De<
014| 0> 013 Mno e<
015| 1>e<
016| *** End of ExNy ***