Javatpoint Logo
Javatpoint Logo

Parse tree

  • Parse tree is the graphical representation of symbol. The symbol can be terminal or non-terminal.
  • In parsing, the string is derived using the start symbol. The root of the parse tree is that start symbol.
  • It is the graphical representation of symbol that can be terminals or non-terminals.
  • Parse tree follows the precedence of operators. The deepest sub-tree traversed first. So, the operator in the parent node has less precedence over the operator in the sub-tree.

The parse tree follows these points:

  • All leaf nodes have to be terminals.
  • All interior nodes have to be non-terminals.
  • In-order traversal gives original input string.

Example:

Production rules:

Input:

a * b + c

Step 1:

Parse tree1

Step 2:

Parse tree2

Step 3:

Parse tree3

Step 4:

Parse tree4

Step 5:

Parse tree5
Next TopicAmbiguity





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA