
编译原理
haiheng
这个作者很懒,什么都没留下…
展开
-
LEX&YACC使用问题集
http://www.monmouth.com/~wstreett/lex-yacc/lex-yacc.html1.工程路径不允许有空格原创 2005-01-17 17:17:00 · 1093 阅读 · 0 评论 -
一个加法编译器(AddLex.l)
%{ #include void yyerror(char *); #include "AddLex.h" %} %% [0-9]+ { yylval = atoi(yytext); return INTEGER; } [-+/n] return *yytext; [ /t]原创 2005-01-18 16:58:00 · 1142 阅读 · 0 评论 -
sample.l
%%. printf("match everything except newline/n");/n printf("match newline/n");%%int yywrap(void){ return 1;}int main(void){ printf("begin/n"); yylex(); printf("end"); return 0;}原创 2005-01-18 10:09:00 · 939 阅读 · 0 评论 -
一个加法编译器(AddYacc.y)
%{ #include int yylex(void); void yyerror(char *); %} %token INTEGER %% program: program expr /n { printf("%d/n", $2); } | ; expr: INTEGER原创 2005-01-18 16:57:00 · 992 阅读 · 0 评论 -
sample2.l
%{ int yylineno=0;%}%%^(.*)/n printf("%4d/t%s", ++yylineno,yytext);%%int yywrap(void){ return 1;}int main(void){ yyin=fopen("input.txt","r"); yylex(); fclose(yyin); return 0;}原创 2005-01-18 10:36:00 · 890 阅读 · 0 评论 -
sample3.l
digit [0-9]letter [A-Za-z]%{ int count=0;%}%%{letter}({letter}|{digit})* {count++; printf("number of identifiers=%d/n",count);};%%int yywrap(void){ return 1;}int main(void){ yylex(); return 0; }原创 2005-01-18 10:54:00 · 1049 阅读 · 0 评论 -
一个加法编译器(bison.simple)
/* -*-C-*- Note some compilers choke on comments on `#line lines. */#line 3 "bison.simple"/* Skeleton output parser for bison, Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.原创 2005-01-18 16:59:00 · 2917 阅读 · 0 评论