30 const std::map<std::string, std::string>* predefined_macros,
31 int num_intermediate_inputs) {
33 std::string preprocessed_source = infix_expr;
34 std::vector<infix2postfix::LineMapping> line_map;
35 int library_line_count = 0;
37 if (predefined_macros !=
nullptr) {
40 for (
const auto& [name, value] : *predefined_macros) {
44 auto preprocess_result = preprocessor.
process();
46 if (!preprocess_result.success) {
47 std::string error_msg =
"Preprocessing errors:\n";
48 for (
const auto& error : preprocess_result.errors) {
49 error_msg += error +
"\n";
51 throw std::runtime_error(error_msg);
54 preprocessed_source = preprocess_result.
source;
55 line_map = preprocess_result.line_map;
56 library_line_count = preprocess_result.library_line_count;
63 num_intermediate_inputs, line_map,
69 throw std::runtime_error(diagnostics);
73 }
catch (
const std::exception& e) {
74 throw std::runtime_error(
75 std::format(
"Infix to postfix conversion error: {}", e.what()));
std::string convert_infix_to_postfix(const std::string &infix_expr, int num_inputs, infix2postfix::Mode mode, const std::map< std::string, std::string > *predefined_macros, int num_intermediate_inputs)
std::string formatDiagnostics() const
std::string generateCode()
PreprocessResult process()
void addPredefinedMacro(std::string name, const std::string &value="")
std::vector< Token > tokenize()