statement.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #ifndef VIRTUALMATH_STATEMENT_H
  2. #define VIRTUALMATH_STATEMENT_H
  3. #include "__macro.h"
  4. #define MAX_SIZE (1024)
  5. struct Statement;
  6. typedef struct VirtualMathValue{
  7. enum ValueType{
  8. number=1,
  9. string,
  10. } type;
  11. union data{
  12. struct Number{
  13. NUMBER_TYPE num;
  14. } num;
  15. struct String{
  16. char *str;
  17. } str;
  18. }data;
  19. struct VirtualMathValue *next;
  20. struct VirtualMathValue *last;
  21. } Value;
  22. typedef struct VirtualMathLinkValue{
  23. struct VirtualMathValue *value;
  24. struct VirtualMathLinkValue *father;
  25. struct VirtualMathLinkValue *next;
  26. struct VirtualMathLinkValue *last;
  27. } LinkValue;
  28. typedef struct VirtualMathResult{
  29. enum ResultType{
  30. statement_end = 1,
  31. } type;
  32. struct VirtualMathLinkValue *value;
  33. } Result;
  34. typedef struct VirtualMathVar{
  35. char *name;
  36. struct VirtualMathLinkValue *value;
  37. struct VirtualMathVar *next;
  38. } Var;
  39. typedef struct VirtualMathHashTable{
  40. struct VirtualMathVar **hashtable;
  41. int count;
  42. struct VirtualMathHashTable *next;
  43. struct VirtualMathHashTable *last;
  44. } HashTable;
  45. typedef struct VirtualMathVarList{
  46. struct VirtualMathHashTable *hashtable;
  47. struct VirtualMathVarList *next;
  48. } VarList;
  49. typedef struct Statement{
  50. enum StatementType{
  51. start = 1,
  52. base_value,
  53. base_var,
  54. operation,
  55. } type;
  56. union StatementU{
  57. struct base_value{
  58. struct VirtualMathValue *value;
  59. } base_value;
  60. struct base_var{
  61. char *name;
  62. struct Statement *times;
  63. } base_var;
  64. struct operation{
  65. enum OperationType{
  66. ADD = 1,
  67. SUB,
  68. MUL,
  69. DIV,
  70. ASS,
  71. } OperationType;
  72. struct Statement *left;
  73. struct Statement *right;
  74. } operation;
  75. }u;
  76. struct Statement *next;
  77. } Statement;
  78. #endif //VIRTUALMATH_STATEMENT_H