一个可以识别c语言中标识符,关健字,运算符与各种数字的词法分析器.用vc6.0编写的.
下面是主要代码.. 【程序编程相关:Spring AOP之Hello Wor】 【推荐阅读:PDA电子邮件系统中邮件识别与封装模块的】 【扩展信息:Hibernate随想】 cstring cdlg::next(int &sy,int &t) { cstring r=""; int s = 1,o,st=1,bit=0; tchar c; t=0; o=sy; tvi=0; tvf=0; while(s&&(sy<in.getlength())){ switch(s){ case 1: c=in[sy]; if(isspace(c)) sy++; else if(isalpha(c)||c==´_´){ s=2; r=c; sy++; } else if(isdigit(c)){ s=4; r+=c; sy++; tvi*=10; tvi+=(c-´0´); tvf*=10; tvf+=(c-´0´); } else{ switch(c){ case ´+´: s=14; break; case ´-´: s=18; break; case ´*´: s=23; break; case ´/´: s=26; break; case ´%´: s=29; break; case ´&´: ... 下一页