Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Tokenizer and analyzer package supporting precedence prioritized rules

, 1 Jan 2002
A library allowing you to conveniently build a custom tokenizer and analyzer supporting precedence priorized rules
cxtpackagetut_win32vc.zip
cxTokenizer
cxTokenizer.dsp
cxTokenizer.plg
cxtPackage
cxtPackage.plg
cxtPackage.dsp
mathTok
mathTok.plg
mathTok.dsp
simpleCalc
simpleCalc.bmp
simpleCalc.dsp
simpleCalc.plg
tkCommon
cxAnalyzer
cxAnalyzer.dsp
cxAnalyzer.plg
COPYING
cpAbsd.dsw
cxtpackage_win32vc.zip
cxTokenizer.dsp
cxTokenizer.plg
Debug
cxAnalyzer.dsp
cxAnalyzer.plg
cxtPackage.plg
cxtPackage.dsp
COPYING
cpAbsd.dsw
grammaride.zip
stlport_vc645.dll
grammarIDE.exe
pkgcomplete.zip
cxTokenizerMatchTokenRule.inl
cxTokenizer.dsp
cxtPackage.dsp
emptyTestApp
emptyTestApp.clw
res
emptyTestApp.ico
emptyTestApp.dsp
grammarIDE
grammarIDE.clw
res
grammarIDEDoc.ico
icon1.ico
zoomable.ico
Toolbar.bmp
grammarIDE.ico
vssver.scc
grammarIDE.dsp
simpleCalc.bmp
simpleCalc.dsp
vssver.scc
cxaToken.inl
cxAnalyzer.dsp
COPYING
cpAbsd.dsw
pkgsrconly.zip
cxTokenizerMatchTokenRule.inl
cxTokenizer.dsp
cxtPackage.dsp
emptyTestApp.clw
emptyTestApp.ico
emptyTestApp.dsp
vssver.scc
cxaToken.inl
cxAnalyzer.dsp
COPYING
cpAbsd.dsw
#if !defined(AFX_LTRITEMTREEWND_H__6E4108A6_4C37_4F9A_AAD7_5A486AAC442A__INCLUDED_)
#define AFX_LTRITEMTREEWND_H__6E4108A6_4C37_4F9A_AAD7_5A486AAC442A__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// ltrItemTreeWnd.h : header file
//

/////////////////////////////////////////////////////////////////////////////
// CltrItemTreeWnd window

struct cltrItemNode
	{
	cltrItemNode(const cxaParseElement* _papeElem = NULL)
		:	clrBorder(0), 
			clrBackground(RGB(0xcc,0xcc,0xcc)),
			clrForeground(RGB(0xaa,0xaa,0xaa)),
			fIsNode(true),nX(0),nY(0),nWidth(0),
			papeElem(_papeElem)
		{};
	cltrItemNode(const std::tstring& _text, const cxaParseElement* _papeElem = NULL)
		:	clrBorder(0), 
			clrBackground(RGB(0xcc,0xcc,0xcc)),
			clrForeground(RGB(0xaa,0xaa,0xaa)),
			text(_text),
			fIsNode(true),nX(0),nY(0),nWidth(0),
			papeElem(_papeElem)
		{};
	virtual ~cltrItemNode()
		{};

	bool		fIsNode;
	COLORREF	clrBorder;
	COLORREF	clrBackground;
	COLORREF	clrForeground;
	std::tstring text;
	int			nX,nY,nWidth;
	const cxaParseElement *papeElem;
	};

struct cltrItemBranch : public cltrItemNode,
						public std::vector<cltrItemNode*>
	{
	cltrItemBranch(const cxaParseElement* _papeElem = NULL)
		: cltrItemNode(_papeElem),
		  fIsExpanded(false)
		{ fIsNode = false; };
	cltrItemBranch(std::tstring _text, const cxaParseElement* _papeElem = NULL)
		: fIsExpanded(false),
		  cltrItemNode(_text,_papeElem)
		{ fIsNode = false; };
	virtual ~cltrItemBranch()
		{
		const_iterator it;
		for(it=begin();it!=end();it++)
			delete (*it);
		};

	bool		fIsExpanded;
	};

struct cltrItemCoordMap
	{
	typedef std::map< int, cltrItemNode* > innermap_type;
	typedef std::map< int, innermap_type > coordmap_type;
	coordmap_type		mapCoords;

	void				reset() { mapCoords.clear(); };

	void				insert(int x,int y, cltrItemNode* pltrItem)
						{
						coordmap_type::iterator it0;
						innermap_type::iterator it1;
						it0 = mapCoords.find(x);
						if(it0==mapCoords.end())
							{
							mapCoords.insert( std::make_pair(x,innermap_type() ) );
							it0 = mapCoords.find(x);
							}
						it1 = it0->second.find(y);
						if(it1==it0->second.end())
							it0->second.insert( std::make_pair(y,pltrItem) );
						else
							ASSERT(FALSE);
						};

	cltrItemNode*		find(int x,int y)
						{
						coordmap_type::iterator it0;
						innermap_type::iterator it1;
						it0 = mapCoords.find(x);
						if(it0==mapCoords.end())
							return NULL;
						it1 = it0->second.find(y);
						if(it1==it0->second.end())
							return NULL;
						return it1->second;
						};
	};

class CltrItemTreeWnd : public CWnd
{
// Construction
public:
	CltrItemTreeWnd(cxtPackage *pPkg);

// Attributes
public:
	cxtPackage*			m_pPkg;
	CFont				m_Font;
	double				m_fZoomFactor;
	int					m_nLRMargin, m_nTBMargin;
	int					m_nBaseWidth, m_nCenterOffsX;
	int					m_nBaseHeight, m_nCenterOffsY;
	cltrItemBranch*		m_pltrTree;
	cltrItemNode*		m_pltrHilite;
	cltrItemNode*		m_pltrContext;
	HICON				m_icZoom, m_icUnzoom;
	cltrItemCoordMap	m_mapItems;

// Operations
public:
	void				SetTree(cltrItemBranch *pltrTree);

	COLORREF			ColorSlide(COLORREF clr1, COLORREF clr2, int nNom, int nDenom) const;
	void				CalculateItemRect(int x, int y, int nWidth, CRect& rcBounds);
	cltrItemNode*		FindItemFromCoords(int x, int y);
	void				CalculateDims(const cltrItemBranch& ltrBranch, int* pnWidth, int *pnHeight) const;

	void				RecalcViewLayout();
	void				ScrollHandler(bool fHorz, UINT nSBCode, UINT nPos);

	enum eviewstatus
		{
		vs_visible,
		vs_top,
		vs_side,
		vs_bottom
		};

	eviewstatus			DrawItem(CDC *pDC, bool fInsert, int nHilite, int nX, int nY, cltrItemNode* pltrItem, int nWidth=1);
	int					DrawBranch(CDC *pDC, bool fInsert, int nHilite, int nX, int nY, cltrItemBranch& ltrBranch);

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CltrItemTreeWnd)
	//}}AFX_VIRTUAL

// Implementation
public:
	virtual ~CltrItemTreeWnd();

	// Generated message map functions
protected:
	//{{AFX_MSG(CltrItemTreeWnd)
	afx_msg void OnPaint();
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnTimer(UINT_PTR nIDEvent);
	afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar *pScrollBar);
	afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar *pScrollBar);
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu);
	afx_msg void OnLtrcontextShowProps();
	afx_msg void OnUpdateLtrcontextCollapseItem(CCmdUI* pCmdUI);
	afx_msg void OnUpdateLtrcontextExpandItem(CCmdUI* pCmdUI);
	afx_msg void OnLtrcontextExpandItem();
	afx_msg void OnLtrcontextCollapseItem();
	afx_msg void OnLtrcontextShowRawTokenStream();
	afx_msg void OnUpdateLtrcontextShowProps(CCmdUI* pCmdUI);
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_LTRITEMTREEWND_H__6E4108A6_4C37_4F9A_AAD7_5A486AAC442A__INCLUDED_)

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

Share

About the Author

Alexander Berthold
Web Developer
Germany Germany
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150128.1 | Last Updated 2 Jan 2002
Article Copyright 2001 by Alexander Berthold
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid