Clan
0.8.0
|
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <osl/macros.h>
#include <osl/strings.h>
#include <osl/generic.h>
#include <osl/relation.h>
#include <osl/relation_list.h>
#include <osl/extensions/arrays.h>
#include <clan/macros.h>
#include <clan/symbol.h>
Go to the source code of this file.
clan_symbol_p clan_symbol_add | ( | clan_symbol_p * | table, |
char * | identifier, | ||
int | type | ||
) |
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.
[in,out] | table | The address of the symbol table. |
[in] | identifier | The identifier of the symbol we want to add. |
[in] | type | The new symbol type. |
Definition at line 301 of file symbol.c.
References clan_symbol_generate_new_key(), clan_symbol_lookup(), clan_symbol_malloc(), clan_symbol::identifier, clan_symbol::key, clan_symbol::next, and clan_symbol::type.
Referenced by clan_symbol_new_iterator(), and yyparse().
osl_strings_p clan_symbol_array_to_strings | ( | clan_symbol_p * | sarray, |
int | size | ||
) | [read] |
clan_symbol_array_to_strings function: this functions builds (and returns a pointer to) an osl_strings_t structure containing the symbol strings contained in an array of symbols of length nb. The symbol string order is the same as the one in the symbol array.
[in] | sarray | The symbol array. |
[in] | size | The size of the symbol array. |
Definition at line 399 of file symbol.c.
References CLAN_malloc.
Referenced by yyparse().
clan_symbol_p clan_symbol_clone_one | ( | clan_symbol_p | symbol | ) |
clan_symbol_clone_one function: this function clones one symbol, i.e., it returns the clone of the symbol provided as an argument only, with a next field set to NULL.
symbol | The symbol to clone. |
Definition at line 502 of file symbol.c.
References clan_symbol_malloc(), clan_symbol::identifier, clan_symbol::rank, and clan_symbol::type.
Referenced by clan_symbol_new_iterator().
void clan_symbol_free | ( | clan_symbol_p | symbol | ) |
clan_symbol_free function: This function frees the allocated memory for a clan_symbol_t structure.
[in,out] | symbol | The pointer to the symbol we want to free. |
Definition at line 214 of file symbol.c.
References clan_symbol::identifier, and clan_symbol::next.
Referenced by clan_parser_reinitialize(), clan_parser_state_free(), and yyparse().
static int clan_symbol_generate_new_key | ( | clan_symbol_p | table | ) | [static] |
clan_symbol_generate_new_key function: this function generates a key which is not yet present in the table.
[in] | table | The first element of the symbol table. |
Definition at line 278 of file symbol.c.
References CLAN_KEY_START, clan_symbol::key, and clan_symbol::next.
Referenced by clan_symbol_add().
int clan_symbol_get_key | ( | clan_symbol_p | symbol, |
char * | identifier | ||
) |
clan_symbol_get_key function: This function returns the key 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 CLAN_UNDEFINED.
[in] | symbol | The first node of the list of symbols. |
[in] | identifier | The identifier we want to know the key. |
Definition at line 338 of file symbol.c.
References CLAN_UNDEFINED, clan_symbol::identifier, clan_symbol::key, and clan_symbol::next.
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.
[in] | symbol | The first node of the list of symbols. |
[in] | identifier | The identifier we want to know the key. |
Definition at line 358 of file symbol.c.
References CLAN_UNDEFINED, clan_symbol::identifier, clan_symbol::next, and clan_symbol::rank.
Referenced by clan_vector_term().
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.
[in] | symbol | The first node of the list of symbols. |
[in] | identifier | The identifier we want to know the type. |
Definition at line 378 of file symbol.c.
References CLAN_UNDEFINED, clan_symbol::identifier, clan_symbol::next, and clan_symbol::type.
Referenced by clan_vector_term().
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.
[in] | symbol | The first node of the list of symbols. |
[in] | identifier | The identifier we are looking for. |
Definition at line 240 of file symbol.c.
References clan_symbol::identifier, and clan_symbol::next.
Referenced by clan_symbol_add().
clan_symbol_p clan_symbol_lookup_by_key | ( | clan_symbol_p | symbol, |
int | key | ||
) |
clan_symbol_lookup_by_key function: This function searches the symbol table for a symbol with the key provided as parameter. It returns the pointer to the symbol if it already exists inside the table, NULL otherwise.
[in] | symbol | The first node of the list of symbols. |
[in] | key | The key of the searched symbol. |
Definition at line 260 of file symbol.c.
References clan_symbol::key, and clan_symbol::next.
Referenced by clan_symbol_update_type().
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.
Definition at line 195 of file symbol.c.
References CLAN_malloc, CLAN_UNDEFINED, clan_symbol::identifier, clan_symbol::key, clan_symbol::next, clan_symbol::rank, and clan_symbol::type.
Referenced by clan_symbol_add(), and clan_symbol_clone_one().
int clan_symbol_nb_of_type | ( | clan_symbol_p | symbol, |
int | type | ||
) |
clan_symbol_nb_of_type function: this function returns the number of symbols of a given type in the symbol table.
[in] | symbol | The top of the symbol table. |
[in] | type | The type of the elements. |
Definition at line 432 of file symbol.c.
References clan_symbol::next, and clan_symbol::type.
Referenced by clan_symbol_to_strings(), and yyparse().
int clan_symbol_new_iterator | ( | clan_symbol_p * | table, |
clan_symbol_p * | array, | ||
char * | id, | ||
int | depth | ||
) |
clan_symbol_new_iterator function: this function return 1 if it succeeds to register (or to update) an iterator in the symbol table and to add it to the iterator array. It returns 0 otherwise. The reason for failure can be that the symbol is already in use for something else than an iterator.
[in,out] | table | The symbol table. |
[in,out] | array | The iterator array. |
[in] | id | The textual name of the iterator. |
[in] | depth | The current loop depth. |
Definition at line 570 of file symbol.c.
References clan_symbol_add(), clan_symbol_clone_one(), CLAN_TYPE_ITERATOR, clan_symbol::rank, clan_symbol::type, and yyerror().
Referenced by yyparse().
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).
[in] | file | File where informations are printed. |
[in] | symbol | The symbol whose information have to be printed. |
Definition at line 178 of file symbol.c.
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.
[in] | file | File where informations are printed. |
[in] | symbol | The symbol whose information have to be printed. |
[in] | level | Number of spaces before printing, for each line. |
Definition at line 73 of file symbol.c.
References CLAN_TYPE_ARRAY, CLAN_TYPE_FUNCTION, CLAN_TYPE_ITERATOR, CLAN_TYPE_PARAMETER, clan_symbol::identifier, clan_symbol::key, clan_symbol::next, clan_symbol::rank, and clan_symbol::type.
Referenced by clan_symbol_print().
osl_generic_p clan_symbol_to_arrays | ( | clan_symbol_p | symbol | ) | [read] |
clan_symbol_to_arrays function: this function generates an arrays extension from the symbol table passed as an argument. It embeds it in an osl_generic_t structure before returning it.
[in] | symbol | The symbol table. |
Definition at line 522 of file symbol.c.
References CLAN_malloc, CLAN_strdup, clan_symbol::identifier, clan_symbol::key, and clan_symbol::next.
Referenced by yyparse().
osl_generic_p clan_symbol_to_strings | ( | clan_symbol_p | symbol, |
int | type | ||
) | [read] |
clan_symbol_to_strings function: this function builds (and returns a pointer to) an osl_generic_t structure containing the symbol strings of a given type in the symbol table. The osl_generic_t is a shell for an osl_strings_t which actually stores the symbol strings. The symbol strings are sorted in the same order as they appear in the symbol table. If there is no corresponding symbol in the table, it returns NULL.
[in] | symbol | The top of the symbol table. |
[in] | type | The type of the elements. |
Definition at line 457 of file symbol.c.
References CLAN_malloc, clan_symbol_nb_of_type(), clan_symbol::identifier, clan_symbol::next, and clan_symbol::type.
Referenced by yyparse().
int clan_symbol_update_type | ( | clan_symbol_p | table, |
osl_relation_list_p | access, | ||
int | type | ||
) |
clan_symbol_update_type function: this function returns 1 if it succeeds to modify the type of a symbol in the symbol table. The modified symbol corresponds to the reference accessed in the last access relation of an access list provided as parameter. It returns 0 if it fails. The reasons for a failure can be either to try to modify an iterator type or a parameter type since they are supposed to be dead-ends.
[in,out] | table | The first symbol of the symbol table (one element may be modified). |
[in] | access | A list of access relations. |
[in] | type | The new type for the symbol we want to update. |
Definition at line 604 of file symbol.c.
References CLAN_error, clan_symbol_lookup_by_key(), CLAN_TYPE_ITERATOR, CLAN_TYPE_PARAMETER, clan_symbol::type, and yyerror().
Referenced by yyparse().
void yyerror | ( | char * | ) |
Definition at line 4506 of file parser.c.
References clan_options::autoscop, CLAN_debug, CLAN_TRUE, CLAN_warning, clan_options::name, parser_error, scanner_column, and scanner_line.
Referenced by clan_symbol_new_iterator(), clan_symbol_update_type(), and yyparse().