symbolsTable.h
Description du code
Fonctions de gestion de la table des symboles Compilateur LSD010Code source ou contenu du fichier
Code c (symbolsTable.h) (96 lignes)
/* * symbolsTable.h : Exposed items to manage the symbols table * Part of the compiler project for LSD10 language * Gaudry Stéphane * More information on http://www.gaudry.be/langages-table-des-symboles.html * ********************************************************** */ #ifndef SYMBOLS_TABLE_H #define SYMBOLS_TABLE_H #include "common.h" /** * Allows to detect unused variables. */ typedef enum { VAR_USAGE_NEVER, VAR_USAGE_SOMETIMES, VAR_USAGE_ALWAYS }VariableUsage; /** * Sets usage for a declared variable * @param currentVarNode variable node * @param usage one of the VAR_USAGE_SOMETIMES or VAR_USAGE_ALWAYS values * pre-conditions : currentVarNode is a variable node */ int setUsage(AstNode *currentVarNode, VariableUsage usage); /** * @return 1 if the symbols table is available, 0 otherwise */ int isSymbolsTableAvailable(); /** * Creates a new data storage for the symbols management */ void initializeSymbolsTable(); /** * Free all resources */ void finalizeSymbolsTable(); /** * Enters into a new scope */ void enterScope(); /** * Enters into a new function scope */ int enterFunctionScope(AstNode* functionNode); /** * Exits from the current scope, and return to the parent scope if exists */ void exitScope(); /** * Adds informations about a declaration * All information is given from a declaration node from the AST * * Pre-condition: * a createSymbolsTable() call must has been done * the finalizeSymbolsTable may not has been called * the AST may not has been finalized */ void addDeclaration(AstNode *declarationNode); /** * Search into the symbols table for a declaration of a given AST node for the current scope. * If no backward declaration exists, the program exits with an error message * * pre-conditions: * currentNode argument may not be NULL * currentNode must be an ID or a function call * a createSymbolsTable() call must has been done * the finalizeSymbolsTable may not has been called * the AST may not has been finalized * the enterScope() and exitScope() must have been called at the right time to be into the current scope * * returns: AST declaration node for the current scope */ AstNode* getDeclaration(AstNode *currentNode); /** * Returns the memory location of the last declaration, or INITIAL_INT on error */ int getDeclarationsMemoryUpperBound(); /** * Returns the memory location of the given node declaration, or INITIAL_INT on error */ int getDeclarationMemoryLocation(AstNode *node); #endif
Autres extraits de codes en c
- DisquetteDispo Vérifier la disponibilité du lecteur de disquette
- Suite de Fibonacci Exemple d'itération en C
- Suite de Fibonacci Exemple de récursion en C
- astDataRepresentation.h Représentation de données de l'arbre syntaxique abstrait Compilateur LSD010
- ast.h Arbre syntaxique abstrait Compilateur LSD010
- ast.c Arbre syntaxique abstrait Compilateur LSD010
- symbolsTableDataRepresentation.h Représentation de données de la table des symboles Compilateur LSD010
- symbolsTable.h Fonctions de gestion de la table des symboles Compilateur LSD010
- symbolsTable.c Fonctions de gestion de la table des symboles Compilateur LSD010
- hashCode.h Fonctions de hachage Compilateur LSD010
- hashCode.c Fonctions de hachage Compilateur LSD010
- scopeStack.h Fonctions de gestion d'une pile de portées Compilateur LSD010
- scopeStack.c Fonctions de gestion d'une pile de portées Compilateur LSD010
- scopeHelper.h Fonctions de gestion de la portée courante Compilateur LSD010
- console.h Fonctions d'affichage Compilateur LSD010
- console.c Fonctions d'affichage Compilateur LSD010
- graphVizHelper.h Génération d'une image d'un arbre syntaxique abstrait.
Classe d'intégration de l'outil GraphViz. Compilateur LSD010 - graphVizHelper.c Génération d'une image d'un arbre syntaxique abstrait.
Classe d'intégration de l'outil GraphViz. Compilateur LSD010 - common.h Définition des constantes et variables communes Compilateur LSD010
- pcode.c Génération de p-code Compilateur LSD010
- pcode.h Génération de p-code Compilateur LSD010
- Tous les extraits
English translation
You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.
Thank you in advance.
Document created the 05/10/2009, last modified the 28/10/2018
Source of the printed document:https://www.gaudry.be/en/sniplet-rf-lsd010/project/source/symbolsTable.h.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.