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


21.1.1 Ranking methods

Function: Marpa_Rank marpa_g_default_rank_set ( Marpa_Grammar g, Marpa_Rank rank)
Function: Marpa_Rank marpa_g_default_rank ( Marpa_Grammar g)

These methods, respectively, set and query the default rank of the grammar. When a grammar is created, the default rank is 0. When rules and symbols are created, their rank is the default rank of the grammar.

Changing the grammar’s default rank does not affect those rules and symbols already created, only those that will be created. This means that the grammar’s default rank can be used to, in effect, assign ranks to groups of rules and symbols. Applications may find this behavior useful.

Return value: On success, returns the rank after the call, and sets the error code to MARPA_ERR_NONE. On failure, returns -2, and sets the error code to an appropriate value, which will never be MARPA_ERR_NONE. Note that when the rank is -2, the error code is the only way to distinguish success from failure. The error code can be determined by using the marpa_g_error() call.

Function: Marpa_Rank marpa_g_symbol_rank_set ( Marpa_Grammar g, Marpa_Symbol_ID sym_id, Marpa_Rank rank)
Function: Marpa_Rank marpa_g_symbol_rank ( Marpa_Grammar g, Marpa_Symbol_ID sym_id)

These methods, respectively, set and query the rank of a symbol sym_id. When sym_id is created, its rank initialized to the default rank of the grammar.

Return value: On success, returns the rank after the call, and sets the error code to MARPA_ERR_NONE. On failure, returns -2, and sets the error code to an appropriate value, which will never be MARPA_ERR_NONE. Note that when the rank is -2, the error code is the only way to distinguish success from failure. The error code can be determined by using the marpa_g_error() call.


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