1 #ifndef MSP_DATAFILE_PARSER_H_
2 #define MSP_DATAFILE_PARSER_H_
17 Frontend for loading datafiles. Handles switching between text and binary
18 formats. A Parser evaluates into a boolean value indicating whether more
19 statements may be read.
31 Parser(IO::Base &i, const std::string &s);
34 /** Reads a statement from the input. If the end of input was reached, an
35 empty invalid statement will be returned. If an error occurs, the parser
36 will be marked as bad and no more statements may be read, even if the
37 exception was caught. */
38 Statement parse(bool raw = false);
41 void process_control_statement(const Statement &);
44 /** Returns a key for the next statement, consisting of its keyword and
45 signature. Not supported in all modes. */
46 const StatementKey *peek(unsigned);
48 /** Parses a statement and feeds its arguments to an action. The action
49 must be appropriate for the statement. Use peek() to determine the
50 statement's signature. */
51 bool parse_and_load(unsigned, Loader &, const LoaderAction &);
53 operator bool() const { return good && in; }
56 } // namespace DataFile