Exemple #1
0
 public Literal(TextLiteralType aMatchType, Int32 aMatchCount, Boolean aMatchResult)
 {
     this.MatchType    = aMatchType;
     this.MatchSuccess = aMatchResult;
     this.MatchCount   = aMatchCount;
     this.MatchNumber  = 0;
 }
Exemple #2
0
        private static Literal PeekLiteral
        (
            String aData,
            Int32 aStartIndex,
            CConvertOptions aPCO
        )
        {
            if (aData.Length <= 0)
            {
                throw new ArgumentException("Empty input text", "Data");
            }
            if (aStartIndex >= aData.Length)
            {
                throw new ArgumentException("Index is out of range.", "StartIndex");
            }


            Literal Result = Literal.InvalidLiteral;

            Int32 PeekI = aStartIndex;
            Int32 MaskI = 0;

            TextLiteralType Mode = PeekSymbol(aData[PeekI], MaskI, aPCO);

            Result.MatchType = Mode;
            Result.MatchCount++;
            PeekI++;

            while ((PeekI < aData.Length) && (PeekI < aStartIndex + aPCO.MaxElementLength))
            {
                Char            C       = aData[PeekI];
                TextLiteralType NewMode = PeekSymbol(C, MaskI, aPCO);

                if (Mode != NewMode)
                {
                    break;
                }

                Result.MatchCount++;
                PeekI++;
                MaskI++;
            }

            string NumberData = aData.Substring(aStartIndex, Result.MatchCount);
            int    Number;

            Result.MatchNumber = int.TryParse(NumberData, out Number) ? Number : 0;

            return(Result);
        }