CDT Programmer's Guide

Note: This is a work in progress for CDT 3.0. Changes should be expected until further notified.

# CDT DOM

What is a DOM? Well, let me tell you. The DOM, or Document Object Model, is a programmatic way to see the underlying source code in both a syntactic and semantic view using an Abstract Syntax Tree (AST) and to allow changes in the AST to be reflected back out to the source code.

## Syntactic View

The syntactic view (which we sometimes call the physical view) represents the syntactic structure of the program. This is driven mainly by the grammar that the parser follows, mapping from terminals up to the entry rule in the grammer. This view fulfills the role of a traditional Abstract Syntax Tree, and you'll see that the classes that make up this view have AST in their name.

The top node of the Syntactic View is IASTTranslationUnit. The translation unit object can be accessed from the C Model's ITranslationUnit object.

## Semantic View

The semantic view (which we sometimes call the logical view) represent semantic elements in the program. These elements are generally types, variables, and functions. The JDT calls these things bindings, so we do to. However, the more general rule is that anything that links sub-branches of the AST is a binding.

The most common way to get from the Syntactic View is to navigate from an IASTName view to the IBinding that represents the Semantic object for that given name.