使用C++实现左线性文法的标识符识别程序,代码很短,所以就不写注释了。 /* * *标示符识别程序,作者:水/深圳大学软件学院,2009年10月28日 *设:I=标示符,l(L的小写形式)=字母,n=数字 *文法G=({I},{l,n},P,I) *其中P={I->Il,I->In,I->l} * */ #include<iostream.h> //using namespace std; #include<ctype.h> #define EndState 'E'; static char CurrentState = 'R'; char *GetString() { char *str; str = new char; cin>>str; return str; } void ReportError() { //cout<<"ERROR!"<<endl; return; } char identify(char state,char symbol) { switch(state) { case 'R' : switch(symbol) { case 'l' : CurrentState = 'I';