词法分析器心得体会
XX大学学生课程设计词法分析器分析XX级计算机科学与技术XX年6月15日 摘要 词法分析的主要任务是对源程序进行扫描,词法分析是编译的第一个阶段,词法分析器工作时从左向右逐个字符地对源程序进行扫描,是语法分析的基础。词法分析器的分析过程调用GETSYM时,它通过GETCH过程从源程序中获得一个字符。 如果这个字符是字母,则继续获取字符或数字,最终可以拼成一个单词,查保留字表,如果查到为保留字,SYM变量赋成相应的保留字类型值;如果没有查到,则这个单词应是一个用户自定义的标识符。 关键词:词法分析标识符 Abstract Lexicalanalysisisthemaintaskofthesourceprogramforscanning,thecompilerlexicalanalysisisthefirststage,thelexicalanalyzertoworkeachcharacterfromlefttorighttoscanthesourceprogram,andisthebasisofthesyntaxanalysis.Theanalysisofthelexicalanalyzer procedurecallGETSYM,itthroughtheGETCHprocessfromsourceprogramonecharacteratatime. Ifthecharacterisaletter,continuestogetcharactersorNumbers,finallycanspellaword,checkthereservedwordtable,iffindasreservedwords,SYMvariableintocorrespondingreservedwordtypevalue;Ifnotchecked,thiswordshouldbeauser-definedidentifier. 【Keywords】lexicalanalysisIdentifier 目录 引言..................................................................................................................5 1.设计思路.............................................................................................................6 2.设计意义.............................................................................................................6 3.词法分析器的分析.............................................................................................7 词法分析器的任务................................................................................7 设计内容及功能.....................................................................................7 输出.........................................................................................................7 4.词法分析器的设计.............................................................................................7 5.程序源代码.........................................................................................................7 6.结果分析...........................................................................................................11 7.心