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


13.2 Creating a new grammar

Function: Marpa_Grammar marpa_g_new ( Marpa_Config* configuration )

[Constructor] 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. (See marpa_c_error().) 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 hard failure, NULL. Also on hard failure, if the configuration argument is not NULL, the error code is set in configuration. The error code may be accessed using marpa_c_error().

Function: int marpa_g_force_valued ( Marpa_Grammar g )

[Mutator] 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, whose value is otherwise indeterminate. On failure, -2.