Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.82 KB | None | 0 0
  1. /*
  2.  * Project: IFJ2014
  3.  * Variant: Tým 024, varianta a/4/II
  4.  * Authors: Dita Cihlářová <xcihla02>, Martin Vondráček <xvondr20>, Vladislav Bambuch<xbambu03>, Ondřej Záruba <xzarub06>, Lukáš Drahník <xdrahn00>
  5.  * Date: 22.9.2014
  6.  *
  7.  */
  8.  
  9. #ifndef _IAL_H_
  10. #define _IAL_H_
  11.  
  12. #include <stdio.h>
  13. #include <stdlib.h>
  14. #include <stdbool.h>
  15. #include <string.h>
  16. #include <stdarg.h> //va_list apod... pro praci s neomezenym poctem parametru
  17. #include "error.h"
  18. #include "garbage_collector.h"
  19. #include "global.h"
  20. #include "error.h"
  21. #include <stdbool.h>
  22.  
  23. #define MAX_HTSIZE 127
  24. #define HT_MAX 127
  25.  
  26. //struktura pro čtení ze vstupu a konstanta
  27.  
  28.             //-----NAHRAZENÍ ZA T_VALUE-----//
  29. /*typedef struct id{
  30.     union
  31.     {
  32.        int int_n;
  33.        double real_n;
  34.        char* str;
  35.     } d_data;
  36.     enum DATA_TYPE type;
  37. } D_VAR;
  38. */
  39.  
  40.  
  41. T_ERROR sort(char **);        //parametr odkaz na řezený řetězec
  42. T_ERROR copy(char *, int, int, char **);  //
  43. T_ERROR find(char* , char*, int *);
  44. T_ERROR kmp_table(char *, int **);
  45. T_ERROR length(char *, int *);
  46. T_ERROR readln(T_VALUE *);
  47. T_ERROR write(int, ...);    //volani nejdriv pocet dalsich parametru, pak parametry typu adresa T_VALUE. napr: write(2, &foo, &boo);
  48. T_ERROR readString(T_VALUE *);
  49. T_ERROR readInt(int *);
  50. T_ERROR readReal(double *);
  51. T_ERROR mergeSort(char*);
  52. T_ERROR merge(char* left, char* rigth, char* string);
  53.  
  54. /*
  55.  * HASH TABLE
  56.  */
  57.  
  58. /* Type */
  59. typedef enum HT_TYPE {
  60.     HT_FUNCTION,
  61.     HT_VARIABLE,
  62. } HT_TYPE;
  63.  
  64. /* Params node */
  65. typedef struct params_node {
  66.     struct HT_node_data *data;
  67.     struct params_node *next;
  68. } params_node;
  69.  
  70. /* Hashtable node */
  71. typedef struct HT_node {
  72.     struct HT_node_data *data;
  73.     struct HT_node *next;
  74. } HT_node;
  75.  
  76. /* Hashtable data */
  77. typedef struct HT_node_data {
  78.     char* key;
  79.     HT_TYPE type;
  80.     DATA_TYPE data_type;
  81.     struct params_node *params;                   // function params
  82.     struct HT_table* local_HT;                    // local HT for function
  83.     struct T_IL_e* label;                         // návěští
  84.     bool initialized;                             // proměnná je inicializována nebo ne
  85. } HT_node_data;
  86.  
  87. typedef HT_node* HT_table[HT_MAX];
  88.  
  89. /* Functions to work with hashtable */
  90. HT_node* HT_createNode(T_ERROR* error);
  91. int HT_calculateHashCode(char* key);
  92. T_ERROR HT_insert(HT_table* hashtable, HT_node* node);
  93. void HT_init(HT_table* hashtable);
  94. HT_node_data* HT_search(HT_table* hashtable, char* key);
  95. T_ERROR HT_clearAll(HT_table* hashtable);
  96. bool HT_empty(T_ERROR* error, HT_table* hashtable);
  97.  
  98. /* Bonus */
  99. params_node* HT_createParamsNode(T_ERROR* error, HT_node_data* data);
  100. HT_node_data* HT_createNodeData(T_ERROR* error, char* key, HT_TYPE type, DATA_TYPE data_type, params_node* params);
  101.  
  102. #ifdef DEBUG
  103. void HT_print(HT_table*);
  104. #endif
  105.  
  106.  
  107. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement