/*********************************************************************
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.
---------------------------------------------------------------
*********************************************************************/
// cxaTokenStream.cpp: implementation of the cxaTokenStream class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "cxaToken.h"
#include "cxAnalyzerTypeMap.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
cxaTokenStream::cxaTokenStream(const cxAnalyzerTypeMap* patmMap)
{
ASSERT(patmMap!=NULL);
m_patmMap =patmMap;
}
cxaTokenStream::~cxaTokenStream()
{
}
//////////////////////////////////////////////////////////////////////
// cooLexxerListener operations
//////////////////////////////////////////////////////////////////////
void cxaTokenStream::vRegisterToken(
const std::tstring& strTokenText,
const cxTokenizerTokenRule* pttrRule,
const cxTokenizerInputStream* ptisStream)
{
// Recognize blank tokens
if(strTokenText.compare(_T(" "))==0)
return;
// Initialize token
int nToid,nAtmID,nIDValue;
nToid =ptisStream->lGetCurrentPosition();
nAtmID =m_patmMap->nGetIDFor(pttrRule);
if(pttrRule!=NULL)
nIDValue=pttrRule->nGetIDValue();
else
nIDValue=-1;
if(nIDValue==0)
return;
// TODO: This part looks quite slow ...
cxaToken atToken(nToid,nAtmID,nIDValue,strTokenText.data());
// Append to tail
push_back(atToken);
}
//////////////////////////////////////////////////////////////////////
// Operations
//////////////////////////////////////////////////////////////////////
void cxaTokenStream::vDump() const
{
const_iterator it;
TRACE(_T("DUMPING cxaTokenStream(0x%08lx):\n"),DWORD(this));
for(it=begin();it!=end();it++)
{
const cxaToken& atok = (*it);
TRACE(_T("#%04d: %s (toid %d)\n"),atok.nAtmType,atok.lpszTokenText,atok.nGetTokenOrderID());
}
}