finsh_token.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * File : finsh_token.h
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://www.rt-thread.org/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2010-03-22 Bernard first version
  13. */
  14. #ifndef __FINSH_TOKEN_H__
  15. #define __FINSH_TOKEN_H__
  16. #include <finsh.h>
  17. enum finsh_token_type
  18. {
  19. finsh_token_type_left_paren = 1, /* ( */
  20. finsh_token_type_right_paren , /* ) */
  21. finsh_token_type_comma , /* , */
  22. finsh_token_type_semicolon , /* ; */
  23. finsh_token_type_mul , /* * */
  24. finsh_token_type_add , /* + */
  25. finsh_token_type_inc , /* ++ */
  26. finsh_token_type_sub , /* - */
  27. finsh_token_type_dec , /* -- */
  28. finsh_token_type_div , /* / */
  29. finsh_token_type_mod , /* % */
  30. finsh_token_type_assign , /* = */
  31. finsh_token_type_and, /* & */
  32. finsh_token_type_or, /* | */
  33. finsh_token_type_xor, /* ^ */
  34. finsh_token_type_bitwise, /* ~ */
  35. finsh_token_type_shl, /* << */
  36. finsh_token_type_shr, /* >> */
  37. /*-- data type --*/
  38. finsh_token_type_void, /* void */
  39. finsh_token_type_char, /* char */
  40. finsh_token_type_short, /* short */
  41. finsh_token_type_int, /* int */
  42. finsh_token_type_long, /* long */
  43. finsh_token_type_unsigned, /* unsigned */
  44. /* data value type */
  45. finsh_token_type_value_char, /* v:char */
  46. finsh_token_type_value_int, /* v:int */
  47. finsh_token_type_value_long, /* v:long */
  48. finsh_token_type_value_string, /* v:string */
  49. finsh_token_type_value_null, /* NULL */
  50. /*-- others --*/
  51. finsh_token_type_identifier, /* ID */
  52. finsh_token_type_bad, /* bad token */
  53. finsh_token_type_eof
  54. };
  55. #define finsh_token_position(self) (self)->position
  56. #define finsh_token_replay(self) (self)->replay = 1
  57. void finsh_token_init(struct finsh_token* self, u_char* script);
  58. enum finsh_token_type finsh_token_token(struct finsh_token* self);
  59. void finsh_token_get_token(struct finsh_token* self, u_char* token);
  60. #endif