|
In computer science, an abstract syntax tree (AST) is a finite, labeled, directed tree, where the internal nodes are labeled by operators, and the leaf nodes represent the operands of the node operators. Thus, the leaves have nullary operators, i.e., variables or constants. In computing, it is used in a parser as an intermediate between a parse tree and a data structure, the latter which is often used as a compiler or interpreter's internal representation of a computer program while it is being SxasdxSZXzXZXQASASDAdsddsadzXcoptimized and from which code generation is performed. The range of all possible such structures is described by the abstract syntax. An AST differs from a parse tree by omitting nodes and edges for syntax rules that do not affect the semantics of the program. The classic example of such an omission is grouping parentheses, since in an AST the grouping of operands is explicit in the tree structure. Computer science, or computing science, is the study of the theoretical foundations of information and computation and their implementation and application in computer systems. ...
In mathematics, a set is called finite if there is a bijection between the set and some set of the form {1, 2, ..., n} where is a natural number. ...
A labeled tree with 6 vertices and 5 edges In graph theory, a tree is a graph in which any two vertices are connected by exactly one path. ...
A labeled tree with 6 vertices and 5 edges In graph theory, a tree is a graph in which any two vertices are connected by exactly one path. ...
In computer science, an internal node or inner node is any node of a tree data structure that is not a leaf node. ...
In computer science, a leaf node is a node of a tree data structure that has zero child nodes. ...
A parser is a computer program or a component of a program that analyses the grammatical structure of an input, with respect to a given formal grammar, a process known as parsing. ...
A parse tree is a tree that represents the syntactic structure of a string according to some formal grammar. ...
A binary tree, a simple type of branching linked data structure. ...
A compiler is a computer program that translates a computer program written in one computer language (called the source language) into an equivalent program written in another computer language (called the output or the target language). ...
An interpreter is a computer program that executes other programs. ...
In computing, an intermediate representation is a data structure that is constructed from input data to a program, and from which part or all of the output data of the program is constructed in turn. ...
The terms computer program, software program, applications program, system software, or just program are used to refer to either an executable program by both lay people and computer programmers or the collection of source code from which an executable program is created (eg, compiled). ...
Compiler optimization is the process of tuning the output of a compiler to minimise some attribute (or maximise the efficiency) of an executable program. ...
Abstract syntax is a representation of data (typically either a message passing over a communications link or a computer program being compiled) which is independent of machine-oriented structures and encodings and also of the physical representation of the data (called concrete syntax in the case of compilation or transfer...
Creating an AST in a parser for a language described by a context free grammar, as nearly all programming languages are, is straightforward. Most rules in the grammar create a new node with the nodes edges being the symbols in the rule. Rules that do not contribute to the AST, such as grouping rules, merely pass through the node for one of their symbols. Alternatively, a parser can create a full parse tree, and a post-pass over the parse tree can convert it to an AST by removing the nodes and edges not used in the abstract syntax. A parser is a computer program or a component of a program that analyses the grammatical structure of an input, with respect to a given formal grammar, a process known as parsing. ...
In linguistics and computer science, a context-free grammar (CFG) is a formal grammar in which every production rule is of the form V → w where V is a non-terminal symbol and w is a string consisting of terminals and/or non-terminals. ...
See also
A tree used for definition of the semantics of a programming language. ...
In computer science, an abstract semantic graph (ASG) is a data structure used in representing or deriving the semantics of an expression in a formal language (for example, a programming language). ...
In computer science, a symbol table is a data structure used by a language translator such as a compiler or interpreter, where each symbol in a programs source code is associated with information such as location, type and scope level. ...
Document Object Model (DOM) is a description of how an HTML or XML document is represented in a tree structure. ...
Tree Description Language (TreeDL) is a computer language for description of strictly-typed tree data structures and operations on them. ...
References - This article was originally based on material from the Free On-line Dictionary of Computing, which is licensed under the GFDL.
The Free On-line Dictionary of Computing (FOLDOC) is an on-line, searchable encyclopedic dictionary of computing subjects. ...
GNU logo (similar in appearance to a gnu) The GNU Free Documentation License (GNU FDL or simply GFDL) is a copyleft license for free content, designed by the Free Software Foundation (FSF) for the GNU project. ...
External links - Citations from CiteSeer
- An Eclipse plugin to visualize a Java AST
|