/// <summary> /// 行コメントおよびブロックコメントをスキップする. /// </summary> public void SkipComment() { Check('/'); GoNext(); if (Current == '/') { GoNextLine(); return; } else if (Current == '*') { GoNext(); while (!EndOfFile) { int p = RestOfLine.IndexOf("*/", StringComparison.CurrentCulture); if (p == -1) { GoNextLine(); } else { GoNext(p + 2); return; } } throw new ParseException(this, "unclosed comment block."); } throw new ParseException(this, string. Format("'/' or '*' expected but {0} found.", Current)); }
/// <summary> /// 引数で指定されたワードを読み取りその分現在位置を前進させる. /// このメソッドは読み取り前の現在位置からはじまり行末で区切られた文字列に対して、 /// 引数で指定されたワードによる前方一致検索を行う. /// そして検索が失敗した場合は<see cref="ParseException"/>をスローする. /// </summary> /// <returns>前進後の現在位置の文字.</returns> /// <param name="keyword">読み取り対象のワード.</param> public char GoNext(string keyword) { if (RestOfLine.StartsWith(keyword, StringComparison.CurrentCulture)) { GoNext(keyword.Length); return(Current); } throw new ParseException(this, string.Format("keyword \"{0}\" is not found.", keyword)); }