Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. typedef struct word{
  2. struct word *previous;
  3. char *name;
  4. uint8_t flag;
  5. void(*xt)();
  6. }word;
  7.  
  8. #define STRUCT {0, "+", 0, add}
  9. word last_word = {&(STRUCT), "-", 0, sub};
  10.  
  11. typedef struct word{
  12. // struct word *previous;
  13. char *name;
  14. uint8_t flag;
  15. void(*xt)();
  16. } word;
  17.  
  18. word w[] = {
  19. { "plus", 0, add };
  20. { "minus", 0, sub };
  21. ...
  22. };
  23.  
  24. typedef struct word{
  25. struct word *previous;
  26. char *name;
  27. unsigned char flag;
  28. void(*xt)();
  29. } word;
  30.  
  31. word w[] = {
  32. { 0, "plus", 0, add },
  33. { &w[0], "minus", 0, minus },
  34. { &w[1], "product", 0, prod }
  35. ...
  36. };
  37.  
  38. typedef struct word {
  39. struct word *previous;
  40. char *name;
  41. uint8_t flag;
  42. void(*xt)();
  43. } word;
  44.  
  45. word w1 = { 0, "plus", 0, add };
  46. word w2 = { &w1, "minus", 0, sub };
  47.  
  48. typedef struct word {
  49. struct word *previous;
  50. char *name;
  51. uint8_t flag;
  52. void(*xt)();
  53. } word;
  54.  
  55. word* root = malloc(sizeof(word));
  56. *root = (word){ 0, "plus", 0, add };
  57.  
  58. word* prev = root;
  59. root = malloc(sizeof(word));
  60. *root = (word){ prev, "minus", 0, sub };
  61.  
  62. prev = root;
  63. root = malloc(sizeof(word));
  64. *root = (word){ prev, "times", 0, mult };
  65.  
  66. // ...
  67.  
  68. typedef struct word
  69. {
  70. void(*xt)();
  71. char *name;
  72. uint8_t index;
  73. uint8_t flag;
  74. } word;
  75.  
  76. word w[] =
  77. {
  78. { 0, "plus", 0, add },
  79. { 1, "minus", 0, minus },
  80. { 2, "product", 0, prod },
  81. // ...
  82. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement