From 35554e6d32a5e66819f8a7bf869f1853e0d6fede Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Tue, 2 Dec 2014 14:59:44 +0100 Subject: continued working on the xml parser class --- src/plugins/xml/XmlParser.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'src/plugins/xml/XmlParser.cpp') diff --git a/src/plugins/xml/XmlParser.cpp b/src/plugins/xml/XmlParser.cpp index f6891a8..42e0dd4 100644 --- a/src/plugins/xml/XmlParser.cpp +++ b/src/plugins/xml/XmlParser.cpp @@ -20,12 +20,55 @@ #include +#include + #include "XmlParser.hpp" namespace ousia { namespace parser { namespace xml { +/* Document structure */ +static const State STATE_DOCUMENT = 0; +static const State STATE_HEAD = 1; +static const State STATE_BODY = 2; + +/* Special commands */ +static const State STATE_USE = 100; +static const State STATE_INCLUDE = 101; +static const State STATE_INLINE = 102; + +/* Type system definitions */ +static const State STATE_TYPES = 200; +static const State STATE_CONSTANT = 201; +static const State STATE_ENUM = 202; +static const State STATE_STRUCT = 203; + +static Handler* createTestHandler(const ParserContext &ctx, + std::string name, State state, + State parentState, bool isChild) +{ + return nullptr; +} + +static const std::multimap XML_HANDLERS{ + /* Documents */ + {"document", {{STATE_NONE}, createTestHandler, STATE_DOCUMENT}}, + {"head", {{STATE_DOCUMENT}, createTestHandler, STATE_HEAD}}, + {"body", {{STATE_DOCUMENT}, createTestHandler, STATE_BODY, true}}, + + /* Special commands */ + {"use", {{STATE_HEAD}, createTestHandler, STATE_USE}}, + {"include", {{STATE_ALL}, createTestHandler, STATE_INCLUDE}}, + {"inline", {{STATE_ALL}, createTestHandler, STATE_INLINE}}, + + /* Typesystem definitions */ + {"types", {{STATE_NONE, STATE_HEAD}, createTestHandler, STATE_TYPES}}, + {"enum", {{STATE_TYPES}, createTestHandler, STATE_ENUM}}, + {"struct", {{STATE_TYPES}, createTestHandler, STATE_STRUCT}}, + {"constant", {{STATE_TYPES}, createTestHandler, STATE_CONSTANT}} +}; + /** * Wrapper class around the XML_Parser pointer which safely frees it whenever * the scope is left (e.g. because an exception was thrown). -- cgit v1.2.3