8#include <unordered_map>
11#include "gsl/pointers"
68 CParserFacade(std::filesystem::path file_path, gsl::not_null<const TextFormatter *> format);
81 std::filesystem::path file_path,
82 gsl::not_null<const TextFormatter *> format,
83 std::unordered_map<std::string, std::int64_t> seed_symbols);
133 return scan_warnings_;
179 parse_functions(
const std::optional<std::string> &name_prefix = std::nullopt);
324 [[nodiscard]]
const std::vector<std::string> &
file_lines()
const;
328 [[nodiscard]]
Parser make_seeded_parser(std::vector<Token> tokens);
330 std::filesystem::path file_path_;
332 std::unordered_map<std::string, std::int64_t> seed_symbols_;
333 std::vector<std::string> file_lines_;
334 std::string content_;
335 std::unique_ptr<CParserContext> context_;
337 bool load_failed_{
false};
338 FormattableError load_error_;
339 std::optional<std::vector<DefineStatement>> cached_defines_;
340 std::vector<std::string> scan_warnings_;
High-level facade for parsing C/C++ source files.
const std::vector< std::string > & file_lines() const
Returns the cached file lines.
ChainableResult< std::vector< IncbinDeclaration > > parse_incbin_arrays(const std::optional< std::string > &name_prefix=std::nullopt)
Parses INCBIN array declarations from the file.
ChainableResult< std::vector< EnumDeclaration > > parse_enums()
Parses all enum declarations from the file.
ChainableResult< std::vector< StructVariableDeclaration > > parse_struct_variables(const std::optional< std::string > &name_prefix=std::nullopt)
Parses struct variable declarations from the file.
ChainableResult< std::vector< DefineStatement > > parse_defines()
Parses all #define statements from the file.
ChainableResult< std::optional< DefineStatement > > find_define(const std::string &define_name)
Finds a specific #define statement by name.
ChainableResult< std::vector< StructDefinition > > parse_struct_definitions(const std::optional< std::string > &name_filter=std::nullopt)
Parses struct type definitions from the file.
const std::vector< std::string > & scan_warnings() const
Returns recoverable warnings accumulated across tolerant parse calls.
ChainableResult< TolerantDefineScan > parse_defines_tolerant()
Parses all #define statements, tolerating individual evaluation failures.
ChainableResult< std::vector< FunctionDefinition > > parse_functions(const std::optional< std::string > &name_prefix=std::nullopt)
Parses function definitions from the file.
ChainableResult< std::vector< IndexedArrayDeclaration > > parse_indexed_arrays(const std::optional< std::string > &name_prefix=std::nullopt)
Parses designated (indexed) array declarations from the file.
ChainableResult< std::vector< StructInitializerDeclaration > > parse_struct_initializers(const std::optional< std::string > &name_prefix=std::nullopt)
Parses struct variable declarations with their designated initializer fields.
ChainableResult< std::vector< ArrayDeclaration > > parse_pointer_arrays(const std::optional< std::string > &name_prefix=std::nullopt)
Parses all pointer array declarations from the file.
ChainableResult< TolerantEnumScan > parse_enums_tolerant()
Parses all enum declarations, tolerating individual member evaluation failures.
A result type that maintains a chainable sequence of errors for debugging and error reporting.
Parser for C preprocessor constructs.
Abstract base class for applying text styling with context-aware formatting.