VapourSynth-llvmexpr
Loading...
Searching...
No Matches
infix2postfix::Preprocessor Class Reference

#include <llvmexpr/frontend/infix2postfix/Preprocessor.hpp>

Classes

class  Impl

Public Member Functions

 Preprocessor (std::string source)
 ~Preprocessor ()
 Preprocessor (const Preprocessor &)=delete
Preprocessoroperator= (const Preprocessor &)=delete
 Preprocessor (Preprocessor &&)=delete
Preprocessoroperator= (Preprocessor &&)=delete
void addPredefinedMacro (std::string name, const std::string &value="")
PreprocessResult process ()

Static Public Member Functions

static std::string formatDiagnosticWithExpansion (const std::string &message, int line, const std::vector< LineMapping > &line_map)
static std::string formatMacroExpansions (const std::vector< LineMapping > &line_map)

Detailed Description

Definition at line 65 of file Preprocessor.hpp.

Constructor & Destructor Documentation

◆ Preprocessor() [1/3]

infix2postfix::Preprocessor::Preprocessor ( std::string source)
explicit

Definition at line 2378 of file Preprocessor.cpp.

2379 : impl(std::make_unique<Impl>(std::move(source))) {}

Referenced by operator=(), operator=(), Preprocessor(), and Preprocessor().

◆ ~Preprocessor()

infix2postfix::Preprocessor::~Preprocessor ( )
default

◆ Preprocessor() [2/3]

infix2postfix::Preprocessor::Preprocessor ( const Preprocessor & )
delete

References Preprocessor().

◆ Preprocessor() [3/3]

infix2postfix::Preprocessor::Preprocessor ( Preprocessor && )
delete

References Preprocessor().

Member Function Documentation

◆ addPredefinedMacro()

void infix2postfix::Preprocessor::addPredefinedMacro ( std::string name,
const std::string & value = "" )

Definition at line 2383 of file Preprocessor.cpp.

2384 {
2385 impl->addPredefinedMacro(std::move(name), value);
2386}

Referenced by convert_infix_to_postfix().

◆ formatDiagnosticWithExpansion()

std::string infix2postfix::Preprocessor::formatDiagnosticWithExpansion ( const std::string & message,
int line,
const std::vector< LineMapping > & line_map )
static

Definition at line 2390 of file Preprocessor.cpp.

2392 {
2393
2394 const LineMapping* mapping = nullptr;
2395 for (const auto& m : line_map) {
2396 if (m.preprocessed_line == line) {
2397 mapping = &m;
2398 break;
2399 }
2400 }
2401
2402 if (mapping == nullptr || mapping->expansions.empty()) {
2403 return message;
2404 }
2405
2406 std::string result = message;
2407 result += "\n Macro expansion trace:";
2408
2409 for (const auto& expansion : mapping->expansions) {
2410 result += std::format("\n {}:{}: in expansion of macro '{}'",
2411 expansion.original_line,
2412 expansion.original_column, expansion.macro_name);
2413 if (!expansion.replacement_text.empty()) {
2414 result += std::format(" -> '{}'", expansion.replacement_text);
2415 }
2416 }
2417
2418 return result;
2419}

References infix2postfix::LineMapping::expansions.

◆ formatMacroExpansions()

std::string infix2postfix::Preprocessor::formatMacroExpansions ( const std::vector< LineMapping > & line_map)
static

Definition at line 2422 of file Preprocessor.cpp.

2422 {
2423 std::string result;
2424
2425 for (const auto& mapping : line_map) {
2426 if (!mapping.expansions.empty()) {
2427 for (const auto& expansion : mapping.expansions) {
2428 result += std::format(
2429 "Line {} (original line {}:{}): macro '{}' expanded to "
2430 "'{}'\n",
2431 mapping.preprocessed_line, expansion.original_line,
2432 expansion.original_column, expansion.macro_name,
2433 expansion.replacement_text.empty()
2434 ? "(empty)"
2435 : expansion.replacement_text);
2436 }
2437 }
2438 }
2439
2440 return result;
2441}

Referenced by main().

◆ operator=() [1/2]

Preprocessor & infix2postfix::Preprocessor::operator= ( const Preprocessor & )
delete

References Preprocessor().

◆ operator=() [2/2]

Preprocessor & infix2postfix::Preprocessor::operator= ( Preprocessor && )
delete

References Preprocessor().

◆ process()

PreprocessResult infix2postfix::Preprocessor::process ( )

Definition at line 2388 of file Preprocessor.cpp.

2388{ return impl->process(); }

Referenced by convert_infix_to_postfix().


The documentation for this class was generated from the following files: