导航:首页 > 源码编译 > 编译课程设计

编译课程设计

发布时间:2022-01-22 12:54:02

A. 编译原理课程设计在哪可以买

摘要 编译理论和技术作为计算机科学研究和工程应用的基础,受到了广泛的重视。编译原理也是大学计算机专业的必修课程。本书使用优秀的开源Java编译器GJC作为编译教学的基础平台,通过分析一个真正实用的现代编译系统,把编译理论应用到实际的工程实践中。全书不仅包括对编译器源代码的分析、对实例的讲解,还在最后给出3个具体的课程设计实验,介绍如何用书本上的编译理论实现一个真正的编译器。●使用优秀的开源编译器作为教学平台,系统规模不大,且源程序有着很好的注释。●通过详尽的源代码剖析和实例讲解,循序渐进地启发学生完成课程设计。●结合实际应用的要求,使课程设计既覆盖知识点,又接近工程实践需要。●是一本注重应用的实验教程,因此可以和讲授编译理论的教材配合使用。编译原理是大学计算机专业的必修课程。本书使用优秀的开源Java编译器GJC作为编译教学的基础平台,通过分析一个真正实用的现代编译系统,把编译理论应用到实际的工程实践中。全书不仅包括对编译器源代码的分析、对实例的讲解,还在最后给出3个具体的课程设计实验,介绍如何用书本上的编译理论实现一个真正的编译器。本书适合作为大专院校编译原理课程设计的指导用书,相关的从业人员和研究人员也可以从中获得有益的参考。

B. 编译原理课程设计怎么写

摘要

C. 求编译原理课程设计


语法规则及函数模块如下所示:
int do_stat()
{
int es=0;
fscanf(fp,"%s %s\n",&token,&token1);
printf("%s %s\n",token,token1);
es=statement();
if (es>0) return(es);
fscanf(fp,"%s %s\n",&token,&token1);
printf("%s %s\n",token,token1);
if(strcmp(token,"while")==0)
{
fscanf(fp,"%s %s\n",&token,&token1);
printf("%s %s\n",token,token1);
if(strcmp(token,"(")) return(es=5);
fscanf(fp,"%s %s\n",&token,&token1);
printf("%s %s\n",token,token1);
es=expression();
if(es>0) return(es);
if(strcmp(token,")")) return(es=6);
fscanf(fp,"%s %s\n",&token,&token1);
printf("%s %s\n",token,token1);
}
else es=3;
return(es);
}
//<声明语句> ::=int <变量>|<变量>;
//<declaration_stat>::=int ID,;
int declaration_stat()
{
int es=0;
fscanf(fp,"%s %s\n",&token,&token1);
printf("%s %s\n",token,token1);
if (strcmp(token,"ID")) return(es=3); //不是标识符
fscanf(fp,"%s %s\n",&token,&token1);
printf("%s %s\n",token,token1);
while(strcmp(token,",")==0 )
{
fscanf(fp,"%s %s\n",&token,&token1);
printf("%s %s\n",token,token1);
if (strcmp(token,"ID")) return(es=3); //不是标识符
fscanf(fp,"%s %s\n",&token,&token1);
printf("%s %s\n",token,token1);
};
if (strcmp(token,";") ) return(es=4);
fscanf(fp,"%s %s\n",&token,&token1);
printf("%s %s\n",token,token1);
return(es);
}
//<程序>::=
//program::=
int program()
{
int es=0;
fscanf(fp,"%s %s\n",token,token1);
printf("%s %s\n",token,token1);
if(strcmp(token,"main")==0)
{
fscanf(fp,"%s %s\n",&token,&token1);
printf("%s %s\n",token,token1);
if (strcmp(token,"(")) return(es=5); //少左括号
fscanf(fp,"%s %s\n",&token,&token1);
printf("%s %s\n",token,token1);
if (strcmp(token,")")) return(es=6); //少右括号
fscanf(fp,"%s %s\n",&token,&token1);
printf("%s %s\n",token,token1);
}
else
{
es=8;
return(es);
}
if(strcmp(token,"{"))//判断是否'{'
{
es=1;
return(es);
}
fscanf(fp,"%s %s\n",&token,&token1);
printf("%s %s\n",token,token1);
es=declaration_list();
if (es>0) return(es);
es=statement_list();
if (es>0) return(es);
if(strcmp(token,"}"))//判断是否'}'
{
es=2;
return(es);
}
return(es);
}
输入如下:
main()
{int a,b,c;
read a;
read b;
c=0;
do{
c=a*b;
b=b+1;
a=a-1;
}while(b<=20)
write c;
}
输出结果如下:
请输入源程序文件名(包括路径):main.txt
词法分析成功!
main main
( (
) )
{ {
int int
ID a
, ,
ID b
, ,
ID c
; ;
read read
ID a
; ;
read read
ID b
; ;
ID c
= =
NUM 0
; ;
do do
{ {
ID c
= =
ID a
* *
ID b
; ;
ID b
= =
ID b
+ +
NUM 1
; ;
ID a
= =
ID a
- -
NUM 1
; ;
} }
while while
( (
ID b
<= <=
ID b
<= <=
NUM 20
) )
write write
ID c
; ;
ID c
; ;
} }
=====语法分析结果!======
语法分析成功!
程序分析成功!!!

别忘了加分啊,呵呵

D. 编译原理期末课程设计

工大学生伤不起啊锏惧害鍦板浘

本数据来源于网络地图,最终结果以网络地图最新数据为准。

E. 急求:帮忙做一下编译原理课程设计(关于FIRST和FOLLOW集合的)

名称:first和follow集合算法设计办
我知道更多

F. 编译原理课程设计

%{

/* FILENAME: C.Y */

%}
#define YYDEBUG_LEXER_TEXT (yylval) /* our lexer loads this up each time */
#define YYDEBUG 1 /* get the pretty debugging code to compile*/
#define YYSTYPE char * /* interface with flex: should be in header file */
/* Define terminal tokens */
/* keywords */
%token AUTO DOUBLE INT STRUCT
%token BREAK ELSE LONG SWITCH
%token CASE ENUM REGISTER TYPEDEF
%token CHAR EXTERN RETURN UNION
%token CONST FLOAT SHORT UNSIGNED
%token CONTINUE FOR SIGNED VOID
%token DEFAULT GOTO SIZEOF VOLATILE
%token DO IF STATIC WHILE
/* ANSI Grammar suggestions */
%token IDENTIFIER STRINGliteral
%token FLOATINGconstant INTEGERconstant CHARACTERconstant
%token OCTALconstant HEXconstant
/* New Lexical element, whereas ANSI suggested non-terminal */
%token TYPEDEFname /* Lexer will tell the difference between this and
an identifier! An identifier that is CURRENTLY in scope as a
typedef name is provided to the parser as a TYPEDEFname.*/
/* Multi-Character operators */
%token ARROW /* -> */
%token ICR DECR /* ++ -- */
%token LS RS /* << >> */
%token LE GE EQ NE /* <= >= == != */
%token ANDAND OROR /* && || */
%token ELLIPSIS /* ... */
/* modifying assignment operators */
%token MULTassign DIVassign MODassign /* *= /= %= */
%token PLUSassign MINUSassign /* += -= */
%token LSassign RSassign /* <<= >>= */
%token ANDassign ERassign ORassign /* &= ^= |= */
%start translation_unit
%%
/* CONSTANTS */
constant:
INTEGERconstant
| FLOATINGconstant
/* We are not including ENUMERATIONconstant here because we
are treating it like a variable with a type of "enumeration
constant". */
| OCTALconstant
| HEXconstant
| CHARACTERconstant
;

string_literal_list:
STRINGliteral
| string_literal_list STRINGliteral
;
/************************* EXPRESSIONS ********************************/
primary_expression:
IDENTIFIER /* We cannot use a typedef name as a variable */
| constant
| string_literal_list
| '(' comma_expression ')'
;
postfix_expression:
primary_expression
| postfix_expression '[' comma_expression ']'
| postfix_expression '(' ')'
| postfix_expression '(' argument_expression_list ')'
| postfix_expression {} '.' member_name
| postfix_expression {} ARROW member_name
| postfix_expression ICR
| postfix_expression DECR
;
member_name:
IDENTIFIER
| TYPEDEFname
;
argument_expression_list:
assignment_expression
| argument_expression_list ',' assignment_expression
;
unary_expression:
postfix_expression
| ICR unary_expression
| DECR unary_expression
| unary_operator cast_expression
| SIZEOF unary_expression
| SIZEOF '(' type_name ')'
;
unary_operator:
'&'
| '*'
| '+'
| '-'
| '~'
| '!'
;
cast_expression:
unary_expression
| '(' type_name ')' cast_expression
;
multiplicative_expression:
cast_expression
| multiplicative_expression '*' cast_expression
| multiplicative_expression '/' cast_expression
| multiplicative_expression '%' cast_expression
;
additive_expression:
multiplicative_expression
| additive_expression '+' multiplicative_expression
| additive_expression '-' multiplicative_expression
;
shift_expression:
additive_expression
| shift_expression LS additive_expression
| shift_expression RS additive_expression
;
relational_expression:
shift_expression
| relational_expression '<' shift_expression
| relational_expression '>' shift_expression
| relational_expression LE shift_expression
| relational_expression GE shift_expression
;
equality_expression:
relational_expression
| equality_expression EQ relational_expression
| equality_expression NE relational_expression
;
AND_expression:
equality_expression
| AND_expression '&' equality_expression
;
exclusive_OR_expression:
AND_expression
| exclusive_OR_expression '^' AND_expression
;
inclusive_OR_expression:
exclusive_OR_expression
| inclusive_OR_expression '|' exclusive_OR_expression
;
logical_AND_expression:
inclusive_OR_expression
| logical_AND_expression ANDAND inclusive_OR_expression
;
logical_OR_expression:
logical_AND_expression
| logical_OR_expression OROR logical_AND_expression
;
conditional_expression:
logical_OR_expression
| logical_OR_expression '?' comma_expression ':'
conditional_expression
;
assignment_expression:
conditional_expression
| unary_expression assignment_operator assignment_expression
;
assignment_operator:
'='
| MULTassign
| DIVassign
| MODassign
| PLUSassign
| MINUSassign
| LSassign
| RSassign
| ANDassign
| ERassign
| ORassign
;
comma_expression:
assignment_expression
| comma_expression ',' assignment_expression
;
constant_expression:
conditional_expression
;
/* The following was used for clarity */
comma_expression_opt:
/* Nothing */
| comma_expression
;
/******************************* DECLARATIONS *********************************/
/* The following is different from the ANSI C specified grammar.
The changes were made to disambiguate typedef's presence in
declaration_specifiers (vs. in the declarator for redefinition);
to allow struct/union/enum tag declarations without declarators,
and to better reflect the parsing of declarations (declarators
must be combined with declaration_specifiers ASAP so that they
are visible in scope).
Example of typedef use as either a declaration_specifier or a
declarator:
typedef int T;
struct S { T T;}; /* redefinition of T as member name * /
Example of legal and illegal statements detected by this grammar:
int; /* syntax error: vacuous declaration * /
struct S; /* no error: tag is defined or elaborated * /
Example of result of proper declaration binding:
int a=sizeof(a); /* note that "a" is declared with a type in
the name space BEFORE parsing the initializer * /
int b, c[sizeof(b)]; /* Note that the first declarator "b" is
declared with a type BEFORE the second declarator is
parsed * /
*/
declaration:
sue_declaration_specifier ';'
| sue_type_specifier ';'
| declaring_list ';'
| default_declaring_list ';'
;
/* Note that if a typedef were redeclared, then a declaration
specifier must be supplied */
default_declaring_list: /* Can't redeclare typedef names */
declaration_qualifier_list identifier_declarator {} initializer_opt
| type_qualifier_list identifier_declarator {} initializer_opt
| default_declaring_list ',' identifier_declarator {} initializer_opt
;

declaring_list:
declaration_specifier declarator {} initializer_opt
| type_specifier declarator {} initializer_opt
| declaring_list ',' declarator {} initializer_opt
;

declaration_specifier:
basic_declaration_specifier /* Arithmetic or void */
| sue_declaration_specifier /* struct/union/enum */
| typedef_declaration_specifier /* typedef*/
;

type_specifier:
basic_type_specifier /* Arithmetic or void */
| sue_type_specifier /* Struct/Union/Enum */
| typedef_type_specifier /* Typedef */
;

declaration_qualifier_list: /* const/volatile, AND storage class */
storage_class
| type_qualifier_list storage_class
| declaration_qualifier_list declaration_qualifier
;

type_qualifier_list:
type_qualifier
| type_qualifier_list type_qualifier
;

declaration_qualifier:
storage_class
| type_qualifier /* const or volatile */
;

type_qualifier:
CONST
| VOLATILE
;

basic_declaration_specifier: /*Storage Class+Arithmetic or void*/
declaration_qualifier_list basic_type_name
| basic_type_specifier storage_class
| basic_declaration_specifier declaration_qualifier
| basic_declaration_specifier basic_type_name
;

basic_type_specifier:
basic_type_name /* Arithmetic or void */
| type_qualifier_list basic_type_name
| basic_type_specifier type_qualifier
| basic_type_specifier basic_type_name
;

sue_declaration_specifier: /* Storage Class + struct/union/enum */
declaration_qualifier_list elaborated_type_name
| sue_type_specifier storage_class
| sue_declaration_specifier declaration_qualifier
;

sue_type_specifier:
elaborated_type_name /* struct/union/enum */
| type_qualifier_list elaborated_type_name
| sue_type_specifier type_qualifier
;

typedef_declaration_specifier: /*Storage Class + typedef types */
typedef_type_specifier storage_class
| declaration_qualifier_list TYPEDEFname
| typedef_declaration_specifier declaration_qualifier
;

typedef_type_specifier: /* typedef types */
TYPEDEFname
| type_qualifier_list TYPEDEFname
| typedef_type_specifier type_qualifier
;

storage_class:
TYPEDEF
| EXTERN
| STATIC
| AUTO
| REGISTER
;

basic_type_name:
INT
| CHAR
| SHORT
| LONG
| FLOAT
| DOUBLE
| SIGNED
| UNSIGNED
| VOID
;

elaborated_type_name:
aggregate_name
| enum_name
;

aggregate_name:
aggregate_key '{' member_declaration_list '}'
| aggregate_key identifier_or_typedef_name
'{' member_declaration_list '}'
| aggregate_key identifier_or_typedef_name
;

G. 编译原理课程设计-词法分析器设计(C语言)

#include"stdio.h"/*定义I/O库所用的某些宏和变量*/

#include"string.h"/*定义字符串库函数*/

#include"conio.h"/*提供有关屏幕窗口操作函数*/

#include"ctype.h"/*分类函数*/

charprog[80]={''},

token[8];/*存放构成单词符号的字符串*/

charch;

intsyn,/*存放单词字符的种别码*/

n,

sum,/*存放整数型单词*/

m,p;/*p是缓冲区prog的指针,m是token的指针*/

char*rwtab[6]={"begin","if","then","while","do","end"};

voidscaner(){

m=0;

sum=0;

for(n=0;n<8;n++)

token[n]='';

ch=prog[p++];

while(ch=='')

ch=prog[p++];

if(isalpha(ch))/*ch为字母字符*/{

while(isalpha(ch)||isdigit(ch))/*ch为字母字符或者数字字符*/{

token[m++]=ch;

ch=prog[p++];}

token[m++]='';

ch=prog[p--];

syn=10;

for(n=0;n<6;n++)

if(strcmp(token,rwtab[n])==0)/*字符串的比较*/{

syn=n+1;

break;}}

else

if(isdigit(ch))/*ch是数字字符*/{

while(isdigit(ch))/*ch是数字字符*/{

sum=sum*10+ch-'0';

ch=prog[p++];}

ch=prog[p--];

syn=11;}

else

switch(ch){

case'<':m=0;token[m++]=ch;ch=prog[p++];

if(ch=='>'){

syn=21;

token[m++]=ch;}

elseif(ch=='='){

syn=22;

token[m++]=ch;}

else{

syn=20;

ch=prog[p--];}

break;

case'>':m=0;token[m++]=ch;ch=prog[p++];

if(ch=='='){

syn=24;

token[m++]=ch;}

else{

syn=23;

ch=prog[p--];}

break;

case':':m=0;token[m++]=ch;ch=prog[p++];

if(ch=='='){

syn=18;

token[m++]=ch;}

else{

syn=17;

ch=prog[p--];}

break;

case'+':syn=13;token[0]=ch;break;

case'-':syn=14;token[0]=ch;break;

case'*':syn=15;token[0]=ch;break;

case'/':syn=16;token[0]=ch;break;

case'=':syn=25;token[0]=ch;break;

case';':syn=26;token[0]=ch;break;

case'(':syn=27;token[0]=ch;break;

case')':syn=28;token[0]=ch;break;

case'#':syn=0;token[0]=ch;break;

default:syn=-1;}}

main()

{

printf(" Thesignificanceofthefigures: "

"1.figures1to6saidKeyword "

"2. "

"3.figures13to28saidOperators ");

p=0;

printf(" pleaseinputstring: ");

do{

ch=getchar();

prog[p++]=ch;

}while(ch!='#');

p=0;

do{

scaner();

switch(syn){

case11:printf("(%d,%d) ",syn,sum);break;

case-1:printf(" ERROR; ");break;

default:printf("(%d,%s) ",syn,token);

}

}while(syn!=0);

getch();

}

程序测试结果

对源程序beginx:=9:ifx>9thenx:=2*x+1/3;end#的源文件,经过词法分析后输出如下图5-1所示:

具体的你在修改修改吧

H. 编译原理 课程设计

好大的题,要用到bison【如何使用,请下载bison源代码分析--gcc源代码分析语法分析部分的电子版】和flex工具吧。

I. 期末的编译课程设计啊。。。不知道大侠们能不能帮我一下,自己不会写……用C语言就行,pl0文法我给出来

参考答案: 不要试图控制别人,不要要求别人理解你。

J. 一个编译原理的课程设计,急急急

回答:alkaid_pku
学长
4月14日 06:31 1. 预处理
2. 编译
3. 汇编
4. 查找库函数
5. 连接

阅读全文

与编译课程设计相关的资料

热点内容
android图片变灰 浏览:268
linuxvi下一个 浏览:973
安卓手机的应用锁怎么解 浏览:735
linux增加路径 浏览:849
sql身份证号最后四位加密 浏览:533
xp系统表格加密 浏览:856
光遇安卓军大衣什么时候上线 浏览:840
android应用商店图标 浏览:341
java计算圆的面积 浏览:643
应用编译优化recovery 浏览:577
域控命令n 浏览:258
php导出文件 浏览:13
谷歌地图网页版无法连接服务器地址 浏览:298
菜鸟工具在线编译python 浏览:858
栅格化命令有何作用 浏览:823
为什么压缩文件不能解压 浏览:311
足球app哪个软件好 浏览:96
产品经理逼疯程序员的一天 浏览:17
修改svn服务器ip地址 浏览:584
下列关于编译说法正确的是 浏览:246