2010-03-22 07:49:57 +08:00
|
|
|
/*
|
2013-03-30 16:14:38 +08:00
|
|
|
* token lex for finsh shell.
|
2010-03-22 07:49:57 +08:00
|
|
|
*
|
2013-03-30 16:14:38 +08:00
|
|
|
* COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
|
|
|
|
*
|
|
|
|
* This file is part of RT-Thread (http://www.rt-thread.org)
|
|
|
|
* Maintainer: bernard.xiong <bernard.xiong at gmail.com>
|
|
|
|
*
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2010-03-22 07:49:57 +08:00
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
|
|
|
* 2010-03-22 Bernard first version
|
|
|
|
*/
|
2009-07-03 06:48:23 +08:00
|
|
|
#ifndef __FINSH_TOKEN_H__
|
|
|
|
#define __FINSH_TOKEN_H__
|
|
|
|
|
|
|
|
#include <finsh.h>
|
|
|
|
|
|
|
|
enum finsh_token_type
|
|
|
|
{
|
|
|
|
finsh_token_type_left_paren = 1, /* ( */
|
|
|
|
finsh_token_type_right_paren , /* ) */
|
|
|
|
finsh_token_type_comma , /* , */
|
|
|
|
finsh_token_type_semicolon , /* ; */
|
|
|
|
finsh_token_type_mul , /* * */
|
|
|
|
finsh_token_type_add , /* + */
|
|
|
|
finsh_token_type_inc , /* ++ */
|
|
|
|
finsh_token_type_sub , /* - */
|
|
|
|
finsh_token_type_dec , /* -- */
|
|
|
|
finsh_token_type_div , /* / */
|
|
|
|
finsh_token_type_mod , /* % */
|
|
|
|
finsh_token_type_assign , /* = */
|
|
|
|
finsh_token_type_and, /* & */
|
|
|
|
finsh_token_type_or, /* | */
|
|
|
|
finsh_token_type_xor, /* ^ */
|
|
|
|
finsh_token_type_bitwise, /* ~ */
|
|
|
|
finsh_token_type_shl, /* << */
|
|
|
|
finsh_token_type_shr, /* >> */
|
2012-05-30 10:42:26 +08:00
|
|
|
finsh_token_type_comments, /* // */
|
2009-07-03 06:48:23 +08:00
|
|
|
/*-- data type --*/
|
|
|
|
finsh_token_type_void, /* void */
|
|
|
|
finsh_token_type_char, /* char */
|
|
|
|
finsh_token_type_short, /* short */
|
|
|
|
finsh_token_type_int, /* int */
|
|
|
|
finsh_token_type_long, /* long */
|
|
|
|
finsh_token_type_unsigned, /* unsigned */
|
|
|
|
/* data value type */
|
|
|
|
finsh_token_type_value_char, /* v:char */
|
|
|
|
finsh_token_type_value_int, /* v:int */
|
|
|
|
finsh_token_type_value_long, /* v:long */
|
|
|
|
finsh_token_type_value_string, /* v:string */
|
|
|
|
finsh_token_type_value_null, /* NULL */
|
|
|
|
/*-- others --*/
|
|
|
|
finsh_token_type_identifier, /* ID */
|
|
|
|
finsh_token_type_bad, /* bad token */
|
|
|
|
finsh_token_type_eof
|
|
|
|
};
|
|
|
|
|
|
|
|
#define finsh_token_position(self) (self)->position
|
|
|
|
#define finsh_token_replay(self) (self)->replay = 1
|
|
|
|
|
2017-10-10 14:27:34 +08:00
|
|
|
void finsh_token_init(struct finsh_token* self, uint8_t* script);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
|
|
|
enum finsh_token_type finsh_token_token(struct finsh_token* self);
|
2017-10-10 14:27:34 +08:00
|
|
|
void finsh_token_get_token(struct finsh_token* self, uint8_t* token);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
|
|
|
#endif
|