資源簡介
c++實現的sql解析器,一個經典的詞法分析器,可解析各種復雜的SQL語句

代碼片段和文件信息
//
//?A?collection?class.?based?on?CObArray()?and?adding?some?stack?operations
//
#include?“afxwin.h“
#include?“EMBSQL.h“
#define?XSIZE?128
//
//?Allocate?object?from?the?shared?memory?segment
void?*SCCollection::operator?new(size_t?size)
{
return?shared_malloc(size);
}
//
//?Deallocate?the?shared?memory?for?this?object
void?SCCollection::operator?delete(void?*ptr)
{
shared_free((char?*)ptr);
}
//
//?Constructor?sets?up?the?object‘s?shared?memory?pointers
SCCollection::SCCollection()
{
where?=?0;
upper?=?XSIZE;
array?=?(void?**)shared_malloc(?XSIZE?*?sizeof(sizeof(Cobject*)));
}
//
//?Destructor?release?the?shared?memory?pointers
SCCollection::~SCCollection()
{
shared_free((char*)array);
}
//
//?Push?a?string?(merely?adds)?onto?the?tail?of?the?collection
void?SCCollection::Push(CString?s) //?push?a?string?object?onto?the?stack
{
Add((Cobject*)new?CString(s));
}
//
//?Push?a?collection?as?a?LISTY?(merely?adds)?onto?the?tail?of?the?collection
void?SCCollection::Push(SCCollection?*s)
{
Push(“EOLIST“);
CopyIntoStack(s);
Push(“LIST“);
}
//
//?Pop?a?string?off?(takes?from?the?tail?of?the?collection)
CString*?SCCollection::Pop() //?pop?a?single?object?off?the?stack
{
CString*?ptr?=?NULL;
int?where?=?this->GetSize()?-?1;
if?(where?0)?return?NULL;
ptr?=?(CString*)this->GetAt(where);
RemoveAt(where);
return?ptr;
}
//
//?Make?a?copy?clone?of?the?collection
SCCollection*?SCCollection::Copy()
{
SCCollection?*nstk?=?NULL;
CString*?ptr?=?NULL;
CString*?nPtr?=?NULL;
nstk?=?new?SCCollection();
for?(int?i=0;iGetSize();i++)?{
ptr?=?(CString*)this->GetAt(i);
nPtr?=?new?CString(*ptr);
nstk->Add((Cobject*)nPtr);
}
return?nstk;
}
//
//?Copy?the?collection?specified?into?this?collection?as?a
//?series?of?push?operations
void?SCCollection::CopyIntoStack(SCCollection*?s)
{
CString?*str?=?NULL;
for?(int?i=0;iGetSize();i++)?{
str?=?(CString*)s->GetAt(i);
Push(*str);
}
}
//
//?Clear?the?collection?and?the?pointers?within?the?list
void?SCCollection::Clear()
{
CString?*ptr?=?NULL;
if?(!this)
return;
while(this->GetSize()?>?0)?{
ptr?=?(CString*)this->GetAt(0);
delete?ptr;
this->RemoveAt(0);
}
}
//
//?Print?the?stack?onto?stdout
void?SCCollection::Print()
{
CString?*s?=?NULL;
for?(int?i=this->GetSize()-1;i>=0;i--)?{
s?=?(CString*)this->GetAt(i);
printf(“\t%s\n“(LPCSTR)s->GetBuffer(128));
}
}
/////////////////////////////////////////////////////////
//
//?Set?the?highwater?pointer?to?0?but?don‘t?free?the?memory
void?SCCollection::RemoveAll()
{
where?=?0;
}
//
//?Return?the?pointer?to?the?array
Cobject**?SCCollection::Array()
{
return?(Cobject**)array;
}
//
//?Preinitialize?the?array
void?SCCollection::Array(Cobject**?n)
{
array?=?(void?**)malloc(?XSIZE?*?sizeof(Cobject*));
if?(array?==?NULL)?{
MessageBox(NULL“QuickView?memory?exhausted?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????4235??1999-11-14?16:05??SqlParser參考\Collection.cpp
?????文件???????2937??1999-11-14?16:05??SqlParser參考\Column.cpp
?????文件???????1213??1999-09-02?17:26??SqlParser參考\Column.h
?????目錄??????????0??2004-09-02?16:44??SqlParser參考\Debug
?????文件???????4085??1999-11-14?17:09??SqlParser參考\Embsql.dsp
?????文件????????535??1999-11-14?17:06??SqlParser參考\Embsql.dsw
?????文件??????16591??1999-11-12?13:12??SqlParser參考\Embsql.h
?????文件?????125952??2004-09-02?16:48??SqlParser參考\Embsql.ncb
?????文件??????53760??1999-11-14?17:09??SqlParser參考\Embsql.opt
?????文件???????1404??1999-11-14?17:08??SqlParser參考\Embsql.plg
?????文件????????912??2004-08-31?22:11??SqlParser參考\Embsql.sln
????..A..H.??????8192??2004-09-02?16:48??SqlParser參考\Embsql.suo
?????文件???????3936??2004-08-31?22:11??SqlParser參考\EMBSQL.vcproj
?????文件??????16793??1999-11-14?16:05??SqlParser參考\ExecuteStack.cpp
?????文件??????10170??1999-11-14?16:55??SqlParser參考\Malloc.cpp
?????文件??????23039??2004-08-31?22:11??SqlParser參考\Parser.cpp
?????文件???????2368??1999-11-14?15:08??SqlParser參考\Readme.txt
?????文件????????674??1999-11-14?16:06??SqlParser參考\SCString.cpp
?????文件???????9024??1999-11-14?16:06??SqlParser參考\Table.cpp
?????目錄??????????0??2004-08-31?22:11??SqlParser參考
-----------?---------??----------?-----??----
???????????????286038????????????????????21
- 上一篇:C++Primer中文版第五版
- 下一篇:cminus語法分析器源代碼完整版
評論
共有 條評論