#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <clan/symbol.h>
Functions | |
void | clan_symbol_print_structure (FILE *file, clan_symbol_p symbol, int level) |
void | clan_symbol_print (FILE *file, clan_symbol_p symbol) |
clan_symbol_p | clan_symbol_malloc () |
void | clan_symbol_free (clan_symbol_p symbol) |
clan_symbol_p | clan_symbol_lookup (clan_symbol_p symbol, char *identifier) |
clan_symbol_p | clan_symbol_add (clan_symbol_p *location, char *identifier, int type, int rank) |
void | clan_symbol_remove (clan_symbol_p *location, clan_symbol_p symbol) |
int | clan_symbol_get_rank (clan_symbol_p symbol, char *identifier) |
int | clan_symbol_get_type (clan_symbol_p symbol, char *identifier) |
char ** | clan_symbol_iterators (clan_symbol_p *symbols, int depth) |
char ** | clan_symbol_id_array (clan_symbol_p symbol, int type, int *size) |
Variables | |
int | symbol_nb_iterators = 0 |
int | symbol_nb_parameters = 0 |
int | symbol_nb_arrays = 0 |
int | symbol_nb_functions = 0 |
clan_symbol_p clan_symbol_add | ( | clan_symbol_p * | location, | |
char * | identifier, | |||
int | type, | |||
int | rank | |||
) |
clan_symbol_add function: This function adds a new clan_symbol_t in the symbol table whose address is provided as a parameter. If the symbol table is empty (NULL), the new node will become its first element. A new node is added only if an existing node with the same identifier does not already exist. It returns the pointer to the symbol table node corresponding to the identifier.
location | The address of the symbol table. | |
identifier | The identifier of the symbol we want to add. | |
type | The new symbol type | |
rank | The new symbol rank (depth if iterator, ignored otherwise) |
References clan_symbol_lookup(), clan_symbol_malloc(), clan_symbol::identifier, clan_symbol::next, clan_symbol::rank, symbol_nb_arrays, symbol_nb_functions, symbol_nb_iterators, symbol_nb_parameters, and clan_symbol::type.
Referenced by yyparse().
void clan_symbol_free | ( | clan_symbol_p | symbol | ) |
clan_symbol_free function: This function frees the allocated memory for a clan_symbol_t structure.
symbol | The pointer to the symbol we want to free. |
References clan_symbol::identifier, and clan_symbol::next.
Referenced by clan_parser_free_state().
int clan_symbol_get_rank | ( | clan_symbol_p | symbol, | |
char * | identifier | |||
) |
clan_symbol_get_rank function: This function returns the rank of the symbol with identifier "identifier" in the symbol table whose first element is "symbol". If the symbol with the specified identifier is not found, it returns -1.
symbol | The first node of the list of symbols. | |
identifier | The identifier we want to know the rank. |
References clan_symbol::identifier, clan_symbol::next, and clan_symbol::rank.
Referenced by clan_vector_term(), and yyparse().
int clan_symbol_get_type | ( | clan_symbol_p | symbol, | |
char * | identifier | |||
) |
clan_symbol_get_type function: This function returns the type of the symbol with identifier "identifier" in the symbol table whose first element is "symbol". If the symbol with the specified identifier is not found, it returns -1.
symbol | The first node of the list of symbols. | |
identifier | The identifier we want to know the type. |
References clan_symbol::identifier, clan_symbol::next, and clan_symbol::type.
Referenced by clan_vector_term().
char** clan_symbol_id_array | ( | clan_symbol_p | symbol, | |
int | type, | |||
int * | size | |||
) |
clan_symbol_id_array function: this function builds an array of identifier names of a given type thanks to the informations stored in the symbol table and returns it. The identifiers are sort according to their rank. It also returns the array size to the parameter "size".
symbol | The first element of the symbol table. | |
type | The type of interesting elements. | |
size | The returned array size (this is a _result_). |
References clan_symbol::identifier, clan_symbol::next, clan_symbol::rank, and clan_symbol::type.
Referenced by yyparse().
char** clan_symbol_iterators | ( | clan_symbol_p * | symbols, | |
int | depth | |||
) |
clan_symbol_iterators function: this function builds the array of original iterator names for the scoplib_statement_t structures thanks to the parser current state of parser_depth (depth) and parser_iterators (symbols). "symbols" is an array of references to symbol table entries, one for each loop enclosing the statement.
symbols | Array of iterator symbols for the statement. | |
depth | The depth of the statement. |
Referenced by yyparse().
clan_symbol_p clan_symbol_lookup | ( | clan_symbol_p | symbol, | |
char * | identifier | |||
) |
clan_symbol_lookup function: This function searches the symbol table for a symbol with the identifier provided as parameter. It returns the pointer to the symbol if it already exists inside the table, NULL otherwise.
symbol | The first node of the list of symbols. | |
identifier | The identifier we are looking for. |
References clan_symbol::identifier, and clan_symbol::next.
Referenced by clan_symbol_add(), and yyparse().
clan_symbol_p clan_symbol_malloc | ( | ) |
clan_symbol_malloc function: This function allocates the memory space for a clan_symbol_t structure and sets its fields with default values. Then it returns a pointer to the allocated space.
References clan_symbol::identifier, and clan_symbol::next.
Referenced by clan_symbol_add().
void clan_symbol_print | ( | FILE * | file, | |
clan_symbol_p | symbol | |||
) |
clan_symbol_print function: This function prints the content of a clan_symbol_t structure (*symbol) into a file (file, possibly stdout).
file | File where informations are printed. | |
symbol | The symbol whose information have to be printed. |
References clan_symbol_print_structure().
void clan_symbol_print_structure | ( | FILE * | file, | |
clan_symbol_p | symbol, | |||
int | level | |||
) |
clan_symbol_print_structure function: Displays a clan_symbol_t structure (*symbol) into a file (file, possibly stdout) in a way that trends to be understandable without falling in a deep depression or, for the lucky ones, getting a headache... It includes an indentation level (level) in order to work with others print_structure functions.
file | File where informations are printed. | |
symbol | The symbol whose information have to be printed. | |
level | Number of spaces before printing, for each line. |
References clan_symbol::identifier, clan_symbol::next, clan_symbol::rank, and clan_symbol::type.
Referenced by clan_symbol_print().
void clan_symbol_remove | ( | clan_symbol_p * | location, | |
clan_symbol_p | symbol | |||
) |
clan_symbol_remove function: Deletes a symbol from the list.
References clan_symbol::next.
Referenced by yyparse().
int symbol_nb_arrays = 0 |
Current number of array symbols
Referenced by clan_parser_initialize_state(), and clan_symbol_add().
int symbol_nb_functions = 0 |
Current number of function symbols
Referenced by clan_parser_initialize_state(), and clan_symbol_add().
int symbol_nb_iterators = 0 |
Current number of iterator symbols
Referenced by clan_parser_initialize_state(), and clan_symbol_add().
int symbol_nb_parameters = 0 |
Current number of parameter symbols
Referenced by clan_parser_initialize_state(), and clan_symbol_add().