Click here to Skip to main content
15,881,803 members
Articles / Programming Languages / C++

Tokenizer and analyzer package supporting precedence prioritized rules

Rate me:
Please Sign up or sign in to vote.
5.00/5 (4 votes)
1 Jan 20023 min read 180.8K   2.8K   54  
A library allowing you to conveniently build a custom tokenizer and analyzer supporting precedence priorized rules
#include <windows.h>
#include <crtdbg.h>
#include "debug.h"

#ifdef _DEBUG

void* __cdecl operator new(size_t nSize, LPCSTR lpszFileName, int nLine)
{
	return ::operator new(nSize, _NORMAL_BLOCK, lpszFileName, nLine);
}

void* __cdecl operator new(size_t nSize)
	{
	void* pResult;

	pResult = _malloc_dbg(nSize, _NORMAL_BLOCK, NULL, 0);

	if (pResult != NULL)
		return pResult;

	_asm int 3;

	return NULL;
	}

void __cdecl operator delete(void* p)
	{
#if defined(_DEBUG)
	_free_dbg(p, _NORMAL_BLOCK);
#else
	free(p);
#endif
	}

#if _MSC_VER >= 1200
void __cdecl operator delete(void* pData, LPCSTR /* lpszFileName */,
	int /* nLine */)
{
	::operator delete(pData);
}
#endif

void* __cdecl operator new(size_t nSize, int nType, LPCSTR lpszFileName, int nLine)
	{
	void* pResult;

	pResult = _malloc_dbg(nSize, nType, lpszFileName, nLine);

	if (pResult != NULL)
		return pResult;

	_asm int 3;

	return NULL;
	}

#ifndef _DLL
_CrtMemState s0;

class	_dbg
	{
	public:

	_dbg()
		{
		_CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_DEBUG );
		_CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_DEBUG );
		_CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_DEBUG );
   
		_CrtMemCheckpoint(&s0);
		};
	~_dbg()
		{
		_CrtMemDumpAllObjectsSince( &s0 );
		};
	}	__dbg;
#endif

#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Germany Germany
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions