summaryrefslogtreecommitdiff
path: root/src/core/parser/ParserScope.hpp
diff options
context:
space:
mode:
authorAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-02-03 02:28:20 +0100
committerAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-02-03 02:28:20 +0100
commit4284cda04b3a1b1f4c5d4368cc8663d01b6925c6 (patch)
tree0dc012115a14c232b3ccfd8f998a02e4c4a3fcac /src/core/parser/ParserScope.hpp
parentc9cb8e1a0cda97511742211c8abab89b35493560 (diff)
Some refactoring, added function for extracting current type signature
Diffstat (limited to 'src/core/parser/ParserScope.hpp')
-rw-r--r--src/core/parser/ParserScope.hpp103
1 files changed, 63 insertions, 40 deletions
diff --git a/src/core/parser/ParserScope.hpp b/src/core/parser/ParserScope.hpp
index 2ef33d9..30db92f 100644
--- a/src/core/parser/ParserScope.hpp
+++ b/src/core/parser/ParserScope.hpp
@@ -104,6 +104,69 @@ public:
*/
Rooted<Node> resolve(const Rtti &type, const std::vector<std::string> &path,
Logger &logger);
+
+ /**
+ * Returns true if the stack is empty.
+ *
+ * @return true if there is no element on the stack.
+ */
+ bool isEmpty() const;
+
+ /**
+ * Returns a reference at the internal node stack.
+ *
+ * @return a const reference at the internal node stack.
+ */
+ const NodeVector<Node> &getStack() const;
+
+ /**
+ * Returns a list containing the Rtti type of each Node that is currently
+ * in the stack.
+ *
+ * @return the type signature of the current node stack.
+ */
+ std::vector<Rtti const *> getStackTypeSignature() const;
+
+ /**
+ * Returns the top-most Node instance in the ParserScopeBase hirarchy.
+ *
+ * @return a reference at the root node.
+ */
+ Rooted<Node> getRoot() const;
+
+ /**
+ * Returns the bottom-most Node instance in the ParserScopeBase hirarchy,
+ * e.g. the node that was pushed last onto the stack.
+ *
+ * @return a reference at the leaf node.
+ */
+ Rooted<Node> getLeaf() const;
+
+ /**
+ * Ascends in the stack starting with the leaf node, returns the first node
+ * that matches the type given in the RttiSet or nullptr if none matches.
+ *
+ * @param types is a set of Rtti types for which should be searched in the
+ * stack.
+ * @param maxDepth is the maximum number of stack entries the selection
+ * function may ascend. A negative value indicates no limitation.
+ */
+ Rooted<Node> select(RttiSet types, int maxDepth = -1);
+
+ /**
+ * Ascends in the stack starting with the leaf node, returns the first node
+ * that matches the given type or nullptr if none matches.
+ *
+ * @tparam T is the type that should be searched in the stack.
+ * @param maxDepth is the maximum number of stack entries the selection
+ * function may ascend. A negative value indicates no limitation.
+ */
+ template <class T>
+ Rooted<T> select(int maxDepth = -1)
+ {
+ return select(RttiSet{&typeOf<T>()}, maxDepth).cast<T>();
+ }
+
};
/**
@@ -344,46 +407,6 @@ public:
NodeVector<Node> getTopLevelNodes() const;
/**
- * Returns the top-most Node instance in the ParserScope hirarchy.
- *
- * @return a reference at the root node.
- */
- Rooted<Node> getRoot() const;
-
- /**
- * Returns the bottom-most Node instance in the ParserScope hirarchy, e.g.
- * the node that was pushed last onto the stack.
- *
- * @return a reference at the leaf node.
- */
- Rooted<Node> getLeaf() const;
-
- /**
- * Ascends in the stack starting with the leaf node, returns the first node
- * that matches the type given in the RttiSet or nullptr if none matches.
- *
- * @param types is a set of Rtti types for which should be searched in the
- * stack.
- * @param maxDepth is the maximum number of stack entries the selection
- * function may ascend. A negative value indicates no limitation.
- */
- Rooted<Node> select(RttiSet types, int maxDepth = -1);
-
- /**
- * Ascends in the stack starting with the leaf node, returns the first node
- * that matches the given type or nullptr if none matches.
- *
- * @tparam T is the type that should be searched in the stack.
- * @param maxDepth is the maximum number of stack entries the selection
- * function may ascend. A negative value indicates no limitation.
- */
- template <class T>
- Rooted<T> select(int maxDepth = -1)
- {
- return select(RttiSet{&typeOf<T>()}, maxDepth).cast<T>();
- }
-
- /**
* Sets a parser flag for the current stack depth.
*
* @param flag is the flag that should be set.