ROSE 0.11.145.147
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);
static Ptr instance(const std::string &name)
Allocating constructor.

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
 Base class of all AST nodes for Rosebud. More...
 
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.
 
using TokenListPtr = std::shared_ptr< TokenList >
 Shared-ownership pointer to a TokenList.
 
using ArgumentListPtr = std::shared_ptr< ArgumentList >
 Shared-ownership pointer to a ArgumentList.
 
using CppStackPtr = std::shared_ptr< CppStack >
 Shared-ownership pointer to a CppStack.
 
using AttributePtr = std::shared_ptr< Attribute >
 Shared-ownership pointer to a Attribute.
 
using DefinitionPtr = std::shared_ptr< Definition >
 Shared-ownership pointer to a Definition.
 
using PropertyPtr = std::shared_ptr< Property >
 Shared-ownership pointer to a Property.
 
using ClassPtr = std::shared_ptr< Class >
 Shared-ownership pointer to a Class.
 
using FilePtr = std::shared_ptr< File >
 Shared-ownership pointer to a File.
 
using ProjectPtr = std::shared_ptr< Project >
 Shared-ownership pointer to a Project.
 

Typedef Documentation

◆ NodePtr

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

Shared-ownership pointer to a Node.

Definition at line 486 of file Rosebud/BasicTypes.h.

◆ TokenListPtr

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

Shared-ownership pointer to a TokenList.

Definition at line 488 of file Rosebud/BasicTypes.h.

◆ ArgumentListPtr

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

Shared-ownership pointer to a ArgumentList.

Definition at line 490 of file Rosebud/BasicTypes.h.

◆ CppStackPtr

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

Shared-ownership pointer to a CppStack.

Definition at line 492 of file Rosebud/BasicTypes.h.

◆ AttributePtr

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

Shared-ownership pointer to a Attribute.

Definition at line 494 of file Rosebud/BasicTypes.h.

◆ DefinitionPtr

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

Shared-ownership pointer to a Definition.

Definition at line 496 of file Rosebud/BasicTypes.h.

◆ PropertyPtr

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

Shared-ownership pointer to a Property.

Definition at line 498 of file Rosebud/BasicTypes.h.

◆ ClassPtr

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

Shared-ownership pointer to a Class.

Definition at line 500 of file Rosebud/BasicTypes.h.

◆ FilePtr

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

Shared-ownership pointer to a File.

Definition at line 502 of file Rosebud/BasicTypes.h.

◆ ProjectPtr

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

Shared-ownership pointer to a Project.

Definition at line 504 of file Rosebud/BasicTypes.h.