C0语言的词法分析程序软件学院1291410044杨德生词法规则:C0语言程序是一组由”{”和”}”括起来的语句序列,语句只有赋值语句,输入语句和输出语句。变量均定义为整形变量,默认初始值为0,因此不需要变量的声明。表达式由整数,变量和运算组成。运算符有两种——加法运算符和乘法运算符。形式化此法运算符:形式化词法规则:实现DFA:StartstateS0EndstateS*FirstinS0{startinginS0}{ifnextcharacteris“{”}gotoS1{nowinS1}{ifnextcharacterisreadifnextcharacteris0...9ifnextcharacterisa...zifnextcharacterisA...Z}gotoS2{nowisS3}{ifnextcharacteriswriteifnextcharacteris0...9ifnextcharacterisa...zifnextcharacterisA...Z}(nowinS2){ifnextcharateris(}gotoS4{nowinS3}{ifnextcharacteris(}gotoS6{nowinS6orS4}ifnextcharacteris)gotoS7{nowinS7}{ifnextcharacteris=ifnextcharacteris;}gotoS7{nowinS7}ifnextcharacteris}gotoS*