HyperAI

Parse Tree

Parse TreeIt is a form of expression of the results of grammatical analysis, usually representing the grammatical structure of the language in a tree form.

Parse trees are usually generated according to two opposite rules, dependency grammar and phrase structure grammar, which are not used for abstract syntax trees, which are a condensation of the information contained in the analysis tree.

Parse Tree vs Abstract Syntax Tree

Abstract Syntax Tree is an abstract representation of grammatical structure. It presents the structure in the form of a tree, that is, each node on the tree is a structure in the grammar. The "abstract" part of it is that it does not represent every detail of the real grammar.

A parse tree typically represents the source text in a fully parsed form, which generally conforms to a context-free grammar that defines the source language, including information such as parentheses, whitespace, and comments, but sample syntax trees typically abstract from this information.

Simply put, AST only contains the semantics of the code, but the parse tree contains information about how to write the code. A specific syntax tree matches the syntax described by the grammar rules, and AST is a simple representation of the essential information in the "parse tree".

Related words: syntax tree