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 ph-javacc-maven-plugin Show documentation
Show all versions of ph-javacc-maven-plugin Show documentation
Maven 3 Plugin for processing JavaCC grammar files.
\#ifndef NODE_H
\#define NODE_H
\#include
\#include "JavaCC.h"
\#include "Token.h"
#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 {
/** This method is called after the node has been made the current
node. It indicates that child nodes can now be added to it. */
public: virtual void jjtOpen() const = 0;
/** This method is called after all the child nodes have been
added. */
public: virtual void jjtClose() const = 0;
/** This pair of methods are used to inform the node of its
parent. */
public: virtual void jjtSetParent(Node *n) = 0;
public: virtual Node *jjtGetParent() const = 0;
/** This method tells the node to add its argument to the node's
list of children. */
public: virtual void jjtAddChild(Node *n, int i) = 0;
/** This method returns a child node. The children are numbered
from zero, left to right. */
public: virtual Node *jjtGetChild(int i) const = 0;
/** Return the number of children the node has. */
public: virtual int jjtGetNumChildren() const = 0;
public: virtual int getId() const = 0;
#if VISITOR
/** Accept the visitor. **/
public: virtual ${VISITOR_RETURN_TYPE:-void} jjtAccept(${PARSER_NAME}Visitor *visitor, ${VISITOR_DATA_TYPE:-void *} data) const = 0;
#fi
public: 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