Next: , Previous: , Up: Grammar methods   [Contents]


11.2 Creating a new grammar

Function: Marpa_Grammar marpa_g_new ( Marpa_Config* configuration )

Creates a new grammar time object. The returned grammar object is not yet precomputed, and will have no symbols and rules. Its reference count will be 1.

Unless the application calls marpa_c_error, Libmarpa will not reference the location pointed to by the configuration argument after marpa_g_new returns. The configuration argument may be NULL, but if it is, there will be no way to determine the error code on failure.

Return value: On success, the grammar object. On failure, NULL, and the error code is set in configuration.

Function: int marpa_g_force_valued ( Marpa_Grammar g )

It is recommended that this call be made immediately after the grammar constructor. It turns off a deprecated feature.

The marpa_g_force_valued forces all the symbols in a grammar to be “valued”. The opposite of a valued symbol is one about whose value you do not care. This distinction has been made in the past in hope of gaining efficiencies at evaluation time. Current thinking is that the gains do not repay the extra complexity.

Return value: On success, a non-negative integer. On failure, a negative integer.