
mbed2 pre-final
Dependencies: LCD_DISCO_F429ZI mbed BSP_DISCO_F429ZI
token_decoder.h
- Committer:
- domino5740
- Date:
- 2020-06-15
- Revision:
- 5:7ca9ea4cde3a
- Parent:
- 2:7dc265489818
File content as of revision 5:7ca9ea4cde3a:
#ifndef TOKEN_DECODER_H #define TOKEN_DECODER_H #define MAX_TOKEN_NR 2 #define MAX_KEYWORD_NR 4 #define MAX_KEYWORD_STRING_LTH 20 typedef enum TokenType {KEYWORD, NUMBER, STRING} TokenType; typedef enum KeywordCode {ID, CALIB, GOTO, STEP} KeywordCode; enum Result {OK, ERR}; typedef union TokenValue { enum KeywordCode eKeyword; unsigned int uiNumber; char * pcString; } TokenValue; typedef struct Token { enum TokenType eType; union TokenValue uValue; } Token; typedef struct Keyword { enum KeywordCode eCode; char cString[MAX_KEYWORD_STRING_LTH + 1]; } Keyword; class TokenDecoder { public: void DecodeMsg(char *pcString); private: unsigned char ucFindTokensInString(char *pcString); enum Result eStringToKeyword (char pcStr[], enum KeywordCode *peKeywordCode); void DecodeTokens(void); }; #endif