1 /* 2 * Copyright (c) 2006-2018, 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 13 #include <finsh.h> 14 15 enum finsh_token_type 16 { 17 finsh_token_type_left_paren = 1, /* ( */ 18 finsh_token_type_right_paren , /* ) */ 19 finsh_token_type_comma , /* , */ 20 finsh_token_type_semicolon , /* ; */ 21 finsh_token_type_mul , /* * */ 22 finsh_token_type_add , /* + */ 23 finsh_token_type_inc , /* ++ */ 24 finsh_token_type_sub , /* - */ 25 finsh_token_type_dec , /* -- */ 26 finsh_token_type_div , /* / */ 27 finsh_token_type_mod , /* % */ 28 finsh_token_type_assign , /* = */ 29 finsh_token_type_and, /* & */ 30 finsh_token_type_or, /* | */ 31 finsh_token_type_xor, /* ^ */ 32 finsh_token_type_bitwise, /* ~ */ 33 finsh_token_type_shl, /* << */ 34 finsh_token_type_shr, /* >> */ 35 finsh_token_type_comments, /* // */ 36 /*-- data type --*/ 37 finsh_token_type_void, /* void */ 38 finsh_token_type_char, /* char */ 39 finsh_token_type_short, /* short */ 40 finsh_token_type_int, /* int */ 41 finsh_token_type_long, /* long */ 42 finsh_token_type_unsigned, /* unsigned */ 43 /* data value type */ 44 finsh_token_type_value_char, /* v:char */ 45 finsh_token_type_value_int, /* v:int */ 46 finsh_token_type_value_long, /* v:long */ 47 finsh_token_type_value_string, /* v:string */ 48 finsh_token_type_value_null, /* NULL */ 49 /*-- others --*/ 50 finsh_token_type_identifier, /* ID */ 51 finsh_token_type_bad, /* bad token */ 52 finsh_token_type_eof 53 }; 54 55 #define finsh_token_position(self) (self)->position 56 #define finsh_token_replay(self) (self)->replay = 1 57 58 void finsh_token_init(struct finsh_token* self, uint8_t* script); 59 60 enum finsh_token_type finsh_token_token(struct finsh_token* self); 61 void finsh_token_get_token(struct finsh_token* self, uint8_t* token); 62 63 #endif 64