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

正文內(nèi)容

lexyacctutorial(參考版)

2024-10-22 00:55本頁(yè)面
  

【正文】 Doug Brown – O?Reilly – ISBN: 1565920007 ? Mastering Regular Expressions – by Jeffrey . Friedl – O?Reilly – ISBN: 1565922573 。 Declare a terminal symbol (token type name) that is nonassociative (using it in a way that would be associative is a syntax error, ex: x op. y op. z is syntax error) PLLab, NTHU,Cs2403 Programming Languages 64 Reference Books ? lex amp。 Declare a terminal symbol (token type name) that is rightassociative `%left39。 Declare a terminal symbol (token type name) with no precedence or associativity specified `%type39。s start symbol `%union39。 %noassoc UMINUS PLLab, NTHU,Cs2403 Programming Languages 61 Shift/Reduce Conflicts ? shift/reduce conflict – occurs when a grammar is written in such a way that a decision between shifting and reducing can not be made. – ex: IFELSE ambigious. ? To resolve this conflict, yacc will choose to shift. PLLab, NTHU,Cs2403 Programming Languages 62 YACC Declaration Summary `%start39。 39。 %left 39。 39。 } %left 39。 else $$ = $1 / $3。 } | expr ?*? expr { $$ = $1 * $3。 highest precedence PLLab, NTHU,Cs2403 Programming Languages 60 Precedence / Association expr : expr ?+? expr { $$ = $1 + $3。 39。? %left 39。+39。39。39。 . . . 。 e x p r 39。 e x p r | 39。 e x p r | e x p r 39。 e x p r | e x p r 39。T) – yacc –d ? Bison (GNU) – bison –d –y 產(chǎn)生 , 與 yacc相同 不然會(huì)產(chǎn)生 PLLab, NTHU,Cs2403 Programming Languages 58 Precedence / Association 1. 123 = (12)3? or 1(23)? Define ?? operator is leftassociation. 2. 12*3 = 1(2*3) Define “*” operator is precedent to “” operator e x p r : e x p r 39。 /* end of input */ } \n |”=“|”+”|””|”*”|”/” return yytext[0]。 return NAME。 } [ \t] 。 %% Parser (cont’d) PLLab, NTHU,Cs2403 Programming Languages 55 %{ include include include %} %% ([09]+|([09]*\.[09]+)([eE][+]?[09]+)?) { = atof(yytext)。 } | NAME { $$ = $1value。 factor { $$ = $2。 } | 39。)39。(39。 } | factor 。 factor { if ($3 == ) yyerror(divide by zero)。 } | term 39。*39。 } | term 。39。 term { $$ = $1 + $3。 expression: expression 39。 } | expression { printf(= %g\n, $1)。=39。 。 | statement_list statement 39。 factor | NUMBER | NAME PLLab, NTHU,Cs2403 Programming Languages 53 statement_list: statement 39。 | 39。 expression 39。 factor | factor factor ::= 39。 factor | term 39。 term | term term ::= term 39。 term | expression 39。 Yacc ? Simple calculator a = 4 + 6 a a=10 b = 7 c = a + b c c = 17 $ PLLab, NTHU,Cs2403 Programming Languages 52 Grammar expression ::= expression 39。 } {id} { return ID。 } char { return CHAR。 $3 Default: $$ = $1。 { $$ = $2。 expr 39。 factor : 39。 } | factor { $$ = $1。*39。 } 。 term { $$ = $1 + $3。 $2 PLLab, NTHU,Cs2403 Programming Languages 46 The Position of Rules expr : expr 39。 { $$ = $2。 expr 39。 factor : 39。 } | factor { $$ = $1。*39。 } 。 term { $$ = $1 + $3。 $1 PLLab, NTHU,Cs2403 Programming Languages 45 The Position of Rules expr : expr 39。 { $$ = $2。 expr 39。 factor : 39。 } | factor { $$ = $1。*39。 } 。 term { $$ = $1 + $3。 PLLab, NTHU,Cs2403 Programming Languages 44 The Position of Rules expr : expr 39。 { $$ = $2。 expr 39。 factor :
點(diǎn)擊復(fù)制文檔內(nèi)容
教學(xué)課件相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1