Esempio n. 1
0
void    testLexParser()
{ 
#if 1
    // char    *str = "0812";
    // char    *str = "012";
    char    *str = "int i ==< 12;";
    
    Token_state *ts = createTokenState(str);
    if(!ts)
    {
        printf("create Token_state error\n");
        return;
    }
    
    TokensTable *tt = createTokensTable(16);
    if(!tt)
    {
        printf("create TokensTable error\n");
        return;
    }
#if 0
    if(getAllTokens(ts, tt))
    {
       // printTokenName(tt->p[0]);
        showAllTokens(tt);
    }
#endif
    
#if 1   // getNextToken
    {
        Token *tk;
        while((tk = getNextToken(ts, tt)))
        {
            analyseTokenTypes(tk);
            printToken(tk);
        }
    }
#endif
    
    freeTokensTable(tt);
    freeTokenState(ts);
    
#endif
}
Esempio n. 2
0
GRMSGEXPORT coGRObjSetConnectionMsg::coGRObjSetConnectionMsg(const char *msg)
    : coGRObjMsg(msg)
{
    vector<string> tok = getAllTokens();

    if (!tok[0].empty())
    {
        string cp = tok[0];
        connPoint1_ = new char[cp.size() + 1];
        strcpy(connPoint1_, cp.c_str());
        is_valid_ = is_valid_ & 1;
    }
    else
    {
        is_valid_ = 0;
    }

    if (!tok[1].empty())
    {
        string cp = tok[1];
        connPoint2_ = new char[cp.size() + 1];
        strcpy(connPoint2_, cp.c_str());
        is_valid_ = is_valid_ & 1;
    }
    else
    {
        is_valid_ = 0;
    }

    if (!tok[2].empty())
    {
        string conn = tok[2];
        sscanf(conn.c_str(), "%d", &connected_);
        is_valid_ = is_valid_ & 1;
    }
    else
    {
        is_valid_ = 0;
    }

    if (!tok[3].empty())
    {
        string conn = tok[3];
        sscanf(conn.c_str(), "%d", &enabled_);
        is_valid_ = is_valid_ & 1;
    }
    else
    {
        is_valid_ = 0;
    }

    if (!tok[4].empty())
    {
        string cp = tok[4];
        obj_name2_ = new char[cp.size() + 1];
        strcpy(obj_name2_, cp.c_str());
        is_valid_ = is_valid_ & 1;
    }
    else
    {
        is_valid_ = 0;
    }
}