2、ifier(1ormoreletters)read(write);:=Word文档.二、构造Tiny语言DFAID:letter(letter)Number:digit(digit)Word文档.三、根据DFA编写词法分析器#include#include#includeusingnamespacestd;staticintrowCounter=1;//静态变量,用于存储行数staticboolbracketExist=false;//判断注释存在与否,false为不存在classLex{public:o
3、fstreamoutput;stringline="";Lex(stringinputLine){line=inputLine;scan(Trim(line));rowCounter++;}stringTrim(string&str)//函数用于去除每行前后空格{ints=str.find_first_not_of("t");inte=str.find_last_not_of("t");str=str.substr(s,e-s+1);str+=" ";returnstr;}Word文档.voidscan(stringinputLine){ofstrea
4、moutput;output.open("SampleOutput.txt",ios::app);stringline=inputLine;inti=0;stringstr="";inttemp;stringtoken="";output<