Module parser

Source
Expand description

A submodule that handles save file parsing

Re-exportsยง

pub use game_object::ConversionError;
pub use game_object::GameObjectCollection;
pub use game_object::GameObjectMap;
pub use game_object::GameObjectMapping;
pub use game_object::KeyError;
pub use game_object::SaveFileObject;
pub use game_object::SaveFileValue;
pub use game_object::SaveObjectError;
pub use save_file::SaveFile;
pub use save_file::SaveFileError;
pub use section::Section;
pub use section::SectionError;
pub use section_reader::yield_section;
pub use game_state::GameRef;
pub use game_state::GameState;

Modulesยง

game_object ๐Ÿ”’
A submodule that provides the parser output objects. The parser uses GameObject to store the parsed data and structures in structures are initialized from these objects. This is our workaround for the lack of reflection in Rust, and it puts one more layer of abstraction between the parser and the structures. Jomini style would be to have the structures directly initialized from the token tape, but that wouldnโ€™t play well with the way we store everything in a central GameState object.
game_state ๐Ÿ”’
A submodule that provides the GameState object, which is used as a sort of a dictionary. CK3 save files have a myriad of different objects that reference each other, and in order to allow for centralized storage and easy access, the GameState object is used.
save_file ๐Ÿ”’
A submodule that provides the SaveFile object, which is used to store the entire save file. This is essentially the front-end of the parser, handling the IO and the such.
section ๐Ÿ”’
A submodule that provides the Section object, which allows the user to choose which sections should be parsed.
section_reader ๐Ÿ”’
A submodule that provides the yield_section function, which is used to iterate over the save file and return the next section.
tokens ๐Ÿ”’
A submodule providing ironman token declarations.
types ๐Ÿ”’
A submodule that provides [jomini] abstractions. This allows us to create an intermediate parsing interface with objects like SaveFile and Section that hold these abstractions, however hiding if the save file is binary or text. Thanks to this a user doesnโ€™t have to write boilerplate code to handle both types of save files.

Enumsยง

ParsingError
An error that occurred somewhere within the broadly defined parsing process.

Functionsยง

process_section
A function that processes a section of the save file. Based on the given section, it will update the GameState object and the Player vector. The GameState object is used to store all the data from the save file, while the Player vector is used to store the player data. Essentially the fasade of the parser, that makes the choices on which sections to parse and how to parse them.