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


13.7 Rank methods

Function: Marpa_Rank marpa_g_rule_rank ( Marpa_Grammar g, Marpa_Rule_ID rule_id)

[Accessor] When successful, returns the rank of the rule with ID rule_id. When a rule is created, its rank is initialized to the default rank of the grammar. The default rank of the grammar is 0.

Return value: On success, returns a rule rank, and sets the error code to MARPA_ERR_NONE. The rule rank is an integer. On hard failure, returns -2, and sets the error code to an appropriate value, which will never be MARPA_ERR_NONE. Note that -2 is a valid rule rank, so that when -2 is returned, the error code is the only way to distinguish success from failure. The error code can be determined using marpa_g_error(). See marpa_g_error().

Function: Marpa_Rank marpa_g_rule_rank_set ( Marpa_Grammar g, Marpa_Rule_ID rule_id, Marpa_Rank rank)

[Mutator] When successful, sets the rank of the rule with ID rule_id to rank and returns rank.

Return value: On success, returns rank, which will be an integer, and sets the error code to MARPA_ERR_NONE. On hard failure, returns -2, and sets the error code to an appropriate value, which will never be MARPA_ERR_NONE. Note that -2 is a valid rule rank, so that when -2 is returned, the error code is the only way to distinguish success from failure. The error code can be determined using marpa_g_error(). See marpa_g_error().

Function: int marpa_g_rule_null_high ( Marpa_Grammar g, Marpa_Rule_ID rule_id)

[Accessor] On success, returns a boolean whose value is 1 iff “null ranks high” is set in the rule with ID rule_id. When a rule is created, it has “null ranks high” set.

For more on the “null ranks high” setting, read the description of marpa_g_rule_null_high_set(). See marpa_g_rule_null_high_set().

Soft fails iff rule_id is well-formed (a non-negative integer), but a rule with that ID does not exist.

Return value: On success, a boolean. On soft failure, -1. On hard failure, -2.

Function: int marpa_g_rule_null_high_set ( Marpa_Grammar g, Marpa_Rule_ID rule_id, int flag)

[Mutator] On success,

The “null ranks high” setting affects the ranking of rules with properly nullable symbols on their right hand side. If a rule has properly nullable symbols on its RHS, each instance in which it appears in a parse will have a pattern of nulled and non-nulled symbols. Such a pattern is called a “null variant”.

If the “null ranks high” is set, nulled symbols rank high. If the “null ranks high” is unset is the default), nulled symbols rank low. Ranking of a null variants is done from left-to-right.

Soft fails iff rule_id is well-formed (a non-negative integer), but a rule with that ID does not exist.

Hard fails if the grammar has been precomputed.

Return value: On success, a boolean. On soft failure, -1. On hard failure, -2.


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