Analysis tree of context-free grammar (Context-Free Grammar, CFG)-compilation principle

Context-Free Grammar (Context-Free Grammar, CFG) analysis tree

Analysis tree

Insert picture description here

  • The symbol of the root node is the grammar start symbol S
  • Each internal node is an application of a certain production A→β. The label of the node is the left part of the production, and the child nodes form the right part of the production from left to right.
  • The label of the leaf node can be either a terminal symbol or a non-terminal symbol.The symbol obtained by arranging the leaf nodes of a tree from left to right is called the output or edge of the tree .

Sentence pattern

  • Phrase: Given a sentence pattern, the edge of each subtree of the analysis tree is called a phrase of the sentence pattern
  • If the height of the subtree is 2 (there are only two generations of nodes for father and son), then the edge of the subtree is called the direct phrase of the sentence pattern

The sentence of direct phrase

Insert picture description here

Guess you like

Origin blog.csdn.net/qq_44823898/article/details/108051401