Next: Grammar reference counting, Previous: Grammar overview, Up: Grammar methods [Contents][Index]
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()
.
It is recommended that this call be made immediately after the grammar constructor. It turns off a deprecated feature.
The
marpa_g_force_valued()
method
forces all the
symbols in a grammar to be “valued”.
The parse cares about the value of the symbol iff
the symbol is “valued”.
In the past, symbols were allowed to be “unvalued”
in the hope of gaining efficiencies at evaluation time.
Use of unvalued symbols is now deprecated,
because current thinking is that the gains do not repay the extra
complexity.
Return value: On success, a non-negative integer, whose value is otherwise unspecified. On failure, -2.