Ejemplo n.º 1
0
 /// <summary>
 /// Call the Consume parser of this <see cref="Pattern"/> on the <paramref name="source"/> with the <paramref name="result"/>.
 /// </summary>
 /// <param name="source">The <see cref="Source"/> to consume.</param>
 /// <param name="result">A <see cref="Result"/> containing whether a match occured and the captured <see cref="String"/>.</param
 /// <param name="trace">The <see cref="ITrace"/> to record steps in.</param>
 internal override void Consume(ref Source source, ref Result result, ITrace?trace)
 {
     From.Consume(ref source, ref result, trace);
     if (!result)
     {
         result.Error = Error.ConsumeFailed;
         return;
     }
     To.Consume(ref source, ref result, trace);
     while (!result)
     {
         if (source.EOF)
         {
             break;
         }
         source.Position++;
         result.Length++;
         if (To.CheckHeader(ref source))
         {
             To.Consume(ref source, ref result, trace);
         }
     }
     if (!result)
     {
         result.Error = Error.EndOfSource;
     }
 }
Ejemplo n.º 2
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++;
         if (To.CheckHeader(ref Source))
         {
             To.Consume(ref Source, ref Result);
         }
     }
     if (!Result)
     {
         Result.Error = new EndOfSourceError(Expected: To.ToString());
     }
 }
Ejemplo n.º 3
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());
     }
 }
Ejemplo n.º 4
0
 internal override Boolean CheckHeader(ref Source Source) => From.CheckHeader(ref Source);
Ejemplo n.º 5
0
 internal override Boolean CheckHeader(ref Source Source) => Pattern.CheckHeader(ref Source);
Ejemplo n.º 6
0
 internal override Boolean CheckHeader(ref Source Source) => Left.CheckHeader(ref Source) ? true : Right.CheckHeader(ref Source);
Ejemplo n.º 7
0
 /// <summary>
 /// Checks the first character in the <paramref name="source"/> against the header of this node.
 /// </summary>
 /// <remarks>
 /// This is primarily used to check whether a pattern may exist at the current position.
 /// </remarks>
 /// <param name="source">The <see cref="Source"/> to check against.</param>
 /// <returns><c>true</c> if this <see cref="Pattern"/> may be present, <c>false</c> if definately not.</returns>
 internal override Boolean CheckHeader(ref Source source) => Left.CheckHeader(ref source);