トークン読み込み用クラス (VisualBasic用)

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

TokenReaderVB.jsl


package SourceToHtml;

//*******************************************************************************************************
// トークンごとに 文字列と その種類を返す (VisualBasic 用)
//*******************************************************************************************************
public class TokenReaderVB extends TokenReaderNoCase
{
//---------------------------------------------------------------------------------------------------
// 初期化
//---------------------------------------------------------------------------------------------------
public TokenReaderVB(Reader reader, String langType)
{
super(reader, langType);
}
//---------------------------------------------------------------------------------------------------
// 単一行コメントか?
//---------------------------------------------------------------------------------------------------
protected boolean IsComSingle()
{
return (_context.currChar == '\'');
}
//---------------------------------------------------------------------------------------------------
// 複数行コメントか?
//---------------------------------------------------------------------------------------------------
protected boolean IsComMulti()
{
return false;
}
//---------------------------------------------------------------------------------------------------
// 逐語的文字列か?
//---------------------------------------------------------------------------------------------------
protected boolean IsLiteral()
{
return (_context.currChar == '\"');
}
//---------------------------------------------------------------------------------------------------
// 日付か?
//---------------------------------------------------------------------------------------------------
protected boolean IsDate()
{
if (_context.currChar == '#')
{
if ((_context.prevToken != null) && (_context.prevToken.tokenKind.Equals("演算子")))
return true;
}

return false;
}
//---------------------------------------------------------------------------------------------------
// エスケープされた識別子か?
//---------------------------------------------------------------------------------------------------
protected boolean IsEscape()
{
return (_context.currChar == '[');
}
//---------------------------------------------------------------------------------------------------
// 数字か?
//---------------------------------------------------------------------------------------------------
protected boolean IsNumber()
{
if (_context.currChar == '&')
{
if (!_context.State.Equals("不明"))
{
if ((System.Char.ToLower(_context.nextChar) == 'o') || (System.Char.ToLower(_context.nextChar) == 'h'))
return true;
}
}

if (System.Char.IsDigit(_context.currChar)) return true;

return false;
}
//---------------------------------------------------------------------------------------------------
// 状態を更新 (逐語的文字列)
//---------------------------------------------------------------------------------------------------
protected void getNextStateStrLit()
{
_context.State = "逐語的文字列";
_context.nextToken.tokenKind = "文字列";

if (_context.currChar == '\"')
_context.State = "その他";
}
//---------------------------------------------------------------------------------------------------
// 16進表記か?
//---------------------------------------------------------------------------------------------------
protected boolean IsNotHex()
{
// &h で始まっていたら、16進
if (_context.currToken.tokenString.get_Length() > 1)
if (_context.currToken.tokenString.charAt(0) == '&')
if ((_context.currToken.tokenString.charAt(1) == 'h') || (_context.currToken.tokenString.charAt(1) == 'H'))
return false;

return true;
}
//---------------------------------------------------------------------------------------------------
// 状態を更新 (エスケープされた識別子)
//---------------------------------------------------------------------------------------------------
protected void getNextStateIdwEsc()
{
super.getNextStateIdwEsc();

if (_context.currToken.tokenString.get_Length() > 1)
{
if ((_context.currToken.tokenString.charAt(0) == '[') && (_context.currChar == ']'))
_context.State = "その他";
}
}
//---------------------------------------------------------------------------------------------------
// 状態を更新 (日付)
//---------------------------------------------------------------------------------------------------
protected void getNextStateDtm()
{
super.getNextStateDtm();

if (_context.currChar == '#')
_context.State = "その他";
}
}