mbed2 zad 5b

Dependencies:   LCD_DISCO_F429ZI mbed BSP_DISCO_F429ZI

Dekodowanie/Tokeny/Tokeny.h

Committer:
krzysiek99
Date:
2020-06-09
Revision:
5:cafab5a4d1c9
Parent:
4:7855d3ab4c15

File content as of revision 5:cafab5a4d1c9:

#ifndef TOKENY_H
    #define TOKENY_H
    #include <string.h>
    #include <cstring>
    #include <stdlib.h>
    #include <stdio.h>
    #define MAX_TOKEN_NR 2 //maksymalna dopuszczalna ilosc tokenów
    #define MAX_KEYWORD_STRING_LTH 13 // maksymalna dlugosc komendy
    #define MAX_KEYWORD_NR 4
    #define NULL 0
    
    enum KeywordCode {ID, CAL, GT, ST};
    enum TokenType { KEYWORD, NUMBER, STRING};
    enum Stan{DELIMITER, TOKEN};
    
    union TokenValue
    {
        enum KeywordCode eKeyword; // jezeli KEYWORD
        unsigned int uiNumber; // jezeli NUMBER
        char * pcString; // jezeli STRING
    };

    struct Token
    {
        enum TokenType eType; // KEYWORD, NUMBER, STRING
        union TokenValue uValue; // enum, unsigned int, char*
    };

    struct Keyword
    {
        enum KeywordCode eCode;
        char cString[MAX_KEYWORD_STRING_LTH + 1];
    };
    
    unsigned char ucFindTokensInString (char *pcString);
    enum Result eStringToKeyword (char pcStr[], enum KeywordCode *peKeywordCode);
    void DecodeTokens(void);
    void DecodeMsg(char *pcString);
    
#endif