mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-03 05:57:40 -05:00
Added comments attribute
This commit is contained in:
@@ -338,10 +338,12 @@ namespace hex::lang {
|
||||
|
||||
auto handleVariableAttributes = [this, &currPattern](auto attribute, auto value) {
|
||||
|
||||
if (attribute == "color")
|
||||
currPattern->setColor(hex::changeEndianess(u32(strtoul(value.data(), nullptr, 0)) << 8, std::endian::big));
|
||||
else if (attribute == "name")
|
||||
currPattern->setVariableName(value.data());
|
||||
if (attribute == "color" && value.has_value())
|
||||
currPattern->setColor(hex::changeEndianess(u32(strtoul(value->data(), nullptr, 0)) << 8, std::endian::big));
|
||||
else if (attribute == "name" && value.has_value())
|
||||
currPattern->setVariableName(value->data());
|
||||
else if (attribute == "comment" && value.has_value())
|
||||
currPattern->setComment(value->data());
|
||||
else
|
||||
this->getConsole().abortEvaluation("unknown or invalid attribute");
|
||||
|
||||
@@ -349,6 +351,9 @@ namespace hex::lang {
|
||||
|
||||
auto &attributes = attributableNode->getAttributes();
|
||||
|
||||
if (attributes.empty())
|
||||
return currPattern;
|
||||
|
||||
if (auto variableDeclNode = dynamic_cast<ASTNodeVariableDecl*>(currNode); variableDeclNode != nullptr) {
|
||||
for (auto &attribute : attributes)
|
||||
handleVariableAttributes(attribute->getAttribute(), attribute->getValue());
|
||||
|
||||
@@ -420,7 +420,7 @@ namespace hex::lang {
|
||||
|
||||
if (MATCHES(sequence(VALUETYPE_PADDING, SEPARATOR_SQUAREBRACKETOPEN)))
|
||||
member = parsePadding();
|
||||
else if (MATCHES((optional(KEYWORD_BE), optional(KEYWORD_LE)) && variant(IDENTIFIER, VALUETYPE_ANY) && sequence(IDENTIFIER, SEPARATOR_SQUAREBRACKETOPEN)))
|
||||
else if (MATCHES((optional(KEYWORD_BE), optional(KEYWORD_LE)) && variant(IDENTIFIER, VALUETYPE_ANY) && sequence(IDENTIFIER, SEPARATOR_SQUAREBRACKETOPEN) && none(sequence(SEPARATOR_SQUAREBRACKETOPEN))))
|
||||
member = parseMemberArrayVariable();
|
||||
else if (MATCHES((optional(KEYWORD_BE), optional(KEYWORD_LE)) && variant(IDENTIFIER, VALUETYPE_ANY) && sequence(IDENTIFIER)))
|
||||
member = parseMemberVariable();
|
||||
|
||||
Reference in New Issue
Block a user