トークン読み込み用クラス (大文字・小文字を意識しない 言語用)

これまでC# で作成してきた「SourceToHTML」を、VJ# に焼きなおしてみます。

TokenReaderNoCase.jsl


package SourceToHtml;

//*******************************************************************************************************
// トークンごとに 文字列と その種類を返す ( 大文字・小文字を意識しない 言語用 )
//*******************************************************************************************************
abstract public class TokenReaderNoCase extends TokenReaderCommon
{
//予約語 コレクション (全て小文字にしたもの)
protected System.Collections.Specialized.StringCollection _keyWordsNoCase;
//---------------------------------------------------------------------------------------------------
// 初期化
//---------------------------------------------------------------------------------------------------
protected TokenReaderNoCase(Reader reader, String langType)
{
super(reader, langType);

//予約語 コレクションを設定
initKeyWordNoCase(langType);
}
//---------------------------------------------------------------------------------------------------
// 終了
//---------------------------------------------------------------------------------------------------
protected void Finalize()
{
_keyWordsNoCase = null;
}
//---------------------------------------------------------------------------------------------------
// 予約語 コレクションを設定
//---------------------------------------------------------------------------------------------------
private void initKeyWordNoCase(String langType)
{
//予約語 コレクションを設定 (".\cs7\key.txt")
_keyWordsNoCase = new System.Collections.Specialized.StringCollection();

//予約語ファイルがなければ、予約語コレクションは空っぽ
if (System.IO.File.Exists(System.Windows.Forms.Application.get_StartupPath() + "\\" + langType + "\\key.txt"))
{
System.IO.StreamReader keyReader = new System.IO.StreamReader(System.Windows.Forms.Application.get_StartupPath() + "\\" + langType + "\\key.txt", System.Text.Encoding.GetEncoding("Shift_JIS"));
String s;
while ((s = keyReader.ReadLine()) != null)
{
_keyWordsNoCase.Add(s.ToLower());
}
keyReader.Close();
keyReader = null;
}
}
//---------------------------------------------------------------------------------------------------
// 逐語的文字列か?
//---------------------------------------------------------------------------------------------------
protected boolean IsLiteral()
{
return (_context.currChar == '\'');
}
//---------------------------------------------------------------------------------------------------
// 状態を更新 (逐語的文字列)
//---------------------------------------------------------------------------------------------------
protected void getNextStateStrLit()
{
super.getNextStateStrLit();

if (_context.currChar == '\'')
_context.State = "その他";
}
//---------------------------------------------------------------------------------------------------
// 予約語ではないか?
//---------------------------------------------------------------------------------------------------
protected String getKeyWord()
{
//識別子が 予約語であれば、その文字列を返す
int idxKeyWord = _keyWordsNoCase.IndexOf(_context.currToken.tokenString.ToLower());
if (idxKeyWord >= 0)
return _keyWords.get_Item(idxKeyWord);

return "";
}
}