summaryrefslogtreecommitdiff
path: root/src/core/parser/ParserStack.hpp
diff options
context:
space:
mode:
authorAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-01-02 12:12:00 +0100
committerAndreas Stöckel <andreas@somweyr.de>2015-01-02 12:12:00 +0100
commit7bca3d7e34ca5c2b1e939a001229c04fe6b6bde0 (patch)
treea9ee906cecaf2e32fd05dadf1b07f34d51d1a9cf /src/core/parser/ParserStack.hpp
parenta68ee5ed18d9f6744ce99890b8e0249dff3bd070 (diff)
Added argument validation to parser stack
Diffstat (limited to 'src/core/parser/ParserStack.hpp')
-rw-r--r--src/core/parser/ParserStack.hpp35
1 files changed, 28 insertions, 7 deletions
diff --git a/src/core/parser/ParserStack.hpp b/src/core/parser/ParserStack.hpp
index 233f4f9..93180b4 100644
--- a/src/core/parser/ParserStack.hpp
+++ b/src/core/parser/ParserStack.hpp
@@ -38,6 +38,8 @@
#include <vector>
#include <core/common/Variant.hpp>
+#include <core/common/Logger.hpp>
+#include <core/model/Typesystem.hpp>
#include "Parser.hpp"
@@ -61,9 +63,6 @@ class Handler {
private:
Rooted<Node> node;
-protected:
- void setNode(Handle<Node> node) { this->node = node; }
-
public:
/**
* Reference to the ParserContext instance that should be used to resolve
@@ -132,7 +131,7 @@ public:
virtual void start(const Variant &args) = 0;
/**
- * Called whenever the command for which this handler
+ * Called whenever the command for which this handler is defined ends.
*/
virtual void end() = 0;
@@ -153,7 +152,7 @@ public:
*
* @param handler is a reference at the child Handler instance.
*/
- virtual void child(std::shared_ptr<Handler> handler){};
+ virtual void child(std::shared_ptr<Handler> handler);
};
/**
@@ -212,12 +211,34 @@ struct HandlerDescriptor {
*/
const bool arbitraryChildren;
+ /**
+ * Pointer pointing at a StructType describing the layout of the given when
+ * a new Handler instance is instantiated.
+ */
+ const Rooted<model::StructType> argsType;
+
+ /**
+ * Constructor of the HandlerDescriptor class.
+ *
+ * @param parentStates is a set of states in which a new handler of this
+ * type may be instantiated.
+ * @param ctor is a function pointer pointing at a function that
+ * instantiates the acutal Handler instance.
+ * @param targetState is the state the ParserStack switches to after
+ * instantiating an in instance of the described Handler instances.
+ * @param arbitraryChildren allows the Handler instance to handle any child
+ * node.
+ * @param argsType is a struct type describing the arguments that can be
+ * passed to the Handler or nullptr if no check should be performed.
+ */
HandlerDescriptor(std::set<State> parentStates, HandlerConstructor ctor,
- State targetState, bool arbitraryChildren = false)
+ State targetState, bool arbitraryChildren = false,
+ Handle<model::StructType> argsType = nullptr)
: parentStates(std::move(parentStates)),
ctor(ctor),
targetState(targetState),
- arbitraryChildren(arbitraryChildren)
+ arbitraryChildren(arbitraryChildren),
+ argsType(argsType)
{
}