From 531881f651553b365db4b0e3a1e6311808dc5bd3 Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Sat, 6 Nov 2021 11:21:25 -0400 Subject: [PATCH] validateWriteContext: Tag exclusion should also be detected as invalid write context --- src/commands/CmdContext.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/commands/CmdContext.cpp b/src/commands/CmdContext.cpp index 936c7b429..7c3c064f8 100644 --- a/src/commands/CmdContext.cpp +++ b/src/commands/CmdContext.cpp @@ -115,10 +115,12 @@ std::string CmdContext::joinWords (const std::vector & words, unsig // Returns True if the context is a valid write context. If the context is // invalid due to a wrong modifier use, the modifier string will contain the // first invalid modifier. +// bool CmdContext::validateWriteContext (const std::vector & lexedArgs, std::string& modifier_token) { bool contains_or = false; bool contains_modifier = false; + bool contains_tag_exclusion = false; for (auto &arg: lexedArgs) { if (arg._lextype == Lexer::Type::op) @@ -137,9 +139,18 @@ bool CmdContext::validateWriteContext (const std::vector & lexedArgs, std::s break; } } + + if (arg._lextype == Lexer::Type::tag) { + if (arg.attribute ("sign") == "-") + { + contains_tag_exclusion = true; + break; + } + } + } - return not contains_or and not contains_modifier; + return not contains_or and not contains_modifier and not contains_tag_exclusion; } ////////////////////////////////////////////////////////////////////////////////