예제 #1
0
 private string PreviewZone(ISourceStream source, int index)
 {
     source.PreviewPosition++;
     source.IsDigit(1, 2);
     source.IsChar(':');
     source.IsDigit(1, 2);
     return(source.PreviewString(index));
 }
예제 #2
0
 private string PreivewTime(ISourceStream source, int index = -1)
 {
     source.IsDigit(1, 2);
     source.IsChar(':');
     source.IsDigit(1, 2);
     source.IsChar(':');
     source.IsDigit(1, 2);
     if (source.PreviewChar == '.')
     {
         source.PreviewPosition++;
         source.IsDigit(1, 12);
     }
     if (index > -1)
     {
         return(source.PreviewString(index));
     }
     return(source.PreviewString());
 }
예제 #3
0
 private string PreivewDate(ISourceStream source)
 {
     source.IsDigit(4);
     source.IsChar('-');
     source.IsDigit(1, 2);
     source.IsChar('-');
     source.IsDigit(1, 2);
     return(source.PreviewString());
 }
예제 #4
0
        private string PreviewDigit(ISourceStream source)
        {
            var index      = source.PreviewPosition;
            var startIndex = index;
            var text       = source.Text;

            if (!char.IsDigit(text[index++]))
            {
                throw new InvalidCastException();
            }
            while (char.IsDigit(text[index]) || text[index] == '.')
            {
                index++;
            }
            source.PreviewPosition = index;
            return(source.PreviewString(startIndex));
        }
예제 #5
0
        public override Token TryMatch(ParsingContext context, ISourceStream source)
        {
            if (!IsValid(source.PreviewChar))
            {
                return(null);
            }
            source.PreviewPosition++;
            do
            {
                var current = source.PreviewChar;
                if (!IsValid(source.PreviewChar))
                {
                    break;
                }
                source.PreviewPosition++;
            }while (!source.EOF());
            var value = source.PreviewString();

            return(source.CreateToken(this.OutputTerminal, value));
        }