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

正文內(nèi)容

lexyacctutorial-閱讀頁(yè)

2024-11-07 00:55本頁(yè)面
  

【正文】 return 0。+39。 term : term 39。 factor | factor。(39。)39。 PLLab, NTHU,Cs2403 Programming Languages 42 Rules Section ? Normally written like this ? Example: expr : expr 39。 term | term 。*39。 factor : 39。 expr 39。 | ID | NUM 。+39。 } | term { $$ = $1。 term : term 39。 factor { $$ = $1 * $3。 } 。(39。)39。 } | ID | NUM 。+39。 } | term { $$ = $1。 term : term 39。 factor { $$ = $1 * $3。 } 。(39。)39。 } | ID | NUM 。+39。 } | term { $$ = $1。 term : term 39。 factor { $$ = $1 * $3。 } 。(39。)39。 } | ID | NUM 。+39。 } | term { $$ = $1。 term : term 39。 factor { $$ = $1 * $3。 } 。(39。)39。 } | ID | NUM 。 PLLab, NTHU,Cs2403 Programming Languages 47 Communication between LEX and YACC Y A C Cy y p a r s e ( )I n p u t p r o g r a m s12 + 26L E Xy y le x ( )call yylex() [09]+ next token is NUM NUM ?+? NUM LEX and YACC需要一套方法確認(rèn) token的身份 PLLab, NTHU,Cs2403 Programming Languages 48 Communication between LEX and YACC yacc d Will produce: ? Use enumeration ( 列舉 ) / define ? 由一方產(chǎn)生,另一方 include ? YACC 產(chǎn)生 ? LEX include PLLab, NTHU,Cs2403 Programming Languages 49 Communication between LEX and YACC %{ include include %} id [_azAZ][_azAZ09]* %% int { return INT。 } float { return FLOAT。} %{ include include %} %token CHAR, FLOAT, ID, INT %% yacc d Produced : define CHAR 258 define FLOAT 259 define ID 260 define INT 261 PLLab, NTHU,Cs2403 Programming Languages 50 YACC ? Rules may be recursive ? Rules may be ambiguous* ? Uses bottom up Shift/Reduce parsing – Get a token – Push onto stack – Can it reduced (How do we know?) ? If yes: Reduce using a rule ? If no: Get another token ? Yacc cannot look ahead more than one token Phrase cart_animal AND CART | work_animal AND PLOW … PLLab, NTHU,Cs2403 Programming Languages 51 Yacc Example ? Taken from Lex amp。+39。39。*39。/39。(39。)39。39。\n39。\n39。 statement: NAME 39。 expression { $1value = $3。 } 。+39。 } | expression 39。 term { $$ = $1 $3。 Parser (cont’d) PLLab, NTHU,Cs2403 Programming Languages 54 term: term 39。 factor { $$ = $1 * $3。/39。 else $$ = $1 / $3。 factor: 39。 expression 39。 { $$ = $2。39。 } | NUMBER { $$ = $1。 } 。 return NUMBER。 /* ignore white space */ Scanner PLLab, NTHU,Cs2403 Programming Languages 56 [AZaz][AZaz09]* { /* return symbol pointer */ = symlook(yytext)。 } $ { return 0。 %% Scanner (cont’d) PLLab, NTHU,Cs2403 Programming Languages 57 YACC Command ? Yacc (ATamp。 39。 * 39。 39。 ( 39。 ) 39。(1) 1 – 2 3 (2) 1 – 2 * 3 PLLab, NTHU,Cs2403 Programming Languages 59 Precedence / Association %right ?=? %left 39。 39。 NE LE GE %left 39。 39。*39。/39。 } | expr ?? expr { $$ = $1 $3。 } | expr ?/? expr { if($3==0) yyerror(“divide 0”)。 } | ?? expr %prec UMINUS {$$ = $2。+39。39。*39。/39。 Specify the grammar39。 Declare the collection of data types that semantic values may have `%token39。 Declare the type of semantic values for a nonterminal symbol PLLab, NTHU,Cs2403 Programming Languages 63 YACC Declaration Summary `%right39。 Declare a terminal symbol (token type name) that is leftassociative `%nonassoc39。 yacc, 2nd Edition – by John , Tony Mason
點(diǎn)擊復(fù)制文檔內(nèi)容
教學(xué)課件相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1