summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/parser/stack/Callbacks.hpp4
-rw-r--r--src/core/parser/stack/Handler.cpp10
-rw-r--r--src/core/parser/stack/Handler.hpp4
-rw-r--r--src/core/parser/stack/Stack.cpp6
-rw-r--r--src/core/parser/stack/TokenStack.cpp8
-rw-r--r--src/core/parser/stack/TokenStack.hpp4
6 files changed, 20 insertions, 16 deletions
diff --git a/src/core/parser/stack/Callbacks.hpp b/src/core/parser/stack/Callbacks.hpp
index dfe41fc..12796ed 100644
--- a/src/core/parser/stack/Callbacks.hpp
+++ b/src/core/parser/stack/Callbacks.hpp
@@ -86,8 +86,10 @@ public:
*
* @param tokens is a list of TokenSyntaxDescriptor instances that should be
* stored on the stack.
+ * @param inherit if true, the previous tokens descriptors are extended.
*/
- virtual void pushTokens(const std::vector<SyntaxDescriptor> &tokens) = 0;
+ virtual void pushTokens(const std::vector<SyntaxDescriptor> &tokens,
+ bool inherit) = 0;
/**
* Removes the previously pushed list of tokens from the stack.
diff --git a/src/core/parser/stack/Handler.cpp b/src/core/parser/stack/Handler.cpp
index ef6ca8b..019ae5a 100644
--- a/src/core/parser/stack/Handler.cpp
+++ b/src/core/parser/stack/Handler.cpp
@@ -78,9 +78,10 @@ const State &Handler::state() const { return handlerData.state; }
Variant Handler::readData() { return handlerData.callbacks.readData(); }
-void Handler::pushTokens(const std::vector<SyntaxDescriptor> &tokens)
+void Handler::pushTokens(const std::vector<SyntaxDescriptor> &tokens,
+ bool inherit)
{
- handlerData.callbacks.pushTokens(tokens);
+ handlerData.callbacks.pushTokens(tokens, inherit);
}
void Handler::popTokens() { handlerData.callbacks.popTokens(); }
@@ -164,10 +165,7 @@ bool StaticHandler::startCommand(Variant::mapType &args)
return true;
}
-bool StaticHandler::startAnnotation(Variant::mapType &args)
-{
- return false;
-}
+bool StaticHandler::startAnnotation(Variant::mapType &args) { return false; }
bool StaticHandler::startToken(Handle<Node> node) { return false; }
diff --git a/src/core/parser/stack/Handler.hpp b/src/core/parser/stack/Handler.hpp
index d85848a..1149ed2 100644
--- a/src/core/parser/stack/Handler.hpp
+++ b/src/core/parser/stack/Handler.hpp
@@ -166,8 +166,10 @@ protected:
*
* @param tokens is a list of TokenSyntaxDescriptor instances that should be
* stored on the stack.
+ * @param inherit if true, the last tokens on the stack are extended and not
+ * overriden.
*/
- void pushTokens(const std::vector<SyntaxDescriptor> &tokens);
+ void pushTokens(const std::vector<SyntaxDescriptor> &tokens, bool inherit);
/**
* Calls the corresponding function in the HandlerCallbacks instance.
diff --git a/src/core/parser/stack/Stack.cpp b/src/core/parser/stack/Stack.cpp
index 90735df..6fa8659 100644
--- a/src/core/parser/stack/Stack.cpp
+++ b/src/core/parser/stack/Stack.cpp
@@ -480,7 +480,7 @@ public:
TokenId registerToken(const std::string &token) override;
void unregisterToken(TokenId id) override;
Variant readData() override;
- void pushTokens(const std::vector<SyntaxDescriptor> &tokens) override;
+ void pushTokens(const std::vector<SyntaxDescriptor> &tokens, bool inherit) override;
void popTokens() override;
};
@@ -1089,7 +1089,7 @@ void StackImpl::unregisterToken(TokenId id)
tokenRegistry.unregisterToken(id);
}
-void StackImpl::pushTokens(const std::vector<SyntaxDescriptor> &tokens)
+void StackImpl::pushTokens(const std::vector<SyntaxDescriptor> &tokens, bool inherit)
{
// Push the tokens onto the token stack
for (const SyntaxDescriptor &token: tokens) {
@@ -1097,7 +1097,7 @@ void StackImpl::pushTokens(const std::vector<SyntaxDescriptor> &tokens)
std::cout << token.close << std::endl;
std::cout << token.shortForm << std::endl;
}
- tokenStack.pushTokens(tokens);
+ tokenStack.pushTokens(tokens, inherit);
}
void StackImpl::popTokens()
diff --git a/src/core/parser/stack/TokenStack.cpp b/src/core/parser/stack/TokenStack.cpp
index b6fc6e1..c20c764 100644
--- a/src/core/parser/stack/TokenStack.cpp
+++ b/src/core/parser/stack/TokenStack.cpp
@@ -23,14 +23,14 @@
namespace ousia {
namespace parser_stack {
-void TokenStack::pushTokens(const std::vector<SyntaxDescriptor> &tokens)
+void TokenStack::pushTokens(const std::vector<SyntaxDescriptor> &tokens,
+ bool inherit)
{
+ // TODO: Implement inheritance
stack.push_back(tokens);
}
-void TokenStack::popTokens() {
- stack.pop_back();
-}
+void TokenStack::popTokens() { stack.pop_back(); }
TokenSet TokenStack::tokens() const
{
diff --git a/src/core/parser/stack/TokenStack.hpp b/src/core/parser/stack/TokenStack.hpp
index 667b976..32f181a 100644
--- a/src/core/parser/stack/TokenStack.hpp
+++ b/src/core/parser/stack/TokenStack.hpp
@@ -55,8 +55,10 @@ public:
*
* @param tokens is a list of SyntaxDescriptor instances that should be
* stored on the stack.
+ * @param inherit if set to true, combines the given tokens with the tokens
+ * from the last stack level.
*/
- void pushTokens(const std::vector<SyntaxDescriptor> &tokens);
+ void pushTokens(const std::vector<SyntaxDescriptor> &tokens, bool inherit);
/**
* Removes the previously pushed list of tokens from the stack.