/// <summary> /// ソースファイルを構築する /// </summary> /// <param name="path">ファイルのパス</param> public SourceFile(string path) { _status = SourceFileStatus.BeforeOpen; _path = path; _name = Path.GetFileNameWithoutExtension(_path); _reader = null; _line = 1; _ch = -1; }
/// <summary> /// 次の文字を読み込み /// </summary> public void NextChar() { if (_status == SourceFileStatus.BeforeOpen) { _reader = new StreamReader(_path); _status = SourceFileStatus.Open; } if (_status != SourceFileStatus.Close) { _ch = _reader.Read(); if (_ch == -1) { _reader.Close(); _status = SourceFileStatus.Close; } else if (_ch == '\n') { _line++; } } }