Example #1
0
        internal override bool TryMatchInternal(PartialExecutionData data, ref SequenceReader <byte> reader, out OperationStatus status)
        {
            var at         = reader.Consumed;
            var tempReader = reader;

            data.ClearData();
            var inc = Include.TryMatch(data.GetIndexed(0), ref reader, out var match, out status);

            if (inc)
            {
                if (Exclude.TryMatch(data.GetIndexed(1, true, true), ref tempReader, out _, out var tempStatus))
                {
                    status = tempStatus;
                    reader = tempReader;
                    return(false);
                }
            }
            else
            {
                return(false);
            }

            data.AddMatch(0, match);

            return(true);
        }
Example #2
0
        internal override bool TryMatchInternal(PartialExecutionData data, ref SequenceReader <byte> reader, out OperationStatus status)
        {
            status           = OperationStatus.Done;
            data.MayContinue = false;

            foreach (var token in Tokens.Skip(data.Index))
            {
                data.ClearData(data.Index);
                var d = data.GetIndexed(data.Index);

                if (!token.TryMatch(d, ref reader, out var match, out status))
                {
                    data.MayContinue = false;

                    if (data.Index > 0)
                    {
                        data.Index--;
                    }

                    return(false);
                }

                data.AddMatch(data.Index, match);

                // if (status == OperationStatus.NeedMoreData)
                //     return true;

                data.Index++;
            }

            data.MayContinue = false;
            return(true);
        }
Example #3
0
        internal override bool TryMatchInternal(PartialExecutionData data, ref SequenceReader <byte> reader, out OperationStatus status)
        {
            status = OperationStatus.Done;

            if (data.Index > Max)
            {
                data.MayContinue = false;
                return(false);
            }

            if (data.Consumed != 0)
            {
                reader.Advance(data.Consumed - reader.Consumed);
            }

            for (; data.Index <= Max; data.Index++)
            {
                data.MayContinue = false;

                var at = reader.Consumed;
                if (!BaseToken.TryMatch(data.GetIndexed(data.Index, revokeAuthority: data.Index >= Min), ref reader, out var match, out status) || reader.Consumed == at)
                {
                    goto end;
                }

                data.Consumed = reader.Consumed;
                data.ClearData(data.Index);
                data.AddMatch(data.Index, match);

                if (data.Index >= Min)
                {
                    data.MayContinue = true;
                    goto end;
                }
            }

end:
            if (data.Index < Min)
            {
                status = OperationStatus.NeedMoreData;
                return(false);
            }
            else
            {
                if (status != OperationStatus.NeedMoreData)
                {
                    status = OperationStatus.Done;
                }
                else
                {
                    data.MayContinue = true;
                }

                return(true);
            }
        }
Example #4
0
        internal override bool TryMatchInternal(PartialExecutionData data, ref SequenceReader <byte> reader, out OperationStatus status)
        {
            status = OperationStatus.InvalidData;
            var at = reader.Consumed;

            data.ClearData();
            data.MayContinue = true;

            foreach (var token in Tokens.Skip(data.Index))
            {
                try
                {
                    var d = data.GetIndexed(data.Index, revokeAuthority: true);

                    // var tempReader = reader;
                    if (token.TryMatch(d, ref reader, out var match, out var tempStatus))
                    {
                        if (reader.Consumed == at)
                        {
                            continue;
                        }

                        data.AddMatch(data.Index, match);
                        status = tempStatus;

                        if (d.MayContinue)
                        {
                            data.Index--;
                        }

                        return(true);
                    }

                    if (tempStatus == OperationStatus.NeedMoreData)
                    {
                        status = tempStatus;
                    }
                }
                finally
                {
                    data.Index++;
                }
            }

            data.MayContinue = false;

            return(false);
        }