1 #ifndef _LIBSAPLING_PARSER_GRAMMAR_H_
2 #define _LIBSAPLING_PARSER_GRAMMAR_H_
11 typedef struct grammar *grammar_t;
23 grammar_t
new_grammar(node_t *productions,
int num_terminals,
int num_symbols);
int grammar__num_terminals(grammar_t g)
Returns the number of terminals in the grammar.
node_t * grammar__productions(grammar_t g)
Returns the grammar's path of productions.
void delete_grammar(grammar_t g)
Frees the memory previously allocated on the heap for a grammar with new_grammar.
int grammar__is_terminal(grammar_t g, int symbol)
Returns whether the symbol is a terminal in the grammar.
int grammar__num_symbols(grammar_t g)
Returns the sum of the number of terminals and nonterminals in the grammar.
grammar_t new_grammar(node_t *productions, int num_terminals, int num_symbols)
Allocates a new grammar on the heap.
int grammar__num_nonterminals(grammar_t g)
Returns the number of nonterminals in the grammar.