好文档就是一把金锄头!
欢迎来到金锄头文库![会员中心]
电子文档交易市场
安卓APP | ios版本
电子文档交易市场
安卓APP | ios版本

编译原理编译原理编译原理 (35).ppt

5页
  • 卖家[上传人]:奉***
  • 文档编号:358708093
  • 上传时间:2023-08-27
  • 文档格式:PPT
  • 文档大小:325.50KB
  • / 5 举报 版权申诉 马上下载
  • 文本预览
  • 下载提示
  • 常见问题
    • CompilerS1Top-Down ParsingoExample:Grammar:S (S)S|String:()accept$6S$S5Match )$S)4S )$S)S3Match()$S)S(2S (S)S()$S1ActionInput Parsing stackCompilerS2Which Rule to Use?oWhen a nonterminal A is at the top of the parsing stack,a decision must be made based on the current input token(the lookahead).oChoices are expressed by LL(1)parsing table.nThis is a two dimensional array MN,T indexed by nonterminals N and terminals T($is added to terminals).S S S (S)SS$)(MN,TCompilerS3Rules1.If A is production choice,and there is a derivation =*a,where a is a token,then add A to the table entry MA,a.Given a token a in the input,we select a rule A if can produce an a for matching.2.If A is production choice,and there is a derivations =*and S$=*A a,where S is the start symbol and a is a token(or$),then add A to the table entry MA,a.If A derives an empty string,and if a is a token that can come after A,then we want to select A to make A disappear.CompilerS4ExampleoS (S)S|oThere is one nonterminal S,three tokens(,)and$,and two production choices.oEvery string derivable from S must be either empty or begin with(.oS (S)S is added to MS,(oS is added to MS,)and MS,$S S S (S)SS$)(MN,T1.A ,=*a 2.A ,=*,S$=*A a CompilerS5ExampleoExample:Grammar:S (S)S|String:()accept$6S$S5Match )$S)4S )$S)S3Match()$S)S(2S(S)S()$S1ActionInput Parsing stackMN,T()$SS (S)SS S 。

      点击阅读更多内容
      关于金锄头网 - 版权申诉 - 免责声明 - 诚邀英才 - 联系我们
      手机版 | 川公网安备 51140202000112号 | 经营许可证(蜀ICP备13022795号)
      ©2008-2016 by Sichuan Goldhoe Inc. All Rights Reserved.