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

正文內(nèi)容

chapter10lexicalanalyzer(lex)-資料下載頁

2024-10-24 18:01本頁面

【導讀】Speaker:Lung-ShengChien. ReferenceURL:. Onlinemanual:. OutLine. Whatislex. Regularexpression. Finitestatemachine. Contentofflex. Application. foreachlineinafile. iflinecontains“//”notinastring,then. iflinecontains“/*”notinastring,then. endfor. anotherfile.Pseudo-code. Whatislex. expressions(正規(guī)表示法).expressions.From. definition. TokenPatternLexeme(詞彙). integer(0-9)+234. identifier[a-zA-Z]?[a-zA-Z0-9]*x1. meaning. Lexicalanalyzer. Syntaxanalyzer(文法分析). Semanticanalyzer(語意分析). Codeoptimizer. Codegenerator. Sourcecode. machinecode. PhasesofaCompiler. Lexisacrucialtool. toextracttoken. token. symboltable. asknextcharacter. character. asknexttoken. token. asknextcharacter. character. Fileprocessorof. Linearprogramming. asknexttoken. token. g++. inputtoken. -don?tuselibrary. -don?-mixCwithC++code. flexinRedHat9. Linkwithlibrary. Library. 按Ctrl+D. Thisisabook\n. byebye\n. 按enter. definitionsection. %%. rulesection. %%. usercode. grammarofinputfile. Usercode. sourcefile. patternaction. \n{++num_lines;++num_chars;}. patternaction. .{++num_chars;}. wildcardcharacter,representany. defaultmain. Q1:canwepi

  

【正文】 les qualified with the start condition will be active. %s example %% examplefoo do_something()。 bar something_else()。 %x example %% examplefoo do_something()。 INITIAL,examplebar something_else()。 pattern foo is activated in starting condition, example pattern bar does not specify starting conditions, then all starting conditions declared as inclusive (s) will execute pattern bar %s example %% examplefoo do_something()。 INITIAL,examplebar something_else()。 The following three lex input are equivalent Inclusive . exclusive How to recognize ment in C, /* … */ CMNT is an exclusive starting condition If read /*, change to CMNT If read */, back to INTIAL Can you explain output? Exercise ? C++ support another kind of ment, starting by //, write a regular expression to recognize this kind of ment and build it into flex input file. Write a C program with Cment and C++ment to test scanner generated by flex. ? Depict state transition diagram for Cment and C++ ment, write code to implement this state transition diagram and measure program size. Do you think flex helps you identify Cment very well? ? Can you have other method to identify Cment by using flex? Hint: use flex to identify /*, then write code to find */ by yyinput() or input() OutLine ? What is lex ? Regular expression ? Finite state machine ? Content of flex ? Application scan configuration file of linear programming Cprogram analyzer m ins u b je c t to , 0Tz c xA x b x??? Application 1: configuration file of Linear Programming objective /objective constraint /constraint x1 x2 x4 x5 integer real number + * token C++ment = = = Objective: read configuration file, extract coefficient of vector c, b and matrix A, then output c, b, A You need to add rule for C++ment substitution rule how many lines are processed definition of code of token driver: show all tokens [1] 1. Space character is removed automatically 2. It is not necessary to keep space character between two tokens since flex would identify them very well driver: show all tokens [2] Exercise ? Complete input file for flex (add rule to deal with C++ment) and test the scanner for different cases. ? Depict state transition diagram to collect information from configuration file and construct vector c, b and matrix A S0 S1 S2 objective constraint Applicatoin2: C program analyzer token Lexeme identifier x1 integer 1234 real , Arithmetic operator +, , *, /, % Increment operator ++, Arithmetic assignment operator +=, =, *=, /=, %=, = Relational operator ==, !=, , , =, = Boolean logical operator amp。, |, ^ Logical operator amp。amp。, || marker ( ) , [ ] , { } , , , 。 , . , “ “ , ? ? Conditional operator ? : Escape sequence \n, \t, \r, \\, \” ment //, /* … */ Exercise ? Write a scanner for Cprogram, we have shown how to write regular expression for identifier, integer, real and ment, you need to add regular expression for arithmetic operator logical operator relational operator marker string and character distinguish keyword (reserved word) from identifier note that you need to define integervalue token for above operator in
點擊復制文檔內(nèi)容
教學課件相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1