Exemplo n.º 1
0
 internal override void Consume(ref Source Source, ref Result Result)
 {
     From.Consume(ref Source, ref Result);
     if (!Result)
     {
         Result.Error = new ConsumeFailedError(Expected: From.ToString());
         return;
     }
     To.Consume(ref Source, ref Result);
     while (!Result)
     {
         if (Source.EOF)
         {
             break;
         }
         Source.Position++;
         Result.Length++;
         //Check for the escape before checking for the end of the range
         if (Escape.CheckHeader(ref Source))
         {
             Escape.Consume(ref Source, ref Result);
             Result.Error = new ConsumeFailedError(Expected: To.ToString());                     //We need an error to continue the loop, and this is the current error
         }
         if (To.CheckHeader(ref Source))
         {
             To.Consume(ref Source, ref Result);
         }
     }
     if (!Result)
     {
         Result.Error = new EndOfSourceError(Expected: To.ToString());
     }
 }
Exemplo n.º 2
0
 internal override void Consume(ref Source Source, ref Result Result)
 {
     From.Consume(ref Source, ref Result);
     if (Result)
     {
         Level++;
     }
     while (Level > 0)
     {
         if (Source.EOF)
         {
             break;
         }
         Source.Position++;
         Result.Length++;
         if (From.CheckHeader(ref Source))
         {
             From.Consume(ref Source, ref Result);
             if (Result)
             {
                 Level++;
             }
         }
         if (To.CheckHeader(ref Source))
         {
             To.Consume(ref Source, ref Result);
             if (Result)
             {
                 Level--;
             }
         }
     }
     if (Level != 0)
     {
         Result.Error = new ConsumeFailedError(Expected: this.ToString());
     }
 }