Beispiel #1
0
Token* Scanner::CreateToken() {
	Token *t;
	if (((char*) heapTop + (int) sizeof(Token)) >= (char*) heapEnd) {
		CreateHeapBlock();
	}
	t = (Token*) heapTop;
	heapTop = (void*) ((char*) heapTop + sizeof(Token));
	t->val = NULL;
	t->next = NULL;
	return t;
}
Beispiel #2
0
static CJcToken* CreateToken(CJcScanner* pScanner)
{
	CJcToken *pToken;
	if (((jc_char*) pScanner->pHeapTop + (jc_int) sizeof(CJcToken)) >= (jc_char*) pScanner->pHeapEnd)
		CreateHeapBlock(pScanner);
	pToken = (CJcToken*) pScanner->pHeapTop;
	pScanner->pHeapTop = (void*) ((jc_char*) pScanner->pHeapTop + sizeof(CJcToken));
	pToken->val = NULL;
	pToken->next = NULL;
	return pToken;
}
Beispiel #3
0
void Scanner::AppendVal(Token *t) {
	int reqMem = (tlen + 1) * sizeof(wchar_t);
	if (((char*) heapTop + reqMem) >= (char*) heapEnd) {
		if (reqMem > HEAP_BLOCK_SIZE) {
			wprintf(L"--- Too long token value\n");
			exit(1);
		}
		CreateHeapBlock();
	}
	t->val = (wchar_t*) heapTop;
	heapTop = (void*) ((char*) heapTop + reqMem);

	wcsncpy(t->val, tval, tlen);
	t->val[tlen] = L'\0';
}
Beispiel #4
0
static void AppendVal(CJcScanner* pScanner, CJcToken *pToken)
{
	jc_int reqMem = (pScanner->tlen + 1) * sizeof(jc_char);
	if (((jc_char*) pScanner->pHeapTop + reqMem) >= (jc_char*) pScanner->pHeapEnd)
	{
		if(reqMem > HEAP_BLOCK_SIZE)
		{
			g_oInterface.PrintError(0, "%s\n", "--- Too long token value");
			g_oInterface.Abort();
		}
		CreateHeapBlock(pScanner);
	}
	pToken->val = (jc_char*) pScanner->pHeapTop;
	pScanner->pHeapTop = (void*) ((jc_char*) pScanner->pHeapTop + reqMem);
	StringCopyN(pToken->val, pScanner->tval, pScanner->tlen);
	pToken->val[pScanner->tlen] = '\0';
}