finsh_token.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * token lex for finsh shell.
  3. *
  4. * COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
  5. *
  6. * This file is part of RT-Thread (http://www.rt-thread.org)
  7. * Maintainer: bernard.xiong <bernard.xiong at gmail.com>
  8. *
  9. * All rights reserved.
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License along
  22. * with this program; if not, write to the Free Software Foundation, Inc.,
  23. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  24. *
  25. * Change Logs:
  26. * Date Author Notes
  27. * 2010-03-22 Bernard first version
  28. */
  29. #ifndef __FINSH_TOKEN_H__
  30. #define __FINSH_TOKEN_H__
  31. #include <finsh.h>
  32. enum finsh_token_type
  33. {
  34. finsh_token_type_left_paren = 1, /* ( */
  35. finsh_token_type_right_paren , /* ) */
  36. finsh_token_type_comma , /* , */
  37. finsh_token_type_semicolon , /* ; */
  38. finsh_token_type_mul , /* * */
  39. finsh_token_type_add , /* + */
  40. finsh_token_type_inc , /* ++ */
  41. finsh_token_type_sub , /* - */
  42. finsh_token_type_dec , /* -- */
  43. finsh_token_type_div , /* / */
  44. finsh_token_type_mod , /* % */
  45. finsh_token_type_assign , /* = */
  46. finsh_token_type_and, /* & */
  47. finsh_token_type_or, /* | */
  48. finsh_token_type_xor, /* ^ */
  49. finsh_token_type_bitwise, /* ~ */
  50. finsh_token_type_shl, /* << */
  51. finsh_token_type_shr, /* >> */
  52. finsh_token_type_comments, /* // */
  53. /*-- data type --*/
  54. finsh_token_type_void, /* void */
  55. finsh_token_type_char, /* char */
  56. finsh_token_type_short, /* short */
  57. finsh_token_type_int, /* int */
  58. finsh_token_type_long, /* long */
  59. finsh_token_type_unsigned, /* unsigned */
  60. /* data value type */
  61. finsh_token_type_value_char, /* v:char */
  62. finsh_token_type_value_int, /* v:int */
  63. finsh_token_type_value_long, /* v:long */
  64. finsh_token_type_value_string, /* v:string */
  65. finsh_token_type_value_null, /* NULL */
  66. /*-- others --*/
  67. finsh_token_type_identifier, /* ID */
  68. finsh_token_type_bad, /* bad token */
  69. finsh_token_type_eof
  70. };
  71. #define finsh_token_position(self) (self)->position
  72. #define finsh_token_replay(self) (self)->replay = 1
  73. void finsh_token_init(struct finsh_token* self, u_char* script);
  74. enum finsh_token_type finsh_token_token(struct finsh_token* self);
  75. void finsh_token_get_token(struct finsh_token* self, u_char* token);
  76. #endif