ROSE  0.11.145.0
Classes | Typedefs
Rosebud::Ast Namespace Reference

Description

Abstract syntax tree.

This is the tree representation of the abstract syntactic structure of the Rosebud input. Each node of the tree denotes a construct appearing in an input file.

The root of the tree is a Project node, which points to a list of File nodes. Each file points to a list of (usually one) Class nodes. A class is a type of (inherits from) Definition and points to a list of Property nodes. Each property has a data type, initial value, and points to a list of Attribute nodes. Each attribute has a list of arguments that are of each a TokenList node. A token list is simply a list of locations in the input file.

All nodes of the AST are derived from the Node type which, among other things, provides a parent pointer. The parent pointer in a node is adjusted automatically when the node is assigned as a child of another node. All nodes are reference counted and are deleted automatically when they're no longer referenced.

Since nodes are always constructed in the heap and reference counted, their normal C++ constructors are protected. Instead, use the static instance member functions to construct nodes. Every node also has a Ptr type which is a std::shared_ptr<T> for that class of node.

For examples showing how nodes and pointers to children and parents work, see the unit Rosebud AST unit tests. Here's a quick preview:

auto fileList = FileList::instance();
auto foo = File::instance("foo.h");
auto bar = File::instance("bar.h");
fileList->push_back(foo);
ASSERT_require(fileList->at(0) == foo);
ASSERT_require(foo->parent == fileList);
fileList->at(0) == bar;
ASSERT_require(foo->parent == nullptr);
ASSERT_require(bar->parent == fileList);
fileList->pop_back();
ASSERT_require(bar->parent == nullptr);

Classes

class  ArgumentList
 A node that holds a list of arguments. More...
 
class  Attribute
 An attribute adjusting the details for a definition. More...
 
class  Class
 Represents a class definition. More...
 
class  CppStack
 Information about C preprocessor conditional compilation directives. More...
 
class  Definition
 Base class for class and property definitions. More...
 
class  File
 An input file. More...
 
class  Node
 
class  Project
 Root of an AST for one or more input files. More...
 
class  Property
 Represents a class property definition. More...
 
class  TokenList
 Node that holds a sequence of consecutive tokens from an input file. More...
 

Typedefs

using NodePtr = std::shared_ptr< Node >
 Shared-ownership pointer to a Node. More...
 
using TokenListPtr = std::shared_ptr< TokenList >
 Shared-ownership pointer to a TokenList. More...
 
using ArgumentListPtr = std::shared_ptr< ArgumentList >
 Shared-ownership pointer to a ArgumentList. More...
 
using CppStackPtr = std::shared_ptr< CppStack >
 Shared-ownership pointer to a CppStack. More...
 
using AttributePtr = std::shared_ptr< Attribute >
 Shared-ownership pointer to a Attribute. More...
 
using DefinitionPtr = std::shared_ptr< Definition >
 Shared-ownership pointer to a Definition. More...
 
using PropertyPtr = std::shared_ptr< Property >
 Shared-ownership pointer to a Property. More...
 
using ClassPtr = std::shared_ptr< Class >
 Shared-ownership pointer to a Class. More...
 
using FilePtr = std::shared_ptr< File >
 Shared-ownership pointer to a File. More...
 
using ProjectPtr = std::shared_ptr< Project >
 Shared-ownership pointer to a Project. More...
 

Typedef Documentation

using Rosebud::Ast::NodePtr = typedef std::shared_ptr<Node>

Shared-ownership pointer to a Node.

Definition at line 37 of file ud/BasicTypes.h.

using Rosebud::Ast::TokenListPtr = typedef std::shared_ptr<TokenList>

Shared-ownership pointer to a TokenList.

Definition at line 39 of file ud/BasicTypes.h.

using Rosebud::Ast::ArgumentListPtr = typedef std::shared_ptr<ArgumentList>

Shared-ownership pointer to a ArgumentList.

Definition at line 41 of file ud/BasicTypes.h.

using Rosebud::Ast::CppStackPtr = typedef std::shared_ptr<CppStack>

Shared-ownership pointer to a CppStack.

Definition at line 43 of file ud/BasicTypes.h.

using Rosebud::Ast::AttributePtr = typedef std::shared_ptr<Attribute>

Shared-ownership pointer to a Attribute.

Definition at line 45 of file ud/BasicTypes.h.

using Rosebud::Ast::DefinitionPtr = typedef std::shared_ptr<Definition>

Shared-ownership pointer to a Definition.

Definition at line 47 of file ud/BasicTypes.h.

using Rosebud::Ast::PropertyPtr = typedef std::shared_ptr<Property>

Shared-ownership pointer to a Property.

Definition at line 49 of file ud/BasicTypes.h.

using Rosebud::Ast::ClassPtr = typedef std::shared_ptr<Class>

Shared-ownership pointer to a Class.

Definition at line 51 of file ud/BasicTypes.h.

using Rosebud::Ast::FilePtr = typedef std::shared_ptr<File>

Shared-ownership pointer to a File.

Definition at line 53 of file ud/BasicTypes.h.

using Rosebud::Ast::ProjectPtr = typedef std::shared_ptr<Project>

Shared-ownership pointer to a Project.

Definition at line 55 of file ud/BasicTypes.h.