validateWriteContext: Tag exclusion should also be detected as invalid write context

This commit is contained in:
Tomas Babej 2021-11-06 11:21:25 -04:00
parent 7de681aa3b
commit 531881f651
No known key found for this signature in database
GPG key ID: B0747C6578F7D2F5

View file

@ -115,10 +115,12 @@ std::string CmdContext::joinWords (const std::vector <std::string>& words, unsig
// Returns True if the context is a valid write context. If the context is // 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 // invalid due to a wrong modifier use, the modifier string will contain the
// first invalid modifier. // first invalid modifier.
//
bool CmdContext::validateWriteContext (const std::vector <A2>& lexedArgs, std::string& modifier_token) bool CmdContext::validateWriteContext (const std::vector <A2>& lexedArgs, std::string& modifier_token)
{ {
bool contains_or = false; bool contains_or = false;
bool contains_modifier = false; bool contains_modifier = false;
bool contains_tag_exclusion = false;
for (auto &arg: lexedArgs) { for (auto &arg: lexedArgs) {
if (arg._lextype == Lexer::Type::op) if (arg._lextype == Lexer::Type::op)
@ -137,9 +139,18 @@ bool CmdContext::validateWriteContext (const std::vector <A2>& lexedArgs, std::s
break; 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;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////