4 #include <Rosebud/BasicTypes.h>
6 #include <Sawyer/Cached.h>
7 #include <Sawyer/Tree.h>
67 std::shared_ptr<T> findAncestor() {
68 return traverseReverse<T>([](
const std::shared_ptr<T> &node,
TraversalEvent) {
113 void string(
const std::string&);
119 std::vector<Token>::iterator
begin() {
120 return tokens.begin();
122 std::vector<Token>::iterator
end() {
174 static Type type(
const std::string &directive);
201 EdgeVector<TokenList> elmts;
246 static Ptr
instance(
const std::string &fqName,
const std::vector<Token> &nameTokens);
361 using Inheritance = std::vector<std::pair<std::string , std::string>>;
454 std::string
lexeme(
size_t position = 0);
466 bool matches(
size_t lookAhead,
const char*);
467 bool matches(
size_t lookAhead,
const std::string&);
469 bool matches(
const std::string&);
475 bool matchesAny(
size_t tokenPosition,
const std::vector<std::string>&);
503 std::string
content(
size_t begin,
size_t end);
Type type
Type of conditional compilation directive.
Sawyer::Optional< std::string > dataMemberName
Optional data member name override.
CppStack()
Default constructor used only by derived classes.
std::string priorText
Input text before the definition.
size_t size() const
Number of tokens.
Information about C preprocessor conditional compilation directives.
static Ptr instance()
Allocating constructor.
std::vector< Token > tokens
The ordered tokens.
std::string content(const std::vector< Token > &, Expand)
Input string for token list.
std::vector< Token >::iterator end()
Iterators.
Conditional compilation directive.
std::string endText
Text after the last member definition.
std::string lexeme
Cached lexeme.
std::shared_ptr< TokenList > TokenListPtr
Shared-ownership pointer to a TokenList.
std::string fqName
Fully qualified name.
std::shared_ptr< Project > ProjectPtr
Shared-ownership pointer to a Project.
std::vector< Token >::iterator begin()
Iterators.
Token docToken
Token associated with the Doxygen comment.
std::string lexeme(size_t position=0)
Text associated with a token.
A node that holds a list of arguments.
Rosebud is a tool to generate code for ROSE.
std::shared_ptr< ArgumentList > ArgumentListPtr
Shared-ownership pointer to a ArgumentList.
static Ptr instance()
Allocating constructor.
Sawyer::Tree::TraversalEvent TraversalEvent
Alias for traversal events.
bool printError(const FilePtr &file) const
Print an error message for the top of the stack if there's something wrong with it.
Not a conditional compilation directive.
std::shared_ptr< Definition > DefinitionPtr
Shared-ownership pointer to a Definition.
EdgeVector< Property > properties
Non-null list of zero or more properties.
std::string name
Unqualified name for the definition.
std::vector< Level > Stack
A stack of nested conditional compilation directives.
void push_back(const Token &token)
Insert a token at the end of the list.
Sawyer::Optional< std::vector< std::string > > mutatorNames
Optional override for mutator names.
Definition()
Default constructor used only by derived classes.
Token startToken
Token at the start of the definition.
bool startsWith(const Token &, const char *)
Test whether a token starts with a certain string.
Edge< ArgumentList > arguments
Attribute arguments.
Root of an AST for one or more input files.
const Token token(size_t lookAhead=0)
Current or future token.
Token endTextToken
Token that encloses endText.
AttributePtr findAttribute(const std::string &fqName)
Finds an attribute with the specified fully qualified name.
static Ptr instance()
Allocating constructor.
TokenList()
Default constructor used only by derived classes.
static Type type(const std::string &directive)
Type of directive.
Property()
Default constructor used only by derived classes.
EdgeVector< Attribute > attributes
Non-null pointer to the list of attributes controlling this property.
std::string doc
Doxygen documentation comment.
Represents a class definition.
std::string string()
Return the text for all tokens in this list.
Token endTextToken
Token that encloses endText.
void emitContext(std::ostream &, const Token &first, const Token &locus, const Token &last)
Emit the context for a diagnostic message.
Token priorTextToken
Token describing the location of the prior text.
Base class for class and property definitions.
std::string trimmedContent(size_t begin, size_t end, Token &outputToken)
Input string for file region.
static Ptr instance(const std::string &name)
Allocating constructor.
Base class for tree vertices.
Class()
Default constructor used only by derived classes.
Edge< TokenList > cType
Optional pointer to tokens that define the property type.
std::vector< Token > nameTokens
One or more tokens associated with the name.
Edge< CppStack > cppStack
C preprocessor pending conditional compilation directives.
std::string name()
Name of the input file.
bool empty() const
True if there are no tokens in this node.
static Ptr instance()
Allocating constructor.
Stack stack
The stack of nested conditional compilation directives.
An attribute adjusting the details for a definition.
Attribute()
Default constructor used only by derived classes.
std::string endText
Text after the last class definition until the end of the file.
void emitClose(std::ostream &)
Emit matching #endif for all control flow directives in this stack.
std::shared_ptr< Property > PropertyPtr
Shared-ownership pointer to a Property.
Expand
How to obtain text when converting a sequence of tokens to a string.
static bool process(const FilePtr &, const Token &directive, Stack &runningStack)
Adjust the stack based on the C preprocessor directive.
bool matchesAny(size_t tokenPosition, const std::vector< std::string > &)
Test whether a token matches any text.
Inheritance inheritance
Information about base classes.
Token consume()
Consume tokens.
std::shared_ptr< File > FilePtr
Shared-ownership pointer to a File.
Token nameToken
Token for the definition's unqualified name.
std::shared_ptr< Class > ClassPtr
Shared-ownership pointer to a Class.
Edge< TokenList > cInit
Optional pointer to tokens that define the property's initial value.
static Ptr instance()
Allocating constructor.
std::vector< std::pair< std::string, std::string >> Inheritance
A list of access specifiers and class names used for class inheritance.
TokenStream & tokenStream()
Token stream for the file.
std::shared_ptr< Attribute > AttributePtr
Shared-ownership pointer to a Attribute.
Token token
Token representing the conditional compilation directive.
std::vector< ClassPtr > allClassesFileOrder()
Return all classes defined in the input.
std::list< Directive > Level
The CPP directives that belong to the same level.
Node that holds a sequence of consecutive tokens from an input file.
Represents a class property definition.
Type
Type of CPP directive.
static Ptr instance()
Allocating constructor.
std::shared_ptr< CppStack > CppStackPtr
Shared-ownership pointer to a CppStack.
Sawyer::Optional< std::vector< std::string > > accessorNames
Optional override for accessor names.
Project()
Default constructor used only by derived classes.
void emitOpen(std::ostream &)
Emit all control flow directives in this stack.
std::shared_ptr< Node > NodePtr
Shared-ownership pointer to a Node.
EdgeVector< Class > classes
Non-null list of zero or more class definitions.
EdgeVector< File > files
Non-null list of input files.
bool matches(const Token &, const char *)
Test whether a token matches a string.
static Ptr instance()
Allocating constructor.