下载此文档

编译原理课程设计语言编译器.doc


文档分类:IT计算机 | 页数:约18页 举报非法文档有奖
1/18
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/18 下载此文档
文档列表 文档介绍
编译原理课程设计报告
课题名称: 词法分析器
小组成员:
陈锋: 姚珂:
王自然: 王力:
丁昭岩: 周德娇: 李文莉: 庄黎:

2008221105110010
2008221104210527
CString wordArray[N];
public:
CEditData(CString fileText);
virtual ^CEditData();
BOOL readText ();
BOOL judgeProperty ();
};
文件CEditDate. cpp代码如下:
文件util, c代码如下:
// EditData. cpp: implementation of the CEditData class.
//
//////////////////////////////////////////////////////////////////////
ttinclude ^stdafx. h〃
ttinclude zzEditProject. h〃
ttinclude "EditData. h〃
ttinclude zzWordStruct. h〃
using namespace std;
ttifdef _DEBUG
Sundef THIS_FILE
static char THIS_FILE[]= FILE ;
ttdefine new DEBUG_NEW
Sendif
////////////////////////〃〃〃〃〃〃〃〃〃/〃〃〃〃〃〃〃〃〃〃〃〃〃/
// Construction/Destruction
////////////////////////〃〃〃〃〃〃〃〃〃/〃〃〃〃〃〃〃〃〃〃〃〃〃/
CEditData::CEditData(CString fileText)
{
this->fileText 二 fileText;
}
CEditData::^CEditData()
(
}
bool isDigit(char ch)
if (ch>- 0, &&ch〈='9')
}
else
return false;
}
bool isLetter (char ch)
(
if (ch>二'a &&ch<=,z \ \ ch>二'A' &&ch<- 71)
(
return true;
}
else
return false;
}
int n;
BOOL CEditData::readText ()
{
char ch;
n=0;
for (int i=0; i<fileText. GetLength() ; i++)
(
ch = fileText. GetAt(i);
if (ch二二,,| | ch=13 | | ch==10 | | ch=,\t')
{
continue;
}
else if (isDigit(ch))
{
wordArray[n]=ch;
ch=fileText. GetAt(i+1);
while (isDigit (ch) || ch二二,.,)
wordArray[n]+=ch;
i++; 二力夕二•
ch=fileText. GetAt (i+1);
}
n++;
}
else if (isLetter (ch) | | ch二二'#,| | ch==,J ) (
wordArray[n]=ch;
ch=fileText. GetAt(i+1);
while(isLetter(ch)||isDigit(ch))
(
wordArray[n]+=ch;
i++;
ch=fileText. GetAt (i+1);
}
n++;
}
else if (ch二二'%')
(
wordArray[n]=ch;
ch =fileText. GetAt(i+1);
if (ch =='二')
{
ch=fileText. GetAt(++i);
wordArray[n]+=ch;
}
else
while(fileText. GetAt (i+1) !二','&& fileText. GetAt (i+1) !='\〃'
fileText. GetAt (i+1) !二'%')
{ ch=fileText. GetAt (++i); wordArray[n]+=ch;
}
}
n++;
}
else if (ch=二'+' && fileText. GetAt (i+1) 二二'二’ | | ch二二'+'
file

编译原理课程设计语言编译器 来自淘豆网m.daumloan.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数18
  • 收藏数0 收藏
  • 顶次数0
  • 上传人pppccc8
  • 文件大小80 KB
  • 时间2022-07-12