Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Abstract syntax tree
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Tree representation of the abstract syntactic structure of source code}} {{For|the trees used in linguistics|parse tree}} {{no footnotes|date=February 2013}} [[File:Abstract syntax tree for Euclidean algorithm.svg|thumb|400px|An abstract syntax tree for the following code for the [[Euclidean algorithm]]:<syntaxhighlight lang="python"> while b β 0: if a > b: a := a - b else: b := b - a return a </syntaxhighlight>]] An '''abstract syntax tree''' ('''AST''') is a data structure used in [[computer science]] to represent the structure of a program or code snippet. It is a [[Tree (data structure)|tree]] representation of the [[abstract syntax|abstract syntactic]] structure of text (often [[source code]]) written in a [[formal language]]. Each node of the tree denotes a construct occurring in the text. It is sometimes called just a '''syntax tree'''. The syntax is "abstract" in the sense that it does not represent every detail appearing in the real syntax, but rather just the structural or content-related details. For instance, grouping [[Bracket#Parentheses|parentheses]] are implicit in the tree structure, so these do not have to be represented as separate nodes. Likewise, a syntactic construct like an if-condition-then statement may be denoted by means of a single node with three branches. This distinguishes abstract syntax trees from concrete syntax trees, traditionally designated [[parse tree]]s. Parse trees are typically built by a [[parser]] during the source code translation and [[compiler|compiling]] process. Once built, additional information is added to the AST by means of subsequent processing, e.g., [[Semantic analysis (compilers)|contextual analysis]]. Abstract syntax trees are also used in [[program analysis]] and [[program transformation]] systems.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)