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

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

TokenReaderNoCase.vb


'*******************************************************************************************************
' トークンごとに その種類と、内容を返す ( 大文字・小文字を意識しない 言語用 )
'*******************************************************************************************************
Public MustInherit Class TokenReaderNoCase
Inherits TokenReaderCommon

'予約語 コレクション (全て小文字にしたもの)
Protected _keyWordsNoCase As System.Collections.Specialized.StringCollection
'---------------------------------------------------------------------------------------------------
' 初期化
'---------------------------------------------------------------------------------------------------
Friend Sub New(ByVal aReader As Reader, ByVal langType As String)
MyBase.New(aReader, langType)

'予約語 コレクションを設定
initKeyWordNoCase(langType)
End Sub
'---------------------------------------------------------------------------------------------------
' 終了
'---------------------------------------------------------------------------------------------------
Protected Overrides Sub Finalize()
_keyWordsNoCase = Nothing
End Sub
'---------------------------------------------------------------------------------------------------
' 予約語 コレクションを設定
'---------------------------------------------------------------------------------------------------
Private Sub initKeyWordNoCase(ByVal langType As String)
'予約語 コレクションを設定 (".\cs7\key.txt")
_keyWordsNoCase = New System.Collections.Specialized.StringCollection()

'予約語ファイルがなければ、予約語コレクションは空っぽ
If (System.IO.File.Exists(System.Windows.Forms.Application.StartupPath + "\" + langType + "\key.txt")) Then
Dim keyReader As System.IO.StreamReader = New System.IO.StreamReader(System.Windows.Forms.Application.StartupPath + "\" + langType + "\key.txt", System.Text.Encoding.GetEncoding("Shift_JIS"))
Dim s As String
Do
s = keyReader.ReadLine()
If (s Is Nothing) Then Exit Do
_keyWordsNoCase.Add(s.ToLower())
Loop
keyReader.Close()
keyReader = Nothing
End If
End Sub
'---------------------------------------------------------------------------------------------------
' 逐語的文字列か?
'---------------------------------------------------------------------------------------------------
Protected Overrides Function IsLiteral() As Boolean
Return (_context.currChar = "'"c)
end function
'---------------------------------------------------------------------------------------------------
' 状態を更新 (逐語的文字列)
'---------------------------------------------------------------------------------------------------
Protected Overrides Sub getNextStateStrLit()
MyBase.getNextStateStrLit()

If (_context.currChar = "'"c) then
_context.State = "その他"
end if
end sub
'---------------------------------------------------------------------------------------------------
' 予約語ではないか?
'---------------------------------------------------------------------------------------------------
Protected Overrides Function getKeyWord() As String
'識別子が 予約語であれば、その文字列を返す
Dim idxKeyWord As Integer = _keyWordsNoCase.IndexOf(_context.currToken.tokenString.ToLower())
If (idxKeyWord >= 0)
Return _keyWords.Item(idxKeyWord)
End If

Return ""
End Function
End Class