トークン読み込み用クラス (Delphi用)
これまでC# で作成してきた「SourceToHTML」を、VJ# に焼きなおしてみます。
TokenReaderDelphi.jsl
package SourceToHtml;//*******************************************************************************************************
// トークンごとに 文字列と その種類を返す (Delphi 用)
//*******************************************************************************************************
public class TokenReaderDelphi extends TokenReaderNoCase
{
//---------------------------------------------------------------------------------------------------
// 初期化
//---------------------------------------------------------------------------------------------------
public TokenReaderDelphi(Reader reader, String langType)
{
super(reader, langType);
}
//---------------------------------------------------------------------------------------------------
// 複数行コメントか?
//---------------------------------------------------------------------------------------------------
protected boolean IsComMulti()
{
if ((_context.currChar == '(') && (_context.nextChar == '*')) return true;
if (_context.currChar == '{') return true;return false;
}
//---------------------------------------------------------------------------------------------------
// 文字か?
//---------------------------------------------------------------------------------------------------
protected boolean IsChar()
{
return (_context.currChar == '#');
}
//---------------------------------------------------------------------------------------------------
// ディレクティブか?
//---------------------------------------------------------------------------------------------------
protected boolean IsDirective()
{
return ((_context.currChar == '{') && (_context.nextChar == '$'));
}
//---------------------------------------------------------------------------------------------------
// 数字か?
//---------------------------------------------------------------------------------------------------
protected boolean IsNumber()
{
if (_context.currChar == '$') return true;
if (System.Char.IsDigit(_context.currChar)) return true;return false;
}
//---------------------------------------------------------------------------------------------------
// 状態を更新 (複数行コメント)
//---------------------------------------------------------------------------------------------------
protected void getNextStateComMul()
{
super.getNextStateComMul();if (_context.currToken.tokenString.get_Length() > 3)
if ((_context.currToken.tokenString.charAt(0) == '(') && (_context.currToken.tokenString.charAt(1) == '*'))
if ((_context.prevChar == '*') && (_context.currChar == ')'))
_context.State = "その他";if (_context.currToken.tokenString.get_Length() > 1)
if ((_context.currToken.tokenString.charAt(0) == '{') && (_context.currChar == '}'))
_context.State = "その他";
}
//---------------------------------------------------------------------------------------------------
// 状態を更新 (文字)
//---------------------------------------------------------------------------------------------------
protected void getNextStateCha()
{
super.getNextStateCha();if (!System.Char.IsDigit(_context.currChar))
_context.State = "不明";
}
//---------------------------------------------------------------------------------------------------
// 16進表記か?
//---------------------------------------------------------------------------------------------------
protected boolean IsNotHex()
{
// $ で始まっていたら、16進
if (_context.currToken.tokenString.get_Length() > 1)
if (_context.currToken.tokenString.charAt(0) == '$')
return false;return true;
}
//---------------------------------------------------------------------------------------------------
// 状態を更新 (ディレクティブ)
//---------------------------------------------------------------------------------------------------
protected void getNextStateDir()
{
super.getNextStateDir();if (_context.currChar == '}')
_context.State = "その他";}
}