まとめ 【トークン読み込み用クラス (VisualBasic用)】

TokenReaderVB.cs


using System;

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

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

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

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

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

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

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

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