Advertisement
Guest User

Untitled

a guest
Feb 12th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. #ifndef AST_H
  2. #define AST_H
  3.  
  4. #include <stdlib.h>
  5.  
  6. enum ast_type {
  7. A_ID,
  8. A_INT,
  9. A_FUNCTION,
  10. A_RETURN
  11. };
  12.  
  13. /*
  14. * AST nodes
  15. */
  16. typedef struct ast_base
  17. {
  18. enum ast_type type;
  19. void * ast_pointer;
  20. } ast_base;
  21.  
  22. typedef struct node_id
  23. {
  24. ast_base base;
  25. char * value;
  26. } node_id;
  27.  
  28. typedef struct node_int
  29. {
  30. ast_base base;
  31. int value;
  32. } node_int;
  33.  
  34. typedef struct node_function
  35. {
  36. ast_base base;
  37. char * name;
  38. ast_base * entry_point;
  39. } node_function;
  40.  
  41. typedef struct node_return
  42. {
  43. ast_base base;
  44. ast_base * value;
  45. } node_return;
  46.  
  47. /*
  48. * Init functions for the AST nodes
  49. */
  50. void init_node_id(node_id * node, char * value);
  51. void init_node_int(node_int * node, int value);
  52. void init_node_function(node_function * node, char * name, ast_base * entry_point);
  53. void init_node_return(node_return * node, ast_base * value);
  54.  
  55. /*
  56. * Release functions for the AST nodes
  57. */
  58. void free_node_id(node_id * node);
  59. void free_node_int(node_int * node);
  60. void free_node_function(node_function * node);
  61. void free_node_return(node_return * node);
  62. #endif //AST_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement