finsh_token.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #ifndef __FINSH_TOKEN_H__
  2. #define __FINSH_TOKEN_H__
  3. #include <finsh.h>
  4. enum finsh_token_type
  5. {
  6. finsh_token_type_left_paren = 1, /* ( */
  7. finsh_token_type_right_paren , /* ) */
  8. finsh_token_type_comma , /* , */
  9. finsh_token_type_semicolon , /* ; */
  10. finsh_token_type_mul , /* * */
  11. finsh_token_type_add , /* + */
  12. finsh_token_type_inc , /* ++ */
  13. finsh_token_type_sub , /* - */
  14. finsh_token_type_dec , /* -- */
  15. finsh_token_type_div , /* / */
  16. finsh_token_type_mod , /* % */
  17. finsh_token_type_assign , /* = */
  18. finsh_token_type_and, /* & */
  19. finsh_token_type_or, /* | */
  20. finsh_token_type_xor, /* ^ */
  21. finsh_token_type_bitwise, /* ~ */
  22. finsh_token_type_shl, /* << */
  23. finsh_token_type_shr, /* >> */
  24. /*-- data type --*/
  25. finsh_token_type_void, /* void */
  26. finsh_token_type_char, /* char */
  27. finsh_token_type_short, /* short */
  28. finsh_token_type_int, /* int */
  29. finsh_token_type_long, /* long */
  30. finsh_token_type_unsigned, /* unsigned */
  31. /* data value type */
  32. finsh_token_type_value_char, /* v:char */
  33. finsh_token_type_value_int, /* v:int */
  34. finsh_token_type_value_long, /* v:long */
  35. finsh_token_type_value_string, /* v:string */
  36. finsh_token_type_value_null, /* NULL */
  37. /*-- others --*/
  38. finsh_token_type_identifier, /* ID */
  39. finsh_token_type_bad, /* bad token */
  40. finsh_token_type_eof
  41. };
  42. #define finsh_token_position(self) (self)->position
  43. #define finsh_token_replay(self) (self)->replay = 1
  44. void finsh_token_init(struct finsh_token* self, u_char* script);
  45. enum finsh_token_type finsh_token_token(struct finsh_token* self);
  46. void finsh_token_get_token(struct finsh_token* self, u_char* token);
  47. #endif