Abstract syntax tree: Difference between revisions

Content deleted Content added
Nicsterr (talk | contribs)
mNo edit summary
Line 3:
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.
 
Creating an AST in a [[parsing|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.
 
{{comp-sci-stub}}