libsapling  0.8.0
Typedefs | Functions
grammar.h File Reference

Grammar implementation. More...

#include "libsapling/dm/graph.h"

Go to the source code of this file.

Typedefs

typedef struct grammar * grammar_t
 

Functions

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

Detailed Description

Grammar implementation.

Function Documentation

◆ grammar__is_terminal()

int grammar__is_terminal ( grammar_t  g,
int  symbol 
)

Returns whether the symbol is a terminal in the grammar.

Returns
whether the symbol is a terminal in the grammar.

◆ grammar__num_nonterminals()

int grammar__num_nonterminals ( grammar_t  g)

Returns the number of nonterminals in the grammar.

Returns
the number of nonterminals in the grammar.

◆ grammar__num_symbols()

int grammar__num_symbols ( grammar_t  g)

Returns the sum of the number of terminals and nonterminals in the grammar.

Returns
the sum of the number of terminals and nonterminals in the grammar.

◆ grammar__num_terminals()

int grammar__num_terminals ( grammar_t  g)

Returns the number of terminals in the grammar.

Returns
the number of terminals in the grammar.

◆ grammar__productions()

node_t* grammar__productions ( grammar_t  g)

Returns the grammar's path of productions.

Returns
the grammar's path of productions.

◆ new_grammar()

grammar_t new_grammar ( node_t *  productions,
int  num_terminals,
int  num_symbols 
)

Allocates a new grammar on the heap.

Parameters
productionsPath of productions.
num_terminalsNumber of terminals.
num_symbolsSum of the number of terminal and nonterminal symbols.
Returns
pointer to the allocated grammar.