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
cxtpackage_win32vc.zip
cxTokenizer.dsp
cxTokenizer.plg
Debug
cxAnalyzer.dsp
cxAnalyzer.plg
cxtPackage.plg
cxtPackage.dsp
grammaride.zip
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
pkgsrconly.zip
cxTokenizerMatchTokenRule.inl
cxTokenizer.dsp
cxtPackage.dsp
emptyTestApp.clw
emptyTestApp.ico
emptyTestApp.dsp
vssver.scc
cxaToken.inl
cxAnalyzer.dsp
/*********************************************************************
	Copyright (C) 2001 by

		Alexander Berthold, alexander-berthold@web.de.
		Hoegestr. 54
		79108 Freiburg i. Breisgau
		Germany

    -- This file is part of cxAnalyzer --

    "cxAnalyzer" is free software; you can redistribute it and/or 
	modify it under the terms of the GNU Lesser General Public 
	License as published by the Free Software Foundation; either 
	version 2 of the License, or any later version.

    "cxAnalyzer" is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
	License along with "cxAnalyzer"; if not, write to the Free 
	Software  Foundation, Inc., 59 Temple Place, Suite 330, 
	Boston, MA  02111-1307  USA

    ---------------------------------------------------------------
      If you find any bugs or if you make other corrections/
	  enhancements, i'd appreciate if you'd let me know about 
	  that. My email is
  
       alexander-berthold@web.de
  
      If you share this code, do not remove this text.
    ---------------------------------------------------------------

Class:      cxAnalyzerTypeMap
Author:     Alexander Berthold
Copyright:  Alexander Berthold
Date:       2001/06/12
Version:	0.1.07
Purpose:    Stores metadata for the analyzer token / rule IDs.
			

Version history:

	-	2001/05/19
		Released the version 0.1.05

	-	2001/06/01
		Added #DEFINE's for the subtypes ATM_SUBT_RULE_FINITE and
		ATM_SUBT_RULE_OPEN (for closed rules / open rules)

	-	2001/06/12
		Current source labeled version 0.1.07

*********************************************************************/

// cxAnalyzerTypeMap.h: interface for the cxAnalyzerTypeMap class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_CXANALYZERTYPEMAP_H__0FAC41ED_07D2_4FD8_9514_34B34370D8B8__INCLUDED_)
#define AFX_CXANALYZERTYPEMAP_H__0FAC41ED_07D2_4FD8_9514_34B34370D8B8__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

// Forward references

class cxTokenizerMap;
class cxTokenizerMapData;
class cxTokenizerTokenRule;

#define	ATM_ID_INVALID			0
#define	ATM_ID_LITERAL			-1
#define	ATM_ID_MATCHALL			-2
#define	ATM_ID_SUBBRANCH		-3
#define ATM_ID_NIL				-4

#define	ATM_MTYPE_TOKEN			0
#define	ATM_MTYPE_COMP_TOKEN	1
#define	ATM_MTYPE_RULE			2

#define	ATM_SUBT_RULE_UNDEF		-1
#define	ATM_SUBT_RULE_FINITE	0
#define	ATM_SUBT_RULE_OPEN		1

#define	IDVALUE_NULL_TOKEN		-3
#define IDVALUE_REORDER			-2

class cxAnalyzerTypeInfo
{
// Construction
public:
	cxAnalyzerTypeInfo(int nAtmType, int nMType, int nSubType)
		{
		m_nAtmType	=nAtmType;
		m_nMType	=nMType;
		m_nSubType	=nSubType;
		}

	~cxAnalyzerTypeInfo()
		{
		}

// Attributes
protected:
	int				m_nAtmType;
	int				m_nMType;
	int				m_nSubType;
	void			*m_pvData;

// Operations
public:
	int				nGetAtmType() const
		{ return m_nAtmType; };
	int				nGetMType() const
		{ return m_nMType; };
	int				nGetSubType() const
		{ return m_nSubType; };
	void*			pvGetData()
		{ return m_pvData; };
	const void*		pvGetData() const
		{ return m_pvData; };
	void*			pvSetData(void* pvNewData)
		{ void *pvTemp = m_pvData; m_pvData = pvNewData; return pvTemp; };
	void			vSetSubType(int nSubType)
		{ m_nSubType = nSubType; };
};

class cxAnalyzerTypeMap
{
// Construction
public:
	cxAnalyzerTypeMap();
	virtual ~cxAnalyzerTypeMap();

// Attributes
protected:
	int				m_nNextID;

	typedef std::map<std::tstring,int>	
					strmap_type;
	typedef std::map<DWORD,int>			
					dwmap_type;
	typedef std::map<int,cxAnalyzerTypeInfo*>
					atmmap_type;
	typedef std::map<int,int>
					atm_to_id_map_type;

	// Mapping from string identifiers to ID's
	strmap_type		m_mapStr;
	// Mapping from DWORD(cooLexxerTokenRule*) to ID's
	dwmap_type		m_mapDW;
	// Mapping from AtmID to cxAnalyzerTypeInfo
	atmmap_type		m_mapAtmInfo;
	// Mapping from CustID to AtmID
	atm_to_id_map_type m_mapCustIDtoAtmID;

// Protected operations
protected:
	void			vInitFromTokenizerMapData(const cxTokenizerMapData* plmdRules);

// Operations
public:
	virtual bool	fCheckValid() const { return true; };

	void			vInitFromTokenizerMap(const cxTokenizerMap* pmInit);
	void			vSetCustIDToAtmMapping(int nCustID, int nAtmID);
	int				nGetIDFor(const cxTokenizerTokenRule* pltrRule) const;
	int				nGetIDFor(const std::tstring& str, bool fCreate = true);
	int				nGetIDFor(LPCTSTR lpszString, bool fCreate = true);
	int				nGetIDFor(int nCustID) const;

	cxAnalyzerTypeInfo*
					patiGetTypeInfo(int nAtmID);
	const cxAnalyzerTypeInfo*
					patiGetTypeInfo(int nAtmID) const
					{ return patiGetTypeInfo(nAtmID); };
	cxAnalyzerTypeInfo*
					patiSetTypeInfo(int nID, int nMType, int nSubType);

	// For testing purposes only
	std::tstring	strGetStringForID(int nID);
	DWORD			dwGetDWORDForID(int nID);
	void			vDump();
};

#endif // !defined(AFX_CXANALYZERTYPEMAP_H__0FAC41ED_07D2_4FD8_9514_34B34370D8B8__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 | Mobile
Web03 | 2.8.140827.1 | Last Updated 2 Jan 2002
Article Copyright 2001 by Alexander Berthold
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid