// ================ TextBuffer Initialization =================== /// <summary> /// Create and initialize a TextBuff buffer object for this scanner. /// TextBuff is a buffer for encoded unicode files. /// </summary> /// <param name="source">the input text file</param> /// <param name="fallbackCodepage">Codepage to use if file has /// no BOM. For 0, use machine default; for -1, 8-bit binary</param> public void SetSource(Stream source, int fallbackCodepage) { this.buffer = TextBuff.NewTextBuff(source, fallbackCodepage); this.lNum = 0; this.cNum = -1; this.chr = '\n'; // to initialize yyline, yycol and lineStart GetChr(); }
// =============== StreamBuffer Initialization ================== /// <summary> /// Create and initialize a StreamBuff buffer object for this scanner. /// StreamBuff is buffer for 8-bit byte files. /// </summary> /// <param name="source">the input byte stream</param> public void SetSource(Stream source) { this.buffer = new StreamBuff(source); this.lNum = 0; this.cNum = -1; this.chr = '\n'; // to initialize yyline, yycol and lineStart GetChr(); }
// ============================================================== // ===== Initialization of string-based input buffers ==== // ============================================================== /// <summary> /// Create and initialize a StringBuff buffer object for this scanner /// </summary> /// <param name="source">the input string</param> /// <param name="offset">starting offset in the string</param> public void SetSource(string source, int offset) { this.buffer = new StringBuff(source); this.buffer.Pos = offset; this.lNum = 0; this.cNum = offset - 1; this.chr = '\n'; // to initialize yyline, yycol and lineStart GetChr(); }
// ================ LineBuffer Initialization =================== /// <summary> /// Create and initialize a LineBuff buffer object for this scanner /// </summary> /// <param name="source">the list of input strings</param> public void SetSource(IList<string> source) { this.buffer = new LineBuff(source); this.chr = '\n'; // to initialize yyline, yycol and lineStart this.lNum = 0; this.cNum = -1; GetChr(); }
/// <summary> /// This method restores the buffer value and allied /// scanner state from the given context record value. /// </summary> void RestoreBuffCtx(BufferContext value) { this.buffer = value.buffSv; this.chr = value.chrSv; this.cNum = value.cNumSv; this.lNum = value.lNumSv; this.lineStartNum = value.startSv; }