javacc-7.0.3.bin.templates.cpp.Node.h.template Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of javacc Show documentation
Show all versions of javacc Show documentation
JavaCC is a parser/scanner generator for java.
\#ifndef JAVACC_NODE_H
\#define JAVACC_NODE_H
\#include
\#include "JavaCC.h"
\#include "Token.h"
#if NODE_INCLUDES
\#include "${NODE_INCLUDES}"
#fi
#if NAMESPACE
namespace ${NAMESPACE_OPEN}
#fi
/* All AST nodes must implement this interface. It provides basic
machinery for constructing the parent and child relationships
between nodes. */
class ${PARSER_NAME};
#if VISITOR
class ${PARSER_NAME}Visitor;
#fi
class Node {
friend class SimpleNode;
public:
/** This method is called after the node has been made the current
node. It indicates that child nodes can now be added to it. */
virtual void jjtOpen() const = 0;
/** This method is called after all the child nodes have been added. */
virtual void jjtClose() const = 0;
/** This pair of methods are used to inform the node of its parent. */
virtual void jjtSetParent(Node *n) = 0;
virtual Node* jjtGetParent() const = 0;
/** This method tells the node to add its argument to the node's list of children. */
virtual void jjtAddChild(Node *n, size_t i) = 0;
/** This method returns a child node. The children are numbered
from zero, left to right. */
virtual Node* jjtGetChild(size_t i) const = 0;
/** Return the number of children the node has. */
virtual size_t jjtGetNumChildren() const = 0;
virtual int getId() const = 0;
#if VISITOR
/** Accept the visitor. **/
virtual ${VISITOR_RETURN_TYPE:-void} jjtAccept(${PARSER_NAME}Visitor *visitor, ${VISITOR_DATA_TYPE:-void *} data) const = 0;
#fi
/** Clear list of children, and return children that we have before.
Used in destructor to do linear destruction of tree.
Since some parsers has subclassed Node, we can't use pure virtual
function, that would break backward compatibility. */
private:
virtual std::vector jjtExtractChildrenForDestruction() {
std::vector x;
return x;
}
friend class SimpleNode;
public:
Node() { }
virtual ~Node() { }
};
#if NODE_FACTORY
class ${NODE_FACTORY};
extern ${NODE_FACTORY} *nodeFactory;
// Takes ownerhip of the factory
void setNodeFactory(${NODE_FACTORY} *factory);
${NODE_FACTORY} *getNodeFactory();
#fi
#if NAMESPACE
${NAMESPACE_CLOSE}
#fi
\#endif
© 2015 - 2024 Weber Informatics LLC | Privacy Policy