619 views
2 votes
2 votes
What is Abstract Syntax Tree(AST)?

Difference between AST and parse tree?At which phase of compiler such trees are created?

Who is the condensed form of whom?

1 Answer

1 votes
1 votes

AST is the condensed form of Parse Tree

 

An abstract syntax tree (AST), or just syntax tree, is a tree representation of the abstract syntactic structure of source code written in a programming language. The syntax is "abstract" in the sense that it does not represent every detail appearing in the real syntax, but rather just the structural, content-related details. 

This distinguishes abstract syntax trees from concrete syntax trees, traditionally designated parse trees, which are typically built by a parser during the source code translation and compiling process.

Abstract syntax trees are data structures widely used in compilers to represent the structure of program code.

An AST is usually the result of the syntax analysis phase of a compiler. It often serves as an intermediate representation of the program through several stages that the compiler requires, and has a strong impact on the final output of the compiler.

 

The AST is used intensively during semantic analysis, where the compiler checks for correct usage of the elements of the program and the language. The compiler also generates symbol tables based on the AST during semantic analysis. A complete traversal of the tree allows verification of the correctness of the program.

After verifying correctness, the AST serves as the base for code generation. The AST is often used to generate an intermediate representation (IR), sometimes called an intermediate language, for the code generation.

https://en.wikipedia.org/wiki/Abstract_syntax_tree

Related questions

2 votes
2 votes
2 answers
2
s_dr_13 asked Jan 3, 2022
470 views
if a grammar is CLR(1) with no mergeable states, then it is LALR(1) ? I suppose it is “yes”, am I right?
0 votes
0 votes
1 answer
3
0 votes
0 votes
1 answer
4
Hirak asked Jun 1, 2019
2,033 views
S → aSbS /bSaS / ϵS → aABb A→ c/ ϵ B → d/ ϵWhich of the following is LL1. Explain in details.