summaryrefslogtreecommitdiff
path: root/src/core/parser/stack/Handler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/parser/stack/Handler.cpp')
-rw-r--r--src/core/parser/stack/Handler.cpp102
1 files changed, 51 insertions, 51 deletions
diff --git a/src/core/parser/stack/Handler.cpp b/src/core/parser/stack/Handler.cpp
index 734976a..f9cefc2 100644
--- a/src/core/parser/stack/Handler.cpp
+++ b/src/core/parser/stack/Handler.cpp
@@ -32,13 +32,8 @@ namespace parser_stack {
/* Class HandlerData */
HandlerData::HandlerData(ParserContext &ctx, HandlerCallbacks &callbacks,
- const std::string &name, const State &state,
- const SourceLocation &location)
- : ctx(ctx),
- callbacks(callbacks),
- name(name),
- state(state),
- location(location)
+ const State &state, const SourceLocation &location)
+ : ctx(ctx), callbacks(callbacks), state(state), location(location)
{
}
@@ -67,22 +62,14 @@ Logger &Handler::logger()
const SourceLocation &Handler::location() const { return handlerData.location; }
-const std::string &Handler::name() const { return handlerData.name; }
-
-Variant Handler::readData()
-{
- return handlerData.callbacks.readData();
-}
+Variant Handler::readData() { return handlerData.callbacks.readData(); }
void Handler::pushTokens(const std::vector<TokenSyntaxDescriptor> &tokens)
{
handlerData.callbacks.pushTokens(tokens);
}
-void Handler::popTokens()
-{
- handlerData.callbacks.popTokens();
-}
+void Handler::popTokens() { handlerData.callbacks.popTokens(); }
TokenId Handler::registerToken(const std::string &token)
{
@@ -94,8 +81,6 @@ void Handler::unregisterToken(TokenId id)
handlerData.callbacks.unregisterToken(id);
}
-const std::string &Handler::getName() const { return name(); }
-
const State &Handler::getState() const { return handlerData.state; }
void Handler::setLogger(Logger &logger) { internalLogger = &logger; }
@@ -106,42 +91,51 @@ const SourceLocation &Handler::getLocation() const { return location(); }
/* Class EmptyHandler */
-bool EmptyHandler::start(Variant::mapType &args)
+bool EmptyHandler::startCommand(const std::string &commandName,
+ Variant::mapType &args)
{
- // Just accept anything
+ // Well, we'll support any command we get, don't we?
return true;
}
-void EmptyHandler::end()
+bool EmptyHandler::startAnnotation(const std::string &name,
+ Variant::mapType &args,
+ Handler::AnnotationType annotationType)
{
- // Do nothing if a command ends
+ // Do not support annotations. Annotations are too complicated for poor
+ // EmptyHandler.
+ return false;
}
-bool EmptyHandler::fieldStart(bool &isDefaultField, size_t fieldIndex)
+bool EmptyHandler::startToken(const Token &token, Handle<Node> node)
{
- // Accept any field
- return true;
+ // EmptyHandler does not support tokens.
+ return false;
}
-void EmptyHandler::fieldEnd()
+Handler::EndTokenResult EmptyHandler::endToken(const Token &token,
+ Handle<Node> node)
{
- // Do not handle fields
+ // There are no tokens to end here.
+ return EndTokenResult::ENDED_NONE;
}
-bool EmptyHandler::annotationStart(const Variant &className,
- Variant::mapType &args)
+void EmptyHandler::end()
{
- // Accept any data
- return true;
+ // Do nothing if a command ends
}
-bool EmptyHandler::annotationEnd(const Variant &className,
- const Variant &elementName)
+bool EmptyHandler::fieldStart(bool &isDefaultField, size_t fieldIndex)
{
- // Accept any annotation
+ // Accept any field
return true;
}
+void EmptyHandler::fieldEnd()
+{
+ // Do not handle field ends
+}
+
bool EmptyHandler::data()
{
// Support any data
@@ -155,12 +149,31 @@ Handler *EmptyHandler::create(const HandlerData &handlerData)
/* Class StaticHandler */
-bool StaticHandler::start(Variant::mapType &args)
+bool StaticHandler::startCommand(const std::string &commandName,
+ Variant::mapType &args)
{
// Do nothing in the default implementation, accept anything
return true;
}
+bool StaticHandler::startAnnotation(const std::string &name,
+ Variant::mapType &args,
+ Handler::AnnotationType annotationType)
+{
+ return false;
+}
+
+bool StaticHandler::startToken(const Token &token, Handle<Node> node)
+{
+ return false;
+}
+
+Handler::EndTokenResult StaticHandler::endToken(const Token &token,
+ Handle<Node> node)
+{
+ return EndTokenResult::ENDED_NONE;
+}
+
void StaticHandler::end()
{
// Do nothing here
@@ -182,20 +195,6 @@ void StaticHandler::fieldEnd()
// Do nothing here
}
-bool StaticHandler::annotationStart(const Variant &className,
- Variant::mapType &args)
-{
- // No annotations supported
- return false;
-}
-
-bool StaticHandler::annotationEnd(const Variant &className,
- const Variant &elementName)
-{
- // No annotations supported
- return false;
-}
-
bool StaticHandler::data()
{
logger().error("Did not expect any data here", readData());
@@ -210,7 +209,8 @@ StaticFieldHandler::StaticFieldHandler(const HandlerData &handlerData,
{
}
-bool StaticFieldHandler::start(Variant::mapType &args)
+bool StaticFieldHandler::startCommand(const std::string &commandName,
+ Variant::mapType &args)
{
if (!argName.empty()) {
auto it = args.find(argName);