Top Prev Next Up Down

The Matchpack

To use Matchpack we have to see the usage through Patternpack.

Usually the only statement in the code is the declaration:
   r:I_A_ARRAY:=MatchPack.getMatch(m);
the result, r variable in our case, is of type I_A_ARRAY, an array of an array of Integer or indexes of the source data which was searched.
   type I_A is array (1..2) of Integer;
contain index of the first and the last codepoint for something wich is found.
   type I_A_ARRAY is Array(Integer range <>) of I_A;
Contain 0..n found objects where the first, at index value zero, is the whole found object and rest are intreset parts of that object which is marked in the regular expression with simple (capturing) parentheses.

Mostly this is enough but if you want go deeper then you should start with to understand what Match_TY is we have to study the contents

The type Match_TY is private because we want to restrict access to theese maps for any other code execept for code in this package.

type MatchID2RE_ID_Elem_TY
record
___mid:MatchID; -- Key (duplicate the orginal key, the 'mid')
___re:RE_Elem_AC;
___ .....
end record;

package MatchID2RE_ID_TY is new Ada.Containers.Ordered_Maps(
___Key_Type=> MatchID, -- Key (the 'mid')
___Element_Type=> MatchID2RE_ID_Elem_TY,
___....);

private type Match_TY is tagged
record
___map:MatchID2RE_ID_TY.map;
___id:MatchID; -- the 'mid'
end record;

MatchID2RE_ID_Elem_TY
This is the base for the mapping. Here is the only link to node and range of a row. RE_ID is the key.
 
MatchID2RE_ID_TY (Ada.Containers.Ordered_Maps)
MatchID connection to RE_ID . Used and updated in the compilation process.