Top Prev Next Up Down TEST

ExXsi

UrvPack functions for MapPools


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 ExXsi is
013| __a2fSet:RangeVectorPack.Set_TY.Set:=UrvPack.make_Set("ABCDEF"c);
014| __j2qSet:RangeVectorPack.Set_TY.Set:=UrvPack.make_Set("JKLMNOPQ"c);
015| __digitSet:RangeVectorPack.Set_TY.Set:=UrvPack.make_Set("0123456789"c);
016| __mp:UrvPack.MapPool;
017| __p:PatternPack.Pattern_AC:=new PatternPack.Pattern;
018| __m : MatchPack.Match_TY;
019| __line:CFix:="DEF 01 MNO 02 EFJ 03"c;
020| __startPos:Integer:=1;
021| __nextPos:Integer;
022| begin
023| __UrvPack.insert(mp,"Alfa"c);
024| __Urvpack.put_Set(mp,"Alfa"c,digitSet);
025| __PatternPack.compileM(p,"^[\s]*(.*?)(\p{Alfa}+)"c,UrvPack.copy_Map(mp));
026| __while startPos <= line'length loop
027| _____if PatternPack.matches(p,startPos,nextPos,line,m) then
028| ________declare
029| ___________r:I_A_ARRAY:=MatchPack.getMatch(m);
030| ________begin
031| ___________Ada.Text_IO.Put_Line("! " & subIA(line,r(2)) & ":" & subIA(line,r(1)));
032| ________end;
033| ________startPos:=nextPos;
034| _____else
035| ________exit;
036| _____end if;
037| __end loop;
038| __Urvpack.store(mp,"exxsi.dat");
039| __-- ****************************************
040| __UrvPack.clear(mp);
041| __UrvPack.insert(mp,"Beta"c);
042| __Urvpack.put_Set(mp,"Beta"c,a2fSet);
043| __Urvpack.put_Set(mp,"Beta"c,j2qSet);
044| __PatternPack.compileM(p,"^[\s]*(.*?)(\p{Beta}+)"c,UrvPack.copy_Map(mp));
045| __startPos:=1;
046| __while startPos <= line'length loop
047| _____if PatternPack.matches(p,startPos,nextPos,line,m) then
048| ________declare
049| ___________r:I_A_ARRAY:=MatchPack.getMatch(m);
050| ________begin
051| ___________Ada.Text_IO.Put_Line("# " & subIA(line,r(2)) & ":" & subIA(line,r(1)));
052| ________end;
053| ________startPos:=nextPos;
054| _____else
055| ________exit;
056| _____end if;
057| __end loop;
058| __-- ****************************************
059| __UrvPack.load(mp,"exxsi.dat",TRI_UNDEF);
060| __PatternPack.compileM(p,"^(.*?)(\p{Beta}+[\s]*\p{Alfa})"c,UrvPack.copy_Map(mp));
061| __startPos:=1;
062| __while startPos <= line'length loop
063| _____if PatternPack.matches(p,startPos,nextPos,line,m) then
064| ________declare
065| ___________r:I_A_ARRAY:=MatchPack.getMatch(m);
066| ________begin
067| ___________Ada.Text_IO.Put_Line("¤ " & subIA(line,r(2)) & ":" & subIA(line,r(1)));
068| ________end;
069| ________startPos:=nextPos;
070| _____else
071| ________exit;
072| _____end if;
073| __end loop;
074| __UrvPack.list_Map(mp);
075| __Ada.Text_IO.Put_Line ("*** End of ExXsi ***");
076| end ExXsi;

Result

Running export LD_LIBRARY_PATH=lib;bin/exxsi in TEST directory.
Three cases
  1. lines 001..003 - (starting with '!')
  2. lines 004..005 - (starting with '#')
  3. lines 006..007 - (starting with '¤')
At end the list from UrvPack.list_Map of mp-mapPool, lines 008..012

001| ! 01:DEF
002| ! 02:MNO
003| ! 03:EFJ
004| # MNO:DEF 01
005| # J:02 EF
006| ¤ MNO 0:DEF 01
007| ¤ J 0:2 EF
008| -- Top --
009| __Alfa size= 1
010| __Beta size= 1
011| __Number of urvSets 2
012| -- Bottom --
013| *** End of ExXsi ***