symbolsTable.h

Sommaire du document

Description du code

Fonctions de gestion de la table des symboles Compilateur LSD010

Code source ou contenu du fichier


Code c (symbolsTable.h) (96 lignes) :
  1. /*
  2.  * symbolsTable.h : Exposed items to manage the symbols table
  3.  * Part of the compiler project for LSD10 language
  4.  * Gaudry Stéphane
  5.  * More information on http://www.gaudry.be/langages-table-des-symboles.html
  6.  * **********************************************************
  7.  */
  8. #ifndef SYMBOLS_TABLE_H
  9. #define SYMBOLS_TABLE_H
  10. #include "common.h"
  11.  
  12. /**
  13. * Allows to detect unused variables.
  14. */
  15. typedef enum {
  16. VAR_USAGE_NEVER,
  17. VAR_USAGE_SOMETIMES,
  18. VAR_USAGE_ALWAYS
  19. }VariableUsage;
  20.  
  21. /**
  22. * Sets usage for a declared variable
  23. * @param currentVarNode variable node
  24. * @param usage one of the VAR_USAGE_SOMETIMES or VAR_USAGE_ALWAYS values
  25. * pre-conditions : currentVarNode is a variable node
  26. */
  27. int setUsage(AstNode *currentVarNode, VariableUsage usage);
  28.  
  29. /**
  30. * @return 1 if the symbols table is available, 0 otherwise
  31. */
  32. int isSymbolsTableAvailable();
  33.  
  34. /**
  35. * Creates a new data storage for the symbols management
  36. */
  37. void initializeSymbolsTable();
  38.  
  39. /**
  40. * Free all resources
  41. */
  42. void finalizeSymbolsTable();
  43.  
  44. /**
  45. * Enters into a new scope
  46. */
  47. void enterScope();
  48.  
  49. /**
  50. * Enters into a new function scope
  51. */
  52. int enterFunctionScope(AstNode* functionNode);
  53.  
  54. /**
  55. * Exits from the current scope, and return to the parent scope if exists
  56. */
  57. void exitScope();
  58.  
  59. /**
  60. * Adds informations about a declaration
  61. * All information is given from a declaration node from the AST
  62. *
  63. * Pre-condition:
  64. * a createSymbolsTable() call must has been done
  65. * the finalizeSymbolsTable may not has been called
  66. * the AST may not has been finalized
  67. */
  68. void addDeclaration(AstNode *declarationNode);
  69.  
  70. /**
  71. * Search into the symbols table for a declaration of a given AST node for the current scope.
  72. * If no backward declaration exists, the program exits with an error message
  73. *
  74. * pre-conditions:
  75. * currentNode argument may not be NULL
  76. * currentNode must be an ID or a function call
  77. * a createSymbolsTable() call must has been done
  78. * the finalizeSymbolsTable may not has been called
  79. * the AST may not has been finalized
  80. * the enterScope() and exitScope() must have been called at the right time to be into the current scope
  81. *
  82. * returns: AST declaration node for the current scope
  83. */
  84. AstNode* getDeclaration(AstNode *currentNode);
  85.  
  86. /**
  87. * Returns the memory location of the last declaration, or INITIAL_INT on error
  88. */
  89. int getDeclarationsMemoryUpperBound();
  90.  
  91. /**
  92. * Returns the memory location of the given node declaration, or INITIAL_INT on error
  93. */
  94. int getDeclarationMemoryLocation(AstNode *node);
  95.  
  96. #endif

Autres extraites 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

 

Réseaux sociaux

Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher les interactions avec les réseaux sociaux sur ces pages.

 

Nuage de mots clés

9 mots clés dont 5 définis manuellement (plus d'information...).

Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher le nuage de mots clés.

 

Astuce pour imprimer les couleurs des cellules de tableaux : http://www.gaudry.be/ast-rf-450.html
Aucun commentaire pour cette page

© Ce document issu de l′infobrol est enregistré sous le certificat Cyber PrInterDeposit Digital Numbertection. Enregistrement IDDN n° 5329-308
Document créé le 05/10/09 01:03, dernière modification le Vendredi 17 Juin 2011, 12:12
Source du document imprimé : http://www.gaudry.be/sniplet.html Document affiché 59 fois ce mois de Juin.
St.Gaudry©07.01.02
Outils (masquer)
||
Recherche (afficher)
Recherche :

Utilisateur (masquer)
Apparence (afficher)
Stats (afficher)
15832 documents
452 astuces.
549 niouzes.
3099 definitions.
447 membres.
8115 messages.

Document genere en :
0,71 seconde

Mises à jour :
Mises à jour du site
Citation (masquer)
Connaître son ignorance est la meilleure part de la connaissance.

Proverbe chinois
 
l'infobrol
Nous sommes le Dimanche 03 Juin 2012, 11:41, toutes les heures sont au format GMT+1.00 Heure, heure d'été (+1)