Chat with us, powered by LiveChat
Abstract syntax tree

Abstract syntax tree

It is a labeled, finite, directed tree where the internal nodes are named by operators, and the leaf nodes represent the operands of the node operators. Thus, the leaves have nullary operators; it is also used in a parser as an intermediate between a parse tree and a data structure and is also used as a compiler or interpreter’s internal representation of a computer program while being optimized and from which code generation takes action.

The range is mentioned by abstract syntax. The difference between an abstract syntax tree against a parse tree is that even by omitting nodes and edges for syntax rules that do not affect the semantics of the program.

Creating an AST in a parser for a language programming languages is to-the-point and most rules create a new node with the nodes edges being the symbols in the rule. Those rules that do not contribute thereafter pass through the node for one of symbols. As an alternative, a parser can also create a full parse tree; a post-pass over the parse tree can be converted in an AST by the removal of the nodes and edges which are not used in the abstract syntax.

Latest posts by shane (see all)

Sharing

1 Comments

  1. Bob

    AST implementation is useful and time saving, to perform task on AST the visitor pattern should be used, the visit method is a parameter for the visitor object, the detail already defined in each AST.

Leave your comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.