All Downloads are FREE. Search and download functionalities are using the official Maven repository.

javacc-6.1.2.bin.templates.cpp.JJTTreeState.h.template Maven / Gradle / Ivy

There is a newer version: 7.0.13
Show newest version
\#ifndef JJT${PARSER_NAME}State_H
\#define JJT${PARSER_NAME}State_H
\#include 
\#include 
\#include "JavaCC.h"
\#include "Node.h"


#if NAMESPACE
namespace ${NAMESPACE_OPEN}
#fi
class JJT${PARSER_NAME}State {
  private: std::vector *nodes;
  private: std::vector *marks;
  private: std::set *open_nodes;

  private: int sp;        // number of nodes on stack
  private: int mk;        // current mark
  private: bool node_created;

  public: 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.  */
  public: virtual bool nodeCreated();

  /* Call this to reinitialize the node stack.  It is called
     automatically by the parser's ReInit() method. */
  public: virtual void reset();

  /* Returns the root node of the AST.  It only makes sense to call
     this after a successful parse. */
  public: virtual Node *rootNode();

  /* Pushes a node on to the stack. */
  public: virtual void pushNode(Node *n);

  /* Returns the node on the top of the stack, and remove it from the
     stack.  */
  public: virtual Node *popNode();

  /* Returns the node currently on the top of the stack. */
  public: virtual Node *peekNode();

  /* Returns the number of children on the stack in the current node
     scope. */
  public: virtual int nodeArity();


  public: virtual void clearNodeScope(Node *n);


  public: 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. */
  public: 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. */
  public: virtual void closeNodeScope(Node *n, bool condition);
  public: virtual ~JJT${PARSER_NAME}State();
};

#if NAMESPACE
${NAMESPACE_CLOSE}
#fi
\#endif




© 2015 - 2024 Weber Informatics LLC | Privacy Policy