private string PreviewZone(ISourceStream source, int index) { source.PreviewPosition++; source.IsDigit(1, 2); source.IsChar(':'); source.IsDigit(1, 2); return(source.PreviewString(index)); }
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()); }
private string PreivewDate(ISourceStream source) { source.IsDigit(4); source.IsChar('-'); source.IsDigit(1, 2); source.IsChar('-'); source.IsDigit(1, 2); return(source.PreviewString()); }
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)); }
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)); }