Next: Rule methods, Previous: Grammar reference counting, Up: Grammar methods [Contents][Index]
[Accessor] When successful, returns the ID of the start symbol.
Soft fails, if there is no start symbol.
The start symbol is set by the
marpa_g_start_symbol_set()
call.
Return value: On success, the ID of the start symbol, which is always a non-negative number. On soft failure, -1. On hard failure, -2.
[Mutator] When successful, sets the start symbol of grammar g to symbol sym_id. Soft fails if sym_id is well-formed (a non-negative integer), but a symbol with that ID does not exist.
Return value: On success, sym_id, which will always be a non-negative number. On soft failure, -1. On hard failure, -2.
[Accessor] Return value: On success, the numerically largest symbol ID of g. On hard failure, -2.
[Accessor] A symbol is accessible if it can be reached from the start symbol. Soft fails if sym_id is well-formed (a non-negative integer), but a symbol with that ID does not exist. A common hard failure is calling this method with a grammar that is not precomputed.
Return value: On success, 1 if symbol sym_id is accessible, 0 if not. On soft failure, -1. On hard failure, -2.
[Accessor] A symbol is nullable if it sometimes produces the empty string. A nulling symbol is always a nullable symbol, but not all nullable symbols are nulling symbols. Soft fails if sym_id is well-formed (a non-negative integer), but a symbol with that ID does not exist. A common hard failure is calling this method with a grammar that is not precomputed.
Return value: On success, 1 if symbol sym_id is nullable, 0 if not. On soft failure, -1. On hard failure, -2.
[Accessor] A symbol is nulling if it always produces the empty string. Soft fails if sym_id is well-formed (a non-negative integer), but a symbol with that ID does not exist. A common hard failure is calling this method with a grammar that is not precomputed.
Return value: On success, 1 if symbol sym_id is nulling, 0 if not. On soft failure, -1. On hard failure, -2.
[Accessor] A symbol is productive if it can produce a string of terminals. All nullable symbols are considered productive. Soft fails if sym_id is well-formed (a non-negative integer), but a symbol with that ID does not exist. A common hard failure is calling this method with a grammar that is not precomputed.
Return value: On success, 1 if symbol sym_id is productive, 0 if not. On soft failure, -1. On hard failure, -2.
[Accessor] On success, if sym_id is the start symbol, returns 1. On success, if sym_id is not the start symbol, returns 0. On success, if no start symbol has been set, returns 0. is the start symbol.
Soft fails if sym_id is well-formed (a non-negative integer), but a symbol with that ID does not exist.
Return value: On success, 1 or 0. On soft failure, -1. On hard failure, -2.
[Accessor] On succcess, returns the “terminal status” of a sym_id.
The terminal status is 1 if sym_id is a terminal,
0 otherwise.
To be used as an input symbol
in the
marpa_r_alternative()
method,
a symbol must be a terminal.
By default, a symbol is a terminal if and only if it
does not appear on the LHS of any rule.
The terminal status can be set explicitly with the
marpa_g_symbol_is_terminal_set()
method.
See marpa_g_symbol_is_terminal_set().
Soft fails if sym_id is well-formed (a non-negative integer), but a symbol with that ID does not exist.
Return value: On success, 1 or 0. On soft failure, -1. On hard failure, -2.
[Mutator] Sets the “terminal status” of a symbol.
This function flags symbol sym_id as a terminal if
value is 1,
or flags it as a non-terminal if value is 0.
To be used as an input symbol
in the
marpa_r_alternative()
method,
a symbol must be a terminal.
On success, this method returns value.
Once set to a value with this method,
the terminal status of a symbol is “locked” at that value.
A subsequent call to this method
that attempts
to change the terminal status
of sym_id to a value different from its current one
will hard fail
with error code MARPA_ERR_TERMINAL_IS_LOCKED
.
Other hard failures include
when value is not 0 or 1;
and
when the grammar g is precomputed.
By default, a symbol is a terminal if and only if it does not appear on the LHS of any rule. An attempt to flag a nulling symbol as a terminal will cause a failure, but this is not necessarily detected before precomputation.
Return value: On success, value, which will be 1 or 0. On soft failure, -1. On hard failure, -2.
[Mutator] When successful, creates a new symbol in grammar g.
Return value: On success, the ID of the new symbol; which will be a non-negative integer. On hard failure, -2.
Next: Rule methods, Previous: Grammar reference counting, Up: Grammar methods [Contents][Index]