1 / 10

chapter 6:bottom-up analysis

chapter 6:bottom-up analysis. 6.1 introduction 1.basic idea:start from the input-string,reduce upward step by step by using grammar,try to get to the start symbol. if the final root node is start symbol,the string is therefore a legal sentence,or else not. 2.the problem encountered

gaffney
Download Presentation

chapter 6:bottom-up analysis

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. chapter 6:bottom-up analysis 6.1 introduction 1.basic idea:start from the input-string,reduce upward step by step by using grammar,try to get to the start symbol. if the final root node is start symbol,the string is therefore a legal sentence,or else not.

  2. 2.the problem encountered at each step of reduction,two basic problems were faced: first: how to determine an simple phrase to reduce? second: what non-terminator will be reduced?

  3. 3.solution because the analysis process is to scan string from left to right,so the problem is to seek handle, then the problem of finding to-be-reduced part in a string is to find handle. but how to determine a handle?

  4. 4.algorithm to answer the above mentioned question, we introduce precedence relations definition to a grammar.that is =,< and > for a given grammar G,each to symbols R,S they may appear adjacently in a sentence-pattern,they have one of the following precedence relations:

  5. + 1)R=S iff(if and only if) there exist the rule form like : U→... RS ... 2)R<S iff U→... RV ... and V →S... 3)R>S iff U→... VW .. and V →...R and W →S... + *

  6. According to this ,we design the algorithm,its kernel is shift-reduce strategy. let me illustrate it with an example. ex6.2 If G[S] S→bMb M→(L | a L→Ma) easy to obtain the simple precedence array:

  7. the simple precedence array of G[S] is below:

  8. analyze a so-called sentence to see if it is legal let w=b(aa)b

  9. 5.now let us summarize the contents mentioned above,and give a brief description of the algorithm: first introduce a stack to hold symbols; according to the scan-order to push symbols into (shift in) the stack; see if there is a handle in the stack; the process involves four kinds of activities: they are:shift,reduce,accept ,error report you should take attention to handle recognizing method and the use of array.

  10. last for today,bye

More Related