Revert pattern language until it's stable again (#1468)
- Revert pattern language
This commit is contained in:
parent
ffc1aa6a91
commit
ad8e3e38f0
2
lib/external/pattern_language
vendored
2
lib/external/pattern_language
vendored
@ -1 +1 @@
|
||||
Subproject commit cbfcf0f1848e4283e00f7a6820ef54fdaaf74dd8
|
||||
Subproject commit 312dc93becd44f24105baad2574b8449f449e831
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
namespace hex {
|
||||
|
||||
|
@ -88,7 +88,7 @@ namespace hex::plugin::builtin::ui {
|
||||
std::optional<pl::core::Token::Literal> value;
|
||||
};
|
||||
|
||||
std::optional<Filter> parseRValueFilter(pl::PatternLanguage *runtime, const std::string &filter) const;
|
||||
std::optional<Filter> parseRValueFilter(const std::string &filter) const;
|
||||
|
||||
private:
|
||||
std::map<const pl::ptrn::Pattern*, u64> m_displayEnd;
|
||||
|
@ -133,7 +133,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
// Execute the inspector file
|
||||
if (!inspectorCode.empty()) {
|
||||
if (m_runtime.executeString(inspectorCode, pl::api::Source::DefaultSource, {}, inVariables, true)) {
|
||||
if (m_runtime.executeString(inspectorCode, {}, inVariables, true)) {
|
||||
|
||||
// Loop over patterns produced by the runtime
|
||||
const auto &patterns = m_runtime.getPatterns();
|
||||
|
@ -857,13 +857,14 @@ namespace hex::plugin::builtin {
|
||||
if (!file.isValid())
|
||||
continue;
|
||||
|
||||
try {
|
||||
auto &preprocessor = runtime.getInternals().preprocessor;
|
||||
|
||||
auto source = runtime.addVirtualSource(file.readString(), wolv::util::toUTF8String(file.getPath()));
|
||||
|
||||
auto result = preprocessor->preprocess(&runtime, source);
|
||||
if (result.hasErrs()) {
|
||||
log::warn("Failed to preprocess file {} during MIME analysis", entry.path().string());
|
||||
auto ret = preprocessor->preprocess(runtime, file.readString());
|
||||
if (!ret.has_value()) {
|
||||
log::warn("Failed to preprocess file {} during MIME analysis: {}", entry.path().string(), preprocessor->getError()->what());
|
||||
}
|
||||
} catch (pl::core::err::PreprocessorError::Exception &e) {
|
||||
log::warn("Failed to preprocess file {} during MIME analysis: {}", entry.path().string(), e.what());
|
||||
}
|
||||
|
||||
if (foundCorrectType)
|
||||
@ -959,7 +960,7 @@ namespace hex::plugin::builtin {
|
||||
m_runningParsers += 1;
|
||||
|
||||
ContentRegistry::PatternLanguage::configureRuntime(*m_parserRuntime, nullptr);
|
||||
auto ast = m_parserRuntime->parseString(code, pl::api::Source::DefaultSource);
|
||||
auto ast = m_parserRuntime->parseString(code);
|
||||
|
||||
auto &patternVariables = m_patternVariables.get(provider);
|
||||
|
||||
@ -1087,7 +1088,7 @@ namespace hex::plugin::builtin {
|
||||
};
|
||||
|
||||
|
||||
m_lastEvaluationResult = runtime.executeString(code, pl::api::Source::DefaultSource, envVars, inVariables);
|
||||
m_lastEvaluationResult = runtime.executeString(code, envVars, inVariables);
|
||||
if (!m_lastEvaluationResult) {
|
||||
*m_lastEvaluationError = runtime.getError();
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ namespace hex::plugin::builtin::ui {
|
||||
|
||||
}
|
||||
|
||||
std::optional<PatternDrawer::Filter> PatternDrawer::parseRValueFilter(pl::PatternLanguage *runtime, const std::string &filter) const {
|
||||
std::optional<PatternDrawer::Filter> PatternDrawer::parseRValueFilter(const std::string &filter) const {
|
||||
Filter result;
|
||||
|
||||
if (filter.empty()) {
|
||||
@ -162,16 +162,22 @@ namespace hex::plugin::builtin::ui {
|
||||
char c = filter[i];
|
||||
|
||||
if (i < filter.size() - 1 && c == '=' && filter[i + 1] == '=') {
|
||||
auto tokens = runtime->lexString(filter.substr(i + 2), pl::api::Source::DefaultSource);
|
||||
if (!tokens.has_value())
|
||||
try {
|
||||
pl::core::Lexer lexer;
|
||||
|
||||
auto source = filter.substr(i + 2);
|
||||
auto tokens = lexer.lex(filter.substr(i + 2), filter.substr(i + 2));
|
||||
|
||||
if (!tokens.has_value() || tokens->size() != 2)
|
||||
return std::nullopt;
|
||||
|
||||
auto literal = std::get_if<pl::core::Token::Literal>(&tokens->front().value);
|
||||
if (literal == nullptr)
|
||||
return std::nullopt;
|
||||
|
||||
result.value = *literal;
|
||||
|
||||
} catch (pl::core::err::LexerError &) {
|
||||
return std::nullopt;
|
||||
}
|
||||
break;
|
||||
} else if (c == '.')
|
||||
result.path.emplace_back();
|
||||
@ -1102,7 +1108,7 @@ namespace hex::plugin::builtin::ui {
|
||||
|
||||
ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x - ImGui::GetTextLineHeightWithSpacing() * 9.5);
|
||||
if (ImGuiExt::InputTextIcon("##Search", ICON_VS_FILTER, m_filterText)) {
|
||||
m_filter = parseRValueFilter(runtime, m_filterText).value_or(Filter{ });
|
||||
m_filter = parseRValueFilter(m_filterText).value_or(Filter{ });
|
||||
}
|
||||
ImGui::PopItemWidth();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user