| 144 | return append_string(std::move(source_code), path); |
| 145 | } |
| 146 | bool reshadefx::preprocessor::append_string(std::string source_code, const std::filesystem::path &path) |
| 147 | { |
| 148 | // Enforce all input strings to end with a line feed |
| 149 | if (source_code.empty() || source_code.back() != '\n') |
| 150 | return false; |
| 151 | |
| 152 | // Only consider new errors added below for the success of this call |
| 153 | const size_t errors_offset = _errors.length(); |
| 154 | |
| 155 | // Give this push a name, so that lexer location starts at a new line |
| 156 | // This is necessary in case this string starts with a preprocessor directive, since the lexer only reports those as such if they appear at the beginning of a new line |
| 157 | // But without a name, the lexer location is set to the last token location, which most likely will not be at the start of the line |
| 158 | push(std::move(source_code), path.empty() ? "unknown" : path.u8string()); |
| 159 | parse(); |
| 160 | |
| 161 | return _errors.find(": preprocessor error: ", errors_offset) == std::string::npos; |
| 162 | } |
| 163 | |
| 164 | std::vector<std::filesystem::path> reshadefx::preprocessor::included_files() const |
| 165 | { |