freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

編程考試機(jī)器評卷系統(tǒng)—畢業(yè)設(shè)計(jì)(編輯修改稿)

2024-09-03 11:27 本頁面
 

【文章內(nèi)容簡介】 字符數(shù)有不同的規(guī)定,一般允許7個(gè)字符。同時(shí)C語言中擁有大量的保留字,在定義變量時(shí)不能與這些關(guān)鍵字重復(fù)。在本程序中也同樣建立了一個(gè)關(guān)于C語言關(guān)鍵字的對應(yīng)表詞法分析功能主要由以下兩個(gè)類來完成:l Class CTokenizer:這個(gè)類的主要作用為:從一個(gè)字符串中(這里把一個(gè)文件看作是一個(gè)字符串,MFC中CFileCstring獲取用戶調(diào)入的C語言源程序)分離出一個(gè)一個(gè)token來,配上簡單的類型再通過NextToken()獲取返回值。返回值與其宏定義如下:CODEdefine TT_EOL 39。\n39。define TT_EOF 1define TT_INTEGER 2define TT_REAL 3define TT_WORD 4define TT_STRING 39。39。define TT_CHAR 39。\39。39。l Class CScaner:這個(gè)類的作用為:獲取C語言源程序中具體具體的的token類型。Token類型的定義必須與C語言關(guān)鍵字相對應(yīng)用于詞法的檢測。C語言關(guān)鍵字如下表:autodoubleintstructbreakelselongswitchcaseenumregistertypedefcharexternreturnunionConstfloatshortunsignedContinueforsignedvoidDefaultgotosizeofvolatileDoifstaticwhile表1 C關(guān)鍵字表Token類型的定義分為以下5類與C語言相對應(yīng)。CODE:enum TokenType{程序關(guān)鍵字定義 _AUTO, _DOUBLE, _INT, _STRUCT, _BREAK, _ELSE, _LONG, _SWITCH, _CASE, _ENUM, _REGISTER, _TYPEDEF, _CHAR, _EXTERN, _RETURN, _UNION, _CONST, _FLOAT, _SHORT, _UNSIGNED, _CONTINUE, _FOR, _SIGNED, _VOID, _DEFAULT, _GOTO, _SIZEOF, _VOLATILE, _DO, _IF, _STATIC, _WHILE, _READ, _WRITE, _PRINTF, 操作關(guān)鍵字 ASSIGN, PLUS, MINUS, TIMES, DIV, MOD, BITWISE_AND, BITWISE_OR, BITWISE_NOT, LOGICAL_NOT, LT, GT,中斷關(guān)鍵字 LPARAN, RPARAN, LBRACE, RBRACE, LSQUARE, RSQUARE, COMMA, DOT, SEMI, COLON, 混合操作符 EQ/* == */, NEQ/* != */, PLUS_PLUS/* ++ */, MINUS_MINUS/* */, PLUS_ASSIGN/* += */, MINUS_ASSIGN/* = */, TIMES_ASSIGN/* *= */, DIV_ASSIGN/* /= */, NGT/* = */, NLT/* = */, LOGICAL_AND/* amp。amp。 */, LOGICAL_OR/* || */,其他 _EOF, _ID, _NUM, _STRING, _CHARACTER, _LABEL, _ERROR, _NONE}。Cscaner實(shí)現(xiàn)詞法分析的查找與反向查找是通過函數(shù)CMapCString, LPCSTR, enum TokenType, enum TokenType來實(shí)現(xiàn)的。成員變量m_KeyIndex 把C語言源程序(CString)的關(guān)鍵字和TokenType對應(yīng)。例如:當(dāng)系統(tǒng)查找到‘+’時(shí),自動(dòng)把它翻譯成Token類型PLUS。l 變量標(biāo)識(shí)符構(gòu)詞法分析原理:例如標(biāo)識(shí)strID1,根據(jù)C語言的變量命名法則,系統(tǒng)先檢查變量名的開頭部分是否由正確的字母或符號組成。(_ a b c d e f g h i j k l m n o p q r s t u v w x y zA B C D E F G H I J K L M N O P Q R S T U V W X Y Z)。然后再檢查變量的其他部分是否含有0 1 2 3 4 5 6 7 8 9。:本系統(tǒng)中語法分析的功能是由類Cparser來完成的。l Class Cparser完成的主要功能是:在詞法分析的基礎(chǔ)上,通過文法與相應(yīng)的規(guī)則起建立語法樹。具體實(shí)現(xiàn)如下:首先定義數(shù)據(jù)結(jié)構(gòu)CTreeNode,結(jié)構(gòu)CtreeNode是建立語法樹的基礎(chǔ)。CtreeNode的由以下代碼實(shí)現(xiàn)。CODE:define MAX_CHILDREN 3class CTreeNode{public: CTreeNode* child[ MAX_CHILDREN ]。 // point to child node CTreeNode* father。 // point to father node CTreeNode* sibling。 // point to sibling node int lineno。 NodeKind nodekind。 union { StmtKind stmt。 ExpKind exp。 } kind。 enum TokenType type。 CString szName。 CString szScope。 // node function scope BOOL bArray。 // is this an array declaration int iArraySize。 // array size}。l Grammar分析與函數(shù)返回:1. programdeclaration_list2. declaration_listdeclaration_list declaration | declaration3. declarationvar_declaration | fun_declaration4. var_declarationtype_specifier ID(, ...)`。` | type_specifier ID `[` NUM `]`(, ...)`。`5. type_specifier`int` | `void` | `char`, actually this step is in declaration_list()6. fun_declarationtype_specifier ID `(` params `)` pound_stmt7. paramsparam_list | `void` | empty, `void` is thought as empty8. param_listparam_list `,` param | param9. paramtype_specifier ID | type_specifier ID `[` `]`10. pound_stmt`{` loal_declarations statement_list `}` | expression_stmt11. local_declarationslocal_declarations var_declaration | var_declaration12. `read` `(` var `)` `。`13. `write` `(` expression `)` `。`14. `printf` `(` `` STRING `` `)` `。`15. expression_stmtexpression `。` | `。`16. expressionvar `=` expression | logic1_expression17. logic1_expressionlogic1_expression `||` logic2_expression | logic2_expression18. logic2_expression logic2_expression `amp。amp。` simple_expression | simple_expression19. simple_expressionadditive_expression relop additive_expression | additive_expression20. relop `=` | `` | `` | `=` | `==` | `!=`21. additive_expression additive_expression addop term | term22. addop `+` | ``23. termterm mulop logic3_expression | logic3_expression24. mulop `*` | `/` | `%`25. logic3_expression `!` logic3_expression | factor26. factor`(` expression `)` | var | call | NUM27. varID | ID `[` expression `]`28. callID `(` args `)`29. argsargs_list | empty30. args_listargs_list `,` expression | expression31. sub_poundstmtID `:` | call `。` | expression_stmt32. if_stmt`if` `(` expression `)` pound_stmt33. | `if` `(` expression `)` pound_stmt `else` pound_stmt34. while_stmt`while` `(` expression `)` pound_stmt35. for_stmt`for` `
點(diǎn)擊復(fù)制文檔內(nèi)容
教學(xué)課件相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號-1