一.Grammar for Micro with Action Symbols:

 <program>         -> #startbegin <statement list> end
 <statement list>  -> <statement> {<statement>}
 <statement>       -> <ident> := <expression> #assign;
 <statement>       -> read(<id list>);
 <statement>       -> write(<expr list>);
 <id list>         -> <ident> #read_id{, <ident> #read_id}
 <expr list>       -> <expression> #write_expr{, <expression> #write_expr}
 <expression>      -> <primary> {<add op> <primary> #gen_infix}
 <primary>         -> (<expression>)
 <primary>         -> <ident>
 <primary>         -> INTLITERAL#process_literal
 <add op>          -> PLUSOP#process_op
 <add op>          -> MINUSOP#process_op
 <ident>           -> ID#process_id
 <system goal>     -> <program> SACNEOF #finish

說明:
 1.Parsing Function為藍色,例:<statement list>
 2.Semantic Function為綠色斜體,例:#assign
 3.所需Match的ID為紅色粗體,例:INTLITERAL



二.Trace Parser:

一開始,不太了解作業的需求。請教老師之後,才知要把Semantic Function插進Parsing Function中。
因此,以下的Parsing Function經過改寫,包含進了Semantic Function.
讓我們以HTML Link的方式,Trace整個Parser.

為了方便閱讀,有以下幾點設計:
1.Parsing Function為一般體,例:statement_list() 並在上方Title顯示「Parsing Function--...」
2.Semantic Function為斜體,例:assign() 並在上方Title顯示「Semantic Function--...」
3.所需Match的ID為紅色粗體,例:INTLITERAL

system_goal()開始吧!:)



2000.3.23 by BSP鄒
This Page is written by Netscape Composer for OS/2.