Ⅰ 編譯原理課程設計
%{
/* 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
;
Ⅱ 編譯原理這門課程第四章語法制導的翻譯的知識點有哪些
編譯原理這門課第四章語法制導的翻譯的知識點包含章節導引,第一節語法制導的翻譯,第二節S屬性定義的自下而上計算,第三節L屬性定義的自上而下計算,第四節L屬性的自下而上計算,課後練習,。
Ⅲ 第二版計算機科學導論的答案
計算機科學與技術專業 相對來說應該是計算機方面專業中最熱門的了
清華大學有全國第一的計算機科學與技術專業
大多學校的 計算機科學與技術專業都是差不多的 當然也有適當的區別
在這里摘錄華中科技大的該專業培養方案(僅供參考)
計算機科學與技術專業本科培養計劃
一、培養目標
培養德、智、體全面發展,具有系統、扎實的信息學科和計算機學科的理論基礎,在信息的獲取、傳遞、處理及應用等方面,具有較寬廣的專業知識和實踐動手能力的研究型、復合型人才。畢業生具有良好的人文素質、創新精神和較強的英語能力,能在信息技術產業,科研部門,高等院校及其相關領域從事信息科學與技術的研究、設計、開發及管理等方面的工作,並可繼續攻讀計算機科學與技術、相關學科與交叉學科的碩士學位。
二、基本規格要求
1、 具有較扎實的信息學科所需的數理基礎;
2、 掌握信息學科、計算機科學與技術的基本理論和方法;
3、 具有研究計算機科學與技術領域理論問題和解決實際問題的能力;
4、 了解信息學科、計算機學科的發展動態;
5、 具有較強的英語語言能力;
6、 掌握文獻檢索、資料查詢的方法和撰寫科學論文的能力;
7、 具有較好的人文社科知識和人文素質,以及較強的協調、組織能力;
8、 具有較強的創新精神。
三、培養特色
以數理為基礎,以信息學科為平台,以計算機科學與技術為方向,以培養創新能力為重點,面向系統,兼顧應用,軟硬結合,計算機科學與計算機工程並重。培養在計算機系統結構與計算機網路系統、軟體系統、計算機工具與應用支撐環境的研究、分析、設計、開發和工程組織等方面具有綜合能力的復合型人才。
四、主幹學科
計算機科學與技術
五、學制與學位
修業年限:四年
授予學位:工學學士
六、學時與學分
完成學業最低課內學分(含課程體系與集中性實踐教學環節)要求:200
七、主要課程
離散數學 數據結構 匯編語言程序設計 數值分析 操作系統原理 微機介面技術 資料庫系統原理 計算機組成原理 計算機通信與網路 編譯原理 計算機系統結構 軟體工程
八、主要實踐教學環節(含專業實驗)
C語言課程設計 數字邏輯課程設計 數據結構課程設計 匯編語言課程設計 操作系統課程設計 計算機組成原理課程設計 微機介面技術課程設計 資料庫系統課程設計 編譯原理課程設計
參考資料:華中科技大計算機科學與技術專業本科培養計劃
Ⅳ 匯編原理的題目:令A、B和C是任意正規式,證明以下關系成立: A=b|aA當且僅當A=a*b
最近學校開了網課,在學編譯原理,其中作業就有這道題,貼出我的答案,不一定是正確的。
A = b|aA
=> A = b
=> A = aA
A = aA => A = a(aA) = a(a(aA)) = ...... = aab = aaab = ... = a*b
所以A = a*b
基於以下規則:
正規式轉換規則
參考圖片來源於博客:網頁鏈接
Ⅳ asp課程項目設計的基本原理和採用的主要方法與技術是什麼
機械原理課程設計,如何設計送料系統
-
1個回答
單元機組運行原理課程設計
-
1個回答
機械原理課程設計之平壓印刷機ppt
18
-
1個回答
機械原理課程設計插刀行程機構分析
-
2個回答
編譯原理課程設計if
-
1個回答
數字日歷倒計時盤設計原理
-
1個回答
機械原理課程設計方案
-
2個回答
c#可以做哪些項目
Ⅵ 編譯原理課程設計-詞法分析器設計(C語言)
#include"stdio.h"/*定義I/O庫所用的某些宏和變數*/
#include"string.h"/*定義字元串庫函數*/
#include"conio.h"/*提供有關屏幕窗口操作函數*/
#include"ctype.h"/*分類函數*/
charprog[80]={'