Compiler theory - a bottom-up analysis

Bottom-up analysis

1. moved into - Statute analysis (bottom-up process in general, defects)

Ready to work:

A symbol stack, a symbol string to be analyzed # xxxxx #

Highlights:

The initial state

Only the leftmost symbol # is moved into the stack

after that

The stack each case two symbols selected from an operation between two:

  1. Moved into
  2. Statute

If the current symbol is not formed stack a new handle for the current sentence, a character string of symbols into the shift (from left to right)

If the current symbol stack to form a new handle for the current sentence, the statute - nonterminal pop the stack and the resulting handle

This process is repeated

End

The final final stack symbol # and only identification symbol, the analysis is successful, otherwise fail

note

  1. Handle certain top of the stack. If the top of the stack, the handle should had been before the statute fishes
  2. The + symbol string stack unprocessed input symbol sequence current sentence =

  3. The above-described method does not give an effective recognition algorithm handle, instead

    Handle according to the identification is to look at the stack if the symbol string is formed in the right portion of the rule ,

    However, this method is not necessarily correct. Because you can not think: xuy terms of the sentence, if U∷ = u, that is,
    U => u u to conclude that a simple phrase, u is the handle, but to satisfy
    Z = *> xUy.

    [Essence reasons for this is that, just to give a static sentence and grammar, in the strict sense of the phrase can not be determined, see https://www.cnblogs.com/Ivan-Luo/p/11694447.html. The phrase is defined, or that there is a rule A :: = b, a sentence in exactly b, but not guaranteed after this Statute to b with A remains the grammar of the sentence. ]

    Operator priority analysis

Suitable for context-free grammar

Guess you like

Origin www.cnblogs.com/Ivan-Luo/p/11696085.html