summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/parser/stack/Stack.cpp8
-rw-r--r--testdata/integration/user_defined_syntax/token_in_invalid_command.fail.osml15
2 files changed, 22 insertions, 1 deletions
diff --git a/src/core/parser/stack/Stack.cpp b/src/core/parser/stack/Stack.cpp
index 2ad5c8b..2acea32 100644
--- a/src/core/parser/stack/Stack.cpp
+++ b/src/core/parser/stack/Stack.cpp
@@ -692,7 +692,7 @@ ssize_t StackImpl::pendingCloseTokenHandlerIdx(TokenId token) const
TokenSet StackImpl::currentTokens() const
{
TokenSet res;
- if (currentInfo().state().supportsTokens) {
+ if (currentInfo().valid && currentInfo().state().supportsTokens) {
res = tokenStack.tokens();
ssize_t idx = pendingCloseTokenHandlerIdx();
if (idx >= 0) {
@@ -1111,6 +1111,12 @@ bool StackImpl::handleOpenTokens(Logger &logger, const Token &token,
void StackImpl::handleToken(const Token &token)
{
+ // If the current handler is not valid, just ignore the token
+ // TODO: Unify the handling of invalid elements across this class
+ if (!handlersValid()) {
+ return;
+ }
+
// If the token matches one from the "pendingCloseTokens" list, then just
// end the corresponding handler
const ssize_t pendingCloseIndex = pendingCloseTokenHandlerIdx(token.id);
diff --git a/testdata/integration/user_defined_syntax/token_in_invalid_command.fail.osml b/testdata/integration/user_defined_syntax/token_in_invalid_command.fail.osml
new file mode 100644
index 0000000..b424c6b
--- /dev/null
+++ b/testdata/integration/user_defined_syntax/token_in_invalid_command.fail.osml
@@ -0,0 +1,15 @@
+\document
+
+\ontology#test
+ \struct#test[root=true]
+ \field
+ \childRef[ref=a]
+ \struct#a
+ \syntax
+ \short{-}
+
+\begin{test}
+ \b{a-}
+ \b{a-}
+\end{test}
+