Skip to main content

Syntax Trees

Syntax trees are abstract or compact representation of parse trees.

They are also called as Abstract Syntax Trees.

Example-



Problem-01:

Considering the following grammar-

E → E + T | T
T → T x F | F
F → ( E ) | id
Generate the following for the string id + id x id
  1. Parse tree
  2. Syntax tree
  3. Directed Acyclic Graph (DAG)

Solution-

Parse Tree-


 





Comments

Popular posts from this blog

Code Optimization | Code Optimization Techniques

Code Optimization- Code Optimization is an approach to enhance the performance of the code. The process of code optimization involves- Eliminating the unwanted code lines Rearranging the statements of the code Advantages- The optimized code has the following advantages- Optimized code has faster execution speed. Optimized code utilizes the memory efficiently. Optimized code gives better performance. Code Optimization Techniques- Important code optimization techniques are- Compile Time Evaluation Common sub-expression elimination Dead Code Elimination Code Movement Strength Reduction 1. Compile Time Evaluation- Two techniques that falls under compile time evaluation are- A) Constant Folding- In this technique, As the name suggests, it involves folding the constants. The expressions that contain the operands having constant values at compile time are evaluated. Those express