Changeset 22


Ignore:
Timestamp:
Jun 1, 2014, 3:12:32 AM (7 years ago)
Author:
vadim.godunko
Message:

Replace use of position by flag to detect block start/continuation.

Location:
trunk/forge/source/wiki
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/forge/source/wiki/forge-wiki-parsers.adb

    r21 r22  
    111111      Group      : Positive := 1;
    112112
    113       procedure Append (Block : Block_Parser_Information);
     113      procedure Append
     114       (Block    : Block_Parser_Information;
     115        Is_Start : Boolean);
     116      --  Appends regular expression of the specified block to the result block
     117      --  detection regular expression, compute absolute position of
     118      --  significant groups of result expression, and add this data into
     119      --  internal information.
    114120
    115121      ------------
     
    117123      ------------
    118124
    119       procedure Append (Block : Block_Parser_Information) is
     125      procedure Append
     126       (Block    : Block_Parser_Information;
     127        Is_Start : Boolean) is
    120128      begin
    121129         if not Expression.Is_Empty then
     
    127135          ((Match_Group  => Group,
    128136            Offset_Group => Group + Block.Offset_Group,
     137            Is_Start     => Is_Start,
    129138            Parser_Tag   => Block.Parser_Tag));
    130139         Group := Group + Block.Total_Groups + 1;
     
    133142   begin
    134143      for Block of Block_Registry loop
    135          Append (Block);
     144         Append (Block, True);
    136145      end loop;
    137146
    138       Append (Paragraph_Registry);
     147      Append (Paragraph_Registry, False);
    139148      Expression.Append (Separator_Expression);
    140149      Self.Separator_Group := Group;
     
    166175         Found := False;
    167176
    168          for Index in 1 .. Natural (Self.Block_Info.Length) loop
    169             if Match.First_Index (Self.Block_Info (Index).Match_Group)
    170                  <= Match.Last_Index (Self.Block_Info (Index).Match_Group)
     177         for Item of Self.Block_Info loop
     178            if Match.First_Index (Item.Match_Group)
     179                 <= Match.Last_Index (Item.Match_Group)
    171180            then
    172                Offset :=
    173                  Match.First_Index (Self.Block_Info (Index).Match_Group);
     181               Offset := Match.First_Index (Item.Match_Group);
    174182
    175183               if Self.Block_State = null then
    176                   Self.Block_State :=
    177                     Create_Block_Parser (Self.Block_Info (Index).Parser_Tag);
     184                  Self.Block_State := Create_Block_Parser (Item.Parser_Tag);
    178185                  Self.Block_State.Start_Block;
    179186                  Self.Block_State.Line (Lines (Line).Tail_From (Offset));
    180187
    181188               else
    182                   if Index /= Self.Block_Info.Last_Index then
     189                  if Item.Is_Start then
    183190                     Put_Line (Standard_Error, "WARNING!");
    184191                     --  This is start of next block element, not handled right
  • trunk/forge/source/wiki/forge-wiki-parsers.ads

    r21 r22  
    112112      Match_Group  : Positive;
    113113      Offset_Group : Positive;
     114      Is_Start     : Boolean;
     115      --  Regular expression detects start of new block element of this kind.
     116      --  Note, ordinary paragraph has same expression for both start and
     117      --  continuation, so it is not set for it till another way to distinguish
     118      --  this case will be found.
    114119      Parser_Tag   : Ada.Tags.Tag;
    115120   end record;
Note: See TracChangeset for help on using the changeset viewer.