finsh_token.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2010-03-22 Bernard first version
  9. */
  10. #ifndef __FINSH_TOKEN_H__
  11. #define __FINSH_TOKEN_H__
  12. #include <finsh.h>
  13. enum finsh_token_type
  14. {
  15. finsh_token_type_left_paren = 1, /* ( */
  16. finsh_token_type_right_paren , /* ) */
  17. finsh_token_type_comma , /* , */
  18. finsh_token_type_semicolon , /* ; */
  19. finsh_token_type_mul , /* * */
  20. finsh_token_type_add , /* + */
  21. finsh_token_type_inc , /* ++ */
  22. finsh_token_type_sub , /* - */
  23. finsh_token_type_dec , /* -- */
  24. finsh_token_type_div , /* / */
  25. finsh_token_type_mod , /* % */
  26. finsh_token_type_assign , /* = */
  27. finsh_token_type_and, /* & */
  28. finsh_token_type_or, /* | */
  29. finsh_token_type_xor, /* ^ */
  30. finsh_token_type_bitwise, /* ~ */
  31. finsh_token_type_shl, /* << */
  32. finsh_token_type_shr, /* >> */
  33. finsh_token_type_comments, /* // */
  34. /*-- data type --*/
  35. finsh_token_type_void, /* void */
  36. finsh_token_type_char, /* char */
  37. finsh_token_type_short, /* short */
  38. finsh_token_type_int, /* int */
  39. finsh_token_type_long, /* long */
  40. finsh_token_type_unsigned, /* unsigned */
  41. /* data value type */
  42. finsh_token_type_value_char, /* v:char */
  43. finsh_token_type_value_int, /* v:int */
  44. finsh_token_type_value_long, /* v:long */
  45. finsh_token_type_value_string, /* v:string */
  46. finsh_token_type_value_null, /* NULL */
  47. /*-- others --*/
  48. finsh_token_type_identifier, /* ID */
  49. finsh_token_type_bad, /* bad token */
  50. finsh_token_type_eof
  51. };
  52. #define finsh_token_position(self) (self)->position
  53. #define finsh_token_replay(self) (self)->replay = 1
  54. void finsh_token_init(struct finsh_token* self, uint8_t* script);
  55. enum finsh_token_type finsh_token_token(struct finsh_token* self);
  56. void finsh_token_get_token(struct finsh_token* self, uint8_t* token);
  57. #endif