Adjust further code formatting

This commit is contained in:
Clang Format
2023-11-19 21:59:57 +01:00
committed by Jan
parent d5f881be04
commit c858695f0c
96 changed files with 4036 additions and 2241 deletions

View File

@ -30,15 +30,22 @@ std::unique_ptr<SimpleExpressionMatchers::matcher_t> MenuExpressionMatchers::Par
{
const MenuMatcherFactory create(labelSupplier);
return create.Or({create
.And({create.Identifier().Capture(CAPTURE_FUNCTION_NAME),
create.Char('('),
create.Optional(create.And({
create.Label(LABEL_EXPRESSION),
create.OptionalLoop(create.And({create.Char(','), create.Label(LABEL_EXPRESSION)})),
})),
create.Char(')').Tag(TAG_EXPRESSION_FUNCTION_CALL_END)})
.Tag(TAG_EXPRESSION_FUNCTION_CALL)});
return create.Or({
create
.And({
create.Identifier().Capture(CAPTURE_FUNCTION_NAME),
create.Char('('),
create.Optional(create.And({
create.Label(LABEL_EXPRESSION),
create.OptionalLoop(create.And({
create.Char(','),
create.Label(LABEL_EXPRESSION),
})),
})),
create.Char(')').Tag(TAG_EXPRESSION_FUNCTION_CALL_END),
})
.Tag(TAG_EXPRESSION_FUNCTION_CALL),
});
}
const std::map<std::string, size_t>& MenuExpressionMatchers::GetBaseFunctionMapForFeatureLevel(const FeatureLevel featureLevel)

View File

@ -13,57 +13,75 @@ MenuMatcherFactory::MenuMatcherFactory(const IMatcherForLabelSupplier<SimplePars
MatcherFactoryWrapper<SimpleParserValue> MenuMatcherFactory::StringChain() const
{
return Or({And({String(), Loop(String())})
.Transform(
[](const token_list_t& tokens) -> SimpleParserValue
{
std::ostringstream ss;
return Or({
And({
String(),
Loop(String()),
})
.Transform(
[](const token_list_t& tokens) -> SimpleParserValue
{
std::ostringstream ss;
for (const auto& token : tokens)
{
ss << token.get().StringValue();
}
for (const auto& token : tokens)
{
ss << token.get().StringValue();
}
return SimpleParserValue::String(tokens[0].get().GetPos(), new std::string(ss.str()));
}),
String()});
return SimpleParserValue::String(tokens[0].get().GetPos(), new std::string(ss.str()));
}),
String(),
});
}
MatcherFactoryWrapper<SimpleParserValue> MenuMatcherFactory::Text() const
{
return MatcherFactoryWrapper(Or({StringChain(), Identifier()}));
return MatcherFactoryWrapper(Or({
StringChain(),
Identifier(),
}));
}
MatcherFactoryWrapper<SimpleParserValue> MenuMatcherFactory::TextNoChain() const
{
return MatcherFactoryWrapper(Or({String(), Identifier()}));
return MatcherFactoryWrapper(Or({
String(),
Identifier(),
}));
}
MatcherFactoryWrapper<SimpleParserValue> MenuMatcherFactory::Numeric() const
{
return MatcherFactoryWrapper(Or({FloatingPoint(), Integer()}));
return MatcherFactoryWrapper(Or({
FloatingPoint(),
Integer(),
}));
}
MatcherFactoryWrapper<SimpleParserValue> MenuMatcherFactory::IntExpression() const
{
return MatcherFactoryWrapper(Or({Integer().Tag(TAG_INT).Capture(CAPTURE_INT),
And({
Char('(').Capture(CAPTURE_FIRST_TOKEN),
Label(MenuExpressionMatchers::LABEL_EXPRESSION),
Char(')'),
})
.Tag(TAG_EXPRESSION)}));
return MatcherFactoryWrapper(Or({
Integer().Tag(TAG_INT).Capture(CAPTURE_INT),
And({
Char('(').Capture(CAPTURE_FIRST_TOKEN),
Label(MenuExpressionMatchers::LABEL_EXPRESSION),
Char(')'),
})
.Tag(TAG_EXPRESSION),
}));
}
MatcherFactoryWrapper<SimpleParserValue> MenuMatcherFactory::NumericExpression() const
{
return MatcherFactoryWrapper(Or({Numeric().Tag(TAG_NUMERIC).Capture(CAPTURE_NUMERIC),
And({
Char('(').Capture(CAPTURE_FIRST_TOKEN),
Label(MenuExpressionMatchers::LABEL_EXPRESSION),
Char(')'),
})
.Tag(TAG_EXPRESSION)}));
return MatcherFactoryWrapper(Or({
Numeric().Tag(TAG_NUMERIC).Capture(CAPTURE_NUMERIC),
And({
Char('(').Capture(CAPTURE_FIRST_TOKEN),
Label(MenuExpressionMatchers::LABEL_EXPRESSION),
Char(')'),
})
.Tag(TAG_EXPRESSION),
}));
}
int MenuMatcherFactory::TokenNumericIntValue(const SimpleParserValue& value)

View File

@ -19,7 +19,9 @@ namespace menu::function_scope_sequences
{
const MenuMatcherFactory create(this);
AddMatchers({create.Char('}').Capture(CAPTURE_TOKEN)});
AddMatchers({
create.Char('}').Capture(CAPTURE_TOKEN),
});
}
protected:

View File

@ -11,7 +11,10 @@ GenericBoolPropertySequence::GenericBoolPropertySequence(std::string keywordName
{
const MenuMatcherFactory create(this);
AddMatchers({create.KeywordIgnoreCase(std::move(keywordName)).Capture(CAPTURE_FIRST_TOKEN), create.Integer().Capture(CAPTURE_VALUE)});
AddMatchers({
create.KeywordIgnoreCase(std::move(keywordName)).Capture(CAPTURE_FIRST_TOKEN),
create.Integer().Capture(CAPTURE_VALUE),
});
}
void GenericBoolPropertySequence::ProcessMatch(MenuFileParserState* state, SequenceResult<SimpleParserValue>& result) const

View File

@ -18,7 +18,7 @@ GenericColorPropertySequence::GenericColorPropertySequence(std::string keywordNa
create.NumericExpression().Tag(TAG_COLOR), // r
create.Optional(create.NumericExpression().Tag(TAG_COLOR)), // g
create.Optional(create.NumericExpression().Tag(TAG_COLOR)), // b
create.Optional(create.NumericExpression().Tag(TAG_COLOR)) // a
create.Optional(create.NumericExpression().Tag(TAG_COLOR)), // a
});
}

View File

@ -19,9 +19,11 @@ std::unique_ptr<GenericExpressionPropertySequence> GenericExpressionPropertySequ
auto result = std::unique_ptr<GenericExpressionPropertySequence>(new GenericExpressionPropertySequence(std::move(setCallback)));
const MenuMatcherFactory create(result.get());
result->AddMatchers({create.KeywordIgnoreCase(std::move(keyword)).Capture(CAPTURE_FIRST_TOKEN),
create.Label(MenuExpressionMatchers::LABEL_EXPRESSION),
create.Optional(create.Char(';'))});
result->AddMatchers({
create.KeywordIgnoreCase(std::move(keyword)).Capture(CAPTURE_FIRST_TOKEN),
create.Label(MenuExpressionMatchers::LABEL_EXPRESSION),
create.Optional(create.Char(';')),
});
return std::move(result);
}
@ -36,9 +38,11 @@ std::unique_ptr<GenericExpressionPropertySequence> GenericExpressionPropertySequ
for (auto keyword : keywords)
keywordMatchers.emplace_back(create.KeywordIgnoreCase(std::move(keyword)));
result->AddMatchers({create.And(std::move(keywordMatchers)).Capture(CAPTURE_FIRST_TOKEN),
create.Label(MenuExpressionMatchers::LABEL_EXPRESSION),
create.Optional(create.Char(';'))});
result->AddMatchers({
create.And(std::move(keywordMatchers)).Capture(CAPTURE_FIRST_TOKEN),
create.Label(MenuExpressionMatchers::LABEL_EXPRESSION),
create.Optional(create.Char(';')),
});
return std::move(result);
}
@ -48,10 +52,12 @@ std::unique_ptr<GenericExpressionPropertySequence> GenericExpressionPropertySequ
auto result = std::unique_ptr<GenericExpressionPropertySequence>(new GenericExpressionPropertySequence(std::move(setCallback)));
const MenuMatcherFactory create(result.get());
result->AddMatchers({create.KeywordIgnoreCase(std::move(keyword)).Capture(CAPTURE_FIRST_TOKEN),
create.Optional(create.KeywordIgnoreCase("when")),
create.Label(MenuExpressionMatchers::LABEL_EXPRESSION),
create.Optional(create.Char(';'))});
result->AddMatchers({
create.KeywordIgnoreCase(std::move(keyword)).Capture(CAPTURE_FIRST_TOKEN),
create.Optional(create.KeywordIgnoreCase("when")),
create.Label(MenuExpressionMatchers::LABEL_EXPRESSION),
create.Optional(create.Char(';')),
});
return std::move(result);
}

View File

@ -13,7 +13,10 @@ GenericFloatingPointPropertySequence::GenericFloatingPointPropertySequence(std::
const MenuMatcherFactory create(this);
AddLabeledMatchers(MenuExpressionMatchers().Expression(this), MenuExpressionMatchers::LABEL_EXPRESSION);
AddMatchers({create.KeywordIgnoreCase(std::move(keywordName)).Capture(CAPTURE_FIRST_TOKEN), create.NumericExpression()});
AddMatchers({
create.KeywordIgnoreCase(std::move(keywordName)).Capture(CAPTURE_FIRST_TOKEN),
create.NumericExpression(),
});
}
void GenericFloatingPointPropertySequence::ProcessMatch(MenuFileParserState* state, SequenceResult<SimpleParserValue>& result) const

View File

@ -11,7 +11,10 @@ GenericMenuEventHandlerSetPropertySequence::GenericMenuEventHandlerSetPropertySe
{
const MenuMatcherFactory create(this);
AddMatchers({create.KeywordIgnoreCase(std::move(keywordName)).Capture(CAPTURE_FIRST_TOKEN), create.Char('{')});
AddMatchers({
create.KeywordIgnoreCase(std::move(keywordName)).Capture(CAPTURE_FIRST_TOKEN),
create.Char('{'),
});
}
void GenericMenuEventHandlerSetPropertySequence::ProcessMatch(MenuFileParserState* state, SequenceResult<SimpleParserValue>& result) const

View File

@ -11,7 +11,10 @@ GenericStringPropertySequence::GenericStringPropertySequence(std::string keyword
{
const MenuMatcherFactory create(this);
AddMatchers({create.KeywordIgnoreCase(std::move(keywordName)).Capture(CAPTURE_FIRST_TOKEN), create.Text().Capture(CAPTURE_VALUE)});
AddMatchers({
create.KeywordIgnoreCase(std::move(keywordName)).Capture(CAPTURE_FIRST_TOKEN),
create.Text().Capture(CAPTURE_VALUE),
});
}
void GenericStringPropertySequence::ProcessMatch(MenuFileParserState* state, SequenceResult<SimpleParserValue>& result) const

View File

@ -14,7 +14,9 @@ namespace menu::global_scope_sequences
{
const MenuMatcherFactory create(this);
AddMatchers({create.Char('}')});
AddMatchers({
create.Char('}'),
});
}
protected:

View File

@ -42,7 +42,7 @@ class ItemScopeOperations
CommonItemFeatureType::NEWS_TICKER, // ITEM_TYPE_NEWS_TICKER
CommonItemFeatureType::NONE, // ITEM_TYPE_TEXT_SCROLL
CommonItemFeatureType::EDIT_FIELD, // ITEM_TYPE_EMAILFIELD
CommonItemFeatureType::EDIT_FIELD // ITEM_TYPE_PASSWORDFIELD
CommonItemFeatureType::EDIT_FIELD, // ITEM_TYPE_PASSWORDFIELD
};
inline static const CommonItemFeatureType IW5_FEATURE_TYPE_BY_TYPE[0x18]{
@ -69,7 +69,7 @@ class ItemScopeOperations
CommonItemFeatureType::NEWS_TICKER, // ITEM_TYPE_NEWS_TICKER
CommonItemFeatureType::NONE, // ITEM_TYPE_TEXT_SCROLL
CommonItemFeatureType::EDIT_FIELD, // ITEM_TYPE_EMAILFIELD
CommonItemFeatureType::EDIT_FIELD // ITEM_TYPE_PASSWORDFIELD
CommonItemFeatureType::EDIT_FIELD, // ITEM_TYPE_PASSWORDFIELD
};
public:
@ -158,7 +158,9 @@ namespace menu::item_scope_sequences
{
const MenuMatcherFactory create(this);
AddMatchers({create.Char('}')});
AddMatchers({
create.Char('}'),
});
}
protected:
@ -175,7 +177,9 @@ namespace menu::item_scope_sequences
{
const MenuMatcherFactory create(this);
AddMatchers({create.Char(';')});
AddMatchers({
create.Char(';'),
});
}
protected:
@ -193,12 +197,17 @@ namespace menu::item_scope_sequences
const MenuMatcherFactory create(this);
AddLabeledMatchers(MenuExpressionMatchers().Expression(this), MenuExpressionMatchers::LABEL_EXPRESSION);
AddMatchers({create.KeywordIgnoreCase("rect"),
create.NumericExpression(), // x
create.NumericExpression(), // y
create.NumericExpression(), // w
create.NumericExpression(), // h
create.Optional(create.And({create.Integer().Capture(CAPTURE_ALIGN_HORIZONTAL), create.Integer().Capture(CAPTURE_ALIGN_VERTICAL)}))});
AddMatchers({
create.KeywordIgnoreCase("rect"),
create.NumericExpression(), // x
create.NumericExpression(), // y
create.NumericExpression(), // w
create.NumericExpression(), // h
create.Optional(create.And({
create.Integer().Capture(CAPTURE_ALIGN_HORIZONTAL),
create.Integer().Capture(CAPTURE_ALIGN_VERTICAL),
})),
});
}
protected:
@ -233,7 +242,7 @@ namespace menu::item_scope_sequences
AddMatchers({
create.KeywordIgnoreCase("origin"),
create.NumericExpression(), // x
create.NumericExpression() // y
create.NumericExpression(), // y
});
}
@ -298,8 +307,13 @@ namespace menu::item_scope_sequences
AddMatchers({
create.KeywordIgnoreCase(std::move(keyName)).Capture(CAPTURE_FIRST_TOKEN),
create.Char('{'),
create.Optional(create.And(
{create.Text().Capture(CAPTURE_VALUE), create.OptionalLoop(create.And({create.Char(';'), create.Text().Capture(CAPTURE_VALUE)}))})),
create.Optional(create.And({
create.Text().Capture(CAPTURE_VALUE),
create.OptionalLoop(create.And({
create.Char(';'),
create.Text().Capture(CAPTURE_VALUE),
})),
})),
create.Char('}'),
});
}
@ -364,15 +378,17 @@ namespace menu::item_scope_sequences
{
const MenuMatcherFactory create(this);
AddMatchers({create.KeywordIgnoreCase("dvarStrList").Capture(CAPTURE_FIRST_TOKEN),
create.Char('{'),
create.OptionalLoop(create.And({
create.TextNoChain().Capture(CAPTURE_STEP_NAME),
create.Optional(create.Char(';')),
create.TextNoChain().Capture(CAPTURE_STEP_VALUE),
create.Optional(create.Char(';')),
})),
create.Char('}')});
AddMatchers({
create.KeywordIgnoreCase("dvarStrList").Capture(CAPTURE_FIRST_TOKEN),
create.Char('{'),
create.OptionalLoop(create.And({
create.TextNoChain().Capture(CAPTURE_STEP_NAME),
create.Optional(create.Char(';')),
create.TextNoChain().Capture(CAPTURE_STEP_VALUE),
create.Optional(create.Char(';')),
})),
create.Char('}'),
});
}
protected:
@ -402,15 +418,17 @@ namespace menu::item_scope_sequences
const MenuMatcherFactory create(this);
AddLabeledMatchers(MenuExpressionMatchers().Expression(this), MenuExpressionMatchers::LABEL_EXPRESSION);
AddMatchers({create.KeywordIgnoreCase("dvarFloatList").Capture(CAPTURE_FIRST_TOKEN),
create.Char('{'),
create.OptionalLoop(create.And({
create.Text().Capture(CAPTURE_STEP_NAME),
create.Optional(create.Char(';')),
create.NumericExpression(),
create.Optional(create.Char(';')),
})),
create.Char('}')});
AddMatchers({
create.KeywordIgnoreCase("dvarFloatList").Capture(CAPTURE_FIRST_TOKEN),
create.Char('{'),
create.OptionalLoop(create.And({
create.Text().Capture(CAPTURE_STEP_NAME),
create.Optional(create.Char(';')),
create.NumericExpression(),
create.Optional(create.Char(';')),
})),
create.Char('}'),
});
}
protected:
@ -485,12 +503,14 @@ namespace menu::item_scope_sequences
const auto& listBoxFeatures = state->m_current_item->m_list_box_features;
while (result.HasNextCapture(CAPTURE_X_POS))
{
CommonItemFeaturesListBox::Column column{result.NextCapture(CAPTURE_X_POS).IntegerValue(),
state->m_feature_level == FeatureLevel::IW5 ? result.NextCapture(CAPTURE_Y_POS).IntegerValue() : 0,
result.NextCapture(CAPTURE_WIDTH).IntegerValue(),
state->m_feature_level == FeatureLevel::IW5 ? result.NextCapture(CAPTURE_HEIGHT).IntegerValue() : 0,
result.NextCapture(CAPTURE_MAX_CHARS).IntegerValue(),
result.NextCapture(CAPTURE_ALIGNMENT).IntegerValue()};
CommonItemFeaturesListBox::Column column{
result.NextCapture(CAPTURE_X_POS).IntegerValue(),
state->m_feature_level == FeatureLevel::IW5 ? result.NextCapture(CAPTURE_Y_POS).IntegerValue() : 0,
result.NextCapture(CAPTURE_WIDTH).IntegerValue(),
state->m_feature_level == FeatureLevel::IW5 ? result.NextCapture(CAPTURE_HEIGHT).IntegerValue() : 0,
result.NextCapture(CAPTURE_MAX_CHARS).IntegerValue(),
result.NextCapture(CAPTURE_ALIGNMENT).IntegerValue(),
};
listBoxFeatures->m_columns.emplace_back(column);
}
}
@ -505,7 +525,11 @@ namespace menu::item_scope_sequences
{
const MenuMatcherFactory create(this);
AddMatchers({create.KeywordIgnoreCase("execKey"), create.StringChain().Capture(CAPTURE_KEY), create.Char('{')});
AddMatchers({
create.KeywordIgnoreCase("execKey"),
create.StringChain().Capture(CAPTURE_KEY),
create.Char('{'),
});
}
protected:
@ -537,7 +561,11 @@ namespace menu::item_scope_sequences
{
const MenuMatcherFactory create(this);
AddMatchers({create.KeywordIgnoreCase("execKeyInt"), create.Integer().Capture(CAPTURE_KEY), create.Char('{')});
AddMatchers({
create.KeywordIgnoreCase("execKeyInt"),
create.Integer().Capture(CAPTURE_KEY),
create.Char('{'),
});
}
protected:

View File

@ -28,7 +28,9 @@ namespace menu::menu_scope_sequences
{
const MenuMatcherFactory create(this);
AddMatchers({create.Char('}').Capture(CAPTURE_TOKEN)});
AddMatchers({
create.Char('}').Capture(CAPTURE_TOKEN),
});
}
protected:
@ -59,7 +61,9 @@ namespace menu::menu_scope_sequences
{
const MenuMatcherFactory create(this);
AddMatchers({create.Char(';')});
AddMatchers({
create.Char(';'),
});
}
protected:
@ -75,7 +79,10 @@ namespace menu::menu_scope_sequences
{
const MenuMatcherFactory create(this);
AddMatchers({create.Keyword("itemDef"), create.Char('{')});
AddMatchers({
create.Keyword("itemDef"),
create.Char('{'),
});
}
protected:
@ -98,12 +105,17 @@ namespace menu::menu_scope_sequences
const MenuMatcherFactory create(this);
AddLabeledMatchers(MenuExpressionMatchers().Expression(this), MenuExpressionMatchers::LABEL_EXPRESSION);
AddMatchers({create.KeywordIgnoreCase("rect"),
create.NumericExpression(), // x
create.NumericExpression(), // y
create.NumericExpression(), // w
create.NumericExpression(), // h
create.Optional(create.And({create.Integer().Capture(CAPTURE_ALIGN_HORIZONTAL), create.Integer().Capture(CAPTURE_ALIGN_VERTICAL)}))});
AddMatchers({
create.KeywordIgnoreCase("rect"),
create.NumericExpression(), // x
create.NumericExpression(), // y
create.NumericExpression(), // w
create.NumericExpression(), // h
create.Optional(create.And({
create.Integer().Capture(CAPTURE_ALIGN_HORIZONTAL),
create.Integer().Capture(CAPTURE_ALIGN_VERTICAL),
})),
});
}
protected:
@ -136,7 +148,11 @@ namespace menu::menu_scope_sequences
{
const MenuMatcherFactory create(this);
AddMatchers({create.KeywordIgnoreCase("execKey"), create.StringChain().Capture(CAPTURE_KEY), create.Char('{')});
AddMatchers({
create.KeywordIgnoreCase("execKey"),
create.StringChain().Capture(CAPTURE_KEY),
create.Char('{'),
});
}
protected:
@ -168,7 +184,11 @@ namespace menu::menu_scope_sequences
{
const MenuMatcherFactory create(this);
AddMatchers({create.KeywordIgnoreCase("execKeyInt"), create.Integer().Capture(CAPTURE_KEY), create.Char('{')});
AddMatchers({
create.KeywordIgnoreCase("execKeyInt"),
create.Integer().Capture(CAPTURE_KEY),
create.Char('{'),
});
}
protected:

View File

@ -14,7 +14,9 @@ namespace menu::no_scope_sequences
{
const MenuMatcherFactory create(this);
AddMatchers({create.Char('{')});
AddMatchers({
create.Char('{'),
});
}
protected: