You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

main.c 650B

123456789101112131415161718192021222324252627282930313233343536
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include "vm.h"
  5. #include "lexer.h"
  6. static const char* strs[] =
  7. {
  8. "whitespace",
  9. "identifier",
  10. "keyword",
  11. "operator",
  12. "separator",
  13. "integer",
  14. "string",
  15. "function_start",
  16. "function_end",
  17. "expression_start",
  18. "expression_end"
  19. };
  20. int main(int argc, char** argv)
  21. {
  22. lexer_tokens* tokens = lexer_analyze("int foo = \"hi there\"");
  23. size_t i;
  24. for (i = 0; i < tokens->length; ++i)
  25. {
  26. lexer_token pair = tokens->pairs[i];
  27. char* str = malloc(pair.len);
  28. memcpy(str, pair.str, pair.len);
  29. str[pair.len - 1] = '\0';
  30. printf("class: %s, str: %s\n", strs[pair.tokenClass], str);
  31. }
  32. }