文脈情報 クラス

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

TokenContext.h


//*******************************************************************************************************
// 文脈情報クラス
//*******************************************************************************************************
#ifndef TokenContextH
#define TokenContextH
//---------------------------------------------------------------------------
#include <WCHAR.H>
#include <Classes.hpp>
#include "Token.h"
//---------------------------------------------------------------------------
class TTokenContext
{
public:
WideString State; // トークンリーダーの状態

wchar_t prevChar; // 前の文字
wchar_t currChar; // 現在の文字
wchar_t nextChar; // 次の文字

TToken* prevToken; // 前のトークン
TToken* currToken; // 現在のトークン
TToken* nextToken; // 次のトークン

// 初期化
__fastcall TTokenContext();
// 終了
__fastcall ~TTokenContext();
};
#endif

TokenContext.cpp


//*******************************************************************************************************
// 文脈情報クラス
//*******************************************************************************************************
#pragma hdrstop
#include "TokenContext.h"
//-------------------------------------------------------------------------------------------------------
#pragma package(smart_init)
//-------------------------------------------------------------------------------------------------------
// 初期化
//-------------------------------------------------------------------------------------------------------
__fastcall TTokenContext::TTokenContext()
{
State = "その他"; // トークンリーダーの状態

prevChar = L'\0'; // 前の文字
currChar = L'\0'; // 現在の文字
nextChar = L'\0'; // 次の文字

//未確定トークン を 初期化
currToken = new TToken("", "その他");
nextToken = new TToken("", "その他");

//確定済みトークン を 初期化
prevToken = new TToken("", "その他");
}
//-------------------------------------------------------------------------------------------------------
// 終了
//-------------------------------------------------------------------------------------------------------
__fastcall TTokenContext::~TTokenContext()
{
delete currToken;
delete nextToken;
delete prevToken;

currToken = NULL;
nextToken = NULL;
prevToken = NULL;
}