lex词法分析器课程设计

上传者: sl198811 | 上传时间: 2024-03-27 13:25:53 | 文件大小: 39KB | 文件类型: RAR
%% ///////////////////////////////////////////////////////////////////////////// // rules section // place your Lex rules here "else" {printf("ELSE:%s%c ",yytext,' ');return ELSE;} "if" {printf("IF:%s%c ",yytext,' ');return IF;} "int" {printf("INT:%s%c ",yytext,' ');return INT;} "return" {printf("RETURN:%s%c ",yytext,' ');return RETURN;} "void" {printf("VOID:%s%c ",yytext,' ');return VOID;} "while" {printf("WHILE:%s%c ",yytext,' ');return WHILE;} "<" {printf("LT:%s%c ",yytext,' ');return LT;} ">" {printf("GT:%s%c ",yytext,' ');return GT;} "<=" {printf("LE:%s%c ",yytext,' ');return LE;} ">=" {printf("GE:%s%c ",yytext,' ');return GE;} "==" {printf("EQ:%s%c ",yytext,' ');return EQ;} "!=" {printf("NE:%s%c ",yytext,' ');return NE;} "{" {printf("{:%s%c ",yytext,' '); return '{';} "}" {printf("}:%s%c ",yytext,' '); return '}';} "(" {printf("(:%s%c ",yytext,' ');return '(';} ")" {printf("):%s%c ",yytext,' ');return ')';} "[" {printf("[:%s%c ",yytext,' ');return '[';} "]" {printf("]:%s%c ",yytext,' ');return ']';} "+" {printf("+:%s%c ",yytext,' ');return '+';} "-" {printf("-:%s%c ",yytext,' ');return '-';} "*" {printf("*:%s%c ",yytext,' ');return '*';} "/" {printf("/:%s%c ",yytext,' ');return '/';} "%" {printf("%:%s%c ",yytext,' ');return '%';} ";" {printf(";:%s%c ",yytext,' ');return ';';} "=" {printf("=:%s%c ",yytext,' ');return '=';} "," {printf(",:%s%c ",yytext,' ');return ',';} {id} {printf("id:%s%c ",yytext,' ');return ID;} {number} {printf("number:%s%c ",yytext,' '); return NUMBER;} "/*" { char c; int done = FALSE; ECHO; do { while((c=input())!='*') putchar(c); putchar(c); while((c=input())=='*') putchar(c); putchar(c); if(c=='/') done =TRUE; } while(!done); printf("\n: There are the conment!"); return COMMENT; } %% 程序可以正确的运行,供有需要的同学使用

文件下载

资源详情

[{"title":"( 9 个子文件 39KB ) lex词法分析器课程设计","children":[{"title":"222","children":[{"title":"CMinus_p","children":[{"title":"mylexer.v <span style='color:#111;'> 7.54KB </span>","children":null,"spread":false},{"title":"mylexer.h <span style='color:#111;'> 1.08KB </span>","children":null,"spread":false},{"title":"CMinus.pgw <span style='color:#111;'> 259B </span>","children":null,"spread":false},{"title":"mylexer.c <span style='color:#111;'> 11.51KB </span>","children":null,"spread":false},{"title":"CMinus.pgp <span style='color:#111;'> 725B </span>","children":null,"spread":false},{"title":"mylexer.l <span style='color:#111;'> 2.63KB </span>","children":null,"spread":false}],"spread":true},{"title":"CMinus.txt <span style='color:#111;'> 147B </span>","children":null,"spread":false},{"title":"CMinus_c.exe <span style='color:#111;'> 188.10KB </span>","children":null,"spread":false}],"spread":true},{"title":"www.pudn.com.txt <span style='color:#111;'> 218B </span>","children":null,"spread":false}],"spread":true}]

评论信息

免责申明

【只为小站】的资源来自网友分享,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,【只为小站】 无法对用户传输的作品、信息、内容的权属或合法性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论 【只为小站】 经营者是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。
本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二条之规定,若资源存在侵权或相关问题请联系本站客服人员,zhiweidada#qq.com,请把#换成@,本站将给予最大的支持与配合,做到及时反馈和处理。关于更多版权及免责申明参见 版权及免责申明