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


18.4 Symbol methods

Accessor function: Marpa_Symbol_ID marpa_g_start_symbol (Marpa_Grammar g)

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 integer. On soft failure, -1. On hard failure, -2.

Mutator function: Marpa_Symbol_ID marpa_g_start_symbol_set ( Marpa_Grammar g, Marpa_Symbol_ID sym_id)

When successful, sets the start symbol of grammar g to symbol sym_id. Soft fails iff 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 integer. On soft failure, -1. On hard failure, -2.

Accessor function: int marpa_g_highest_symbol_id (Marpa_Grammar g)

Return value: On success, the maximum symbol ID of g. On hard failure, -2.

Accessor function: int marpa_g_symbol_is_accessible (Marpa_Grammar g, Marpa_Symbol_ID sym_id)

Soft fails iff 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 function: int marpa_g_symbol_is_nullable ( Marpa_Grammar g, Marpa_Symbol_ID sym_id)

Soft fails iff 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 function: int marpa_g_symbol_is_nulling (Marpa_Grammar g, Marpa_Symbol_ID sym_id)

Soft fails iff 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 function: int marpa_g_symbol_is_productive (Marpa_Grammar g, Marpa_Symbol_ID sym_id)

Soft fails iff 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 function: int marpa_g_symbol_is_start ( Marpa_Grammar g, Marpa_Symbol_ID sym_id)

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.

Soft fails iff 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 function: int marpa_g_symbol_is_terminal ( Marpa_Grammar g, Marpa_Symbol_ID sym_id)

On success, if sym_id is a terminal symbol, returns 1. On success, if sym_id is not a terminal symbol, returns 0. To be used as an input symbol in the marpa_r_alternative() method, a symbol must be a terminal.

Soft fails iff 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 function: Marpa_Symbol_ID marpa_g_symbol_new (Marpa_Grammar g)

When successful, creates a new symbol in grammar g, and returns the ID of the new symbol. The symbol ID’s are non-negative integers. Within each grammar, a symbol’s ID is unique to that symbol.

Symbols are numbered consecutively, starting at 0. That is, the first successful call of this method for a grammar returns the symbol ID 0. The second and later successful calls of marpa_g_symbol_new(), return the symbol ID n+1, where n is the symbol ID returned by the previous successful call of marpa_g_symbol_new(). This makes it convenient for applications to store additional information about the symbols in an array.

Return value: On success, the ID of the new symbol, which will be a non-negative integer. On hard failure, -2.


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