Next: , Previous: , Up: Top   [Contents][Index]


17 Configuration methods

The configuration object is intended for future extensions. Currently, the only function of the Marpa_Config class is to give marpa_g_new() a place to put its error code.

Marpa_Config is Libmarpa’s only “major” class which is not a time class. There is no constructor or destructor, although Marpa_Config objects do need to be initialized before use. Aside from its own accessor, Marpa_Config objects are only used by marpa_g_new() and no reference to their location is kept in any of Libmarpa’s time objects. The intent is that it be convenient to have Marpa_Config objects in memory that might be deallocated soon after marpa_g_new() returns. For example, they could be put on the stack.

Mutator function: int marpa_c_init ( Marpa_Config* config)

Initialize the config information to “safe” default values. An irrecoverable error will result if an uninitialized configuration is used to create a grammar.

Return value: Always succeeds. The return value is unspecified.

Accessor function: Marpa_Error_Code marpa_c_error ( Marpa_Config* config, const char** p_error_string )

Error codes are usually kept in the base grammar, which leaves marpa_g_new() no place to put its error code on failure. Objects of the Marpa_Config class provide such a place. p_error_string is reserved for use by the internals. Applications should set it to NULL.

Return value: The error code in config. Always succeeds, so that marpa_c_error() never requires an error code for itself.