javacc-7.0.4.src.main.resources.templates.cpp.JJTTreeState.h.template Maven / Gradle / Ivy
\#ifndef JAVACC_JJT${PARSER_NAME}State_H
\#define JAVACC_JJT${PARSER_NAME}State_H
\#include
\#include
\#include "JavaCC.h"
\#include "Node.h"
using namespace std;
#if NAMESPACE
namespace ${NAMESPACE_OPEN}
#fi
class JJT${PARSER_NAME}State {
private:
vector* nodes;
vector* marks;
set* open_nodes;
int sp; // number of nodes on stack
int mk; // current mark
bool node_created;
public:
JJT${PARSER_NAME}State();
virtual ~JJT${PARSER_NAME}State();
/* Determines whether the current node was actually closed and
pushed. This should only be called in the final user action of a
node scope. */
virtual bool nodeCreated();
/* Call this to reinitialize the node stack. It is called
automatically by the parser's ReInit() method. */
virtual void reset();
/* Returns the root node of the AST. It only makes sense to call
this after a successful parse. */
virtual Node *rootNode();
/* Pushes a node on to the stack. */
virtual void pushNode(Node *n);
/* Returns the node on the top of the stack, and remove it from the stack. */
virtual Node *popNode();
/* Returns the node currently on the top of the stack. */
virtual Node *peekNode();
/* Returns the number of children on the stack in the current node scope. */
virtual int nodeArity();
virtual void clearNodeScope(Node *n);
virtual void openNodeScope(Node *n);
/* A definite node is constructed from a specified number of
children. That number of nodes are popped from the stack and
made the children of the definite node. Then the definite node
is pushed on to the stack. */
virtual void closeNodeScope(Node *n, int num);
/* A conditional node is constructed if its condition is true. All
the nodes that have been pushed since the node was opened are
made children of the conditional node, which is then pushed
on to the stack. If the condition is false the node is not
constructed and they are left on the stack. */
virtual void closeNodeScope(Node *n, bool condition);
/* Remove nodes */
public: void clear();
};
#if NAMESPACE
${NAMESPACE_CLOSE}
#fi
\#endif
© 2015 - 2024 Weber Informatics LLC | Privacy Policy