Classes | Typedefs | Functions

symbol.h File Reference

#include <stdio.h>
#include <scoplib/scop.h>
#include <scoplib/macros.h>
Include dependency graph for symbol.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  clan_symbol

Typedefs

typedef struct clan_symbol clan_symbol_t
typedef struct clan_symbolclan_symbol_p

Functions

void clan_symbol_print_structure (FILE *, clan_symbol_p, int)
void clan_symbol_print (FILE *, clan_symbol_p)
clan_symbol_p clan_symbol_malloc ()
void clan_symbol_free (clan_symbol_p)
clan_symbol_p clan_symbol_lookup (clan_symbol_p, char *)
clan_symbol_p clan_symbol_add (clan_symbol_p *, char *, int, int)
void clan_symbol_remove (clan_symbol_p *, clan_symbol_p)
int clan_symbol_get_rank (clan_symbol_p, char *)
int clan_symbol_get_type (clan_symbol_p, char *)
char ** clan_symbol_iterators (clan_symbol_p *, int)
char ** clan_symbol_id_array (clan_symbol_p, int, int *)

Typedef Documentation

typedef struct clan_symbol* clan_symbol_p
typedef struct clan_symbol clan_symbol_t

Function Documentation

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.

Parameters:
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)
  • 01/05/2008: first version.

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.

Parameters:
symbol The pointer to the symbol we want to free.
  • 01/05/2008: first version.

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.

Parameters:
symbol The first node of the list of symbols.
identifier The identifier we want to know the rank.
  • 01/05/2008: first version.

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.

Parameters:
symbol The first node of the list of symbols.
identifier The identifier we want to know the type.
  • 01/05/2008: first version.

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".

Parameters:
symbol The first element of the symbol table.
type The type of interesting elements.
size The returned array size (this is a _result_).
  • 02/05/2008: First version.
  • 03/05/2008: More generic, no more dedicated to parameters only.

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.

Parameters:
symbols Array of iterator symbols for the statement.
depth The depth of the statement.
  • 01/05/2008: First version.

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.

Parameters:
symbol The first node of the list of symbols.
identifier The identifier we are looking for.
  • 01/05/2008: first version.

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.

  • 01/05/2008: first version.

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).

Parameters:
file File where informations are printed.
symbol The symbol whose information have to be printed.
  • 01/05/2008: first version.

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.

Parameters:
file File where informations are printed.
symbol The symbol whose information have to be printed.
level Number of spaces before printing, for each line.
  • 01/05/2008: first version.

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().