mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:27:44 +00:00
LibCpp: Add preprocessor option to ignore unsupported keywords
Under some circumstances we need to ignore unsupported preprocessor keywords instead of crashing the processing, for example during live parsing in HackStudio.
This commit is contained in:
parent
711a47b784
commit
0b5d414eba
2 changed files with 11 additions and 2 deletions
|
@ -184,8 +184,11 @@ void Preprocessor::handle_preprocessor_line(const StringView& line)
|
|||
lexer.consume_all();
|
||||
return;
|
||||
}
|
||||
dbgln("Unsupported preprocessor keyword: {}", keyword);
|
||||
VERIFY_NOT_REACHED();
|
||||
|
||||
if (!m_options.ignore_unsupported_keywords) {
|
||||
dbgln("Unsupported preprocessor keyword: {}", keyword);
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
const String& Preprocessor::processed_text()
|
||||
|
|
|
@ -52,6 +52,8 @@ public:
|
|||
|
||||
const Definitions& definitions() const { return m_definitions; }
|
||||
|
||||
void set_ignore_unsupported_keywords(bool ignore) { m_options.ignore_unsupported_keywords = ignore; }
|
||||
|
||||
private:
|
||||
void handle_preprocessor_line(const StringView&);
|
||||
|
||||
|
@ -74,5 +76,9 @@ private:
|
|||
|
||||
Vector<StringView> m_included_paths;
|
||||
String m_processed_text;
|
||||
|
||||
struct Options {
|
||||
bool ignore_unsupported_keywords { false };
|
||||
} m_options;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue