byte_code.c 920 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include "aFun.h"
  4. #include "../../src/core/__code.h"
  5. int main() {
  6. af_Code *bt1 = makeElementCode("data", ',', 0, "Unknown");
  7. af_Code *bt2 = makeElementCode("var1", 0, 1, NULL);
  8. af_Code *bt3 = makeElementCode("data2", 0, 0, NULL);
  9. af_Code *bt4 = makeElementCode("var2", 0, 1, NULL);
  10. pushCode(&bt1, bt2);
  11. pushCode(&bt3, bt4);
  12. af_Code *bt5 = makeBlockCode(parentheses, bt3, 0, 1, NULL, NULL);
  13. pushCode(&bt2, bt5);
  14. if(!writeAllCode(bt1, "test.aub")) {
  15. fprintf(stderr, "Write test.aub error.\n");
  16. return EXIT_FAILURE;
  17. }
  18. af_Code *get;
  19. if(!readAllCode(&get, "test.aub")) {
  20. fprintf(stderr, "Read test.aub error.\n");
  21. return EXIT_FAILURE;
  22. }
  23. printf("out:\n");
  24. printCode(bt1);
  25. printf("in:\n");
  26. printCode(get);
  27. freeAllCode(bt1);
  28. freeAllCode(get);
  29. return EXIT_SUCCESS;
  30. }