finsh_token.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. finsh_token_type_comments, /* // */
  38. /*-- data type --*/
  39. finsh_token_type_void, /* void */
  40. finsh_token_type_char, /* char */
  41. finsh_token_type_short, /* short */
  42. finsh_token_type_int, /* int */
  43. finsh_token_type_long, /* long */
  44. finsh_token_type_unsigned, /* unsigned */
  45. /* data value type */
  46. finsh_token_type_value_char, /* v:char */
  47. finsh_token_type_value_int, /* v:int */
  48. finsh_token_type_value_long, /* v:long */
  49. finsh_token_type_value_string, /* v:string */
  50. finsh_token_type_value_null, /* NULL */
  51. /*-- others --*/
  52. finsh_token_type_identifier, /* ID */
  53. finsh_token_type_bad, /* bad token */
  54. finsh_token_type_eof
  55. };
  56. #define finsh_token_position(self) (self)->position
  57. #define finsh_token_replay(self) (self)->replay = 1
  58. void finsh_token_init(struct finsh_token* self, u_char* script);
  59. enum finsh_token_type finsh_token_token(struct finsh_token* self);
  60. void finsh_token_get_token(struct finsh_token* self, u_char* token);
  61. #endif