Exemple #1
0
VOID ACLStr::MakeLower(VOID)
{
	CHAR_LOWER(_string, _length);
}	//	MakeLower
Exemple #2
0
// 获取符号,数字或标识符
CTobCompiler::EToken CTobCompiler::GetToken(CString& str)
{
    EToken ret = ERR_EOF;
    BOOL comment = FALSE;
    str.Empty();
    for(;;)
    {
        int c = fgetc(m_fsrc);
        if (c == EOF)
        {
            if (!feof(m_fsrc))
            {
                m_err.Format("can not read src file at %p", ftell(m_fsrc));
                return ERR_SEVERE;
            }
            return str.IsEmpty() ? ERR_EOF : ret;
        }
        if (comment)
        {
            if (c == '\n') { ++m_line; comment = FALSE; }
            continue;
        }
        if (ret == ERR_EOF)
        {
            switch(c)
            {
            case ' ':
            case '\t':
            case '\r': continue;
            case '\n': ++m_line;        continue;
            case ';' : comment = TRUE;  continue;
            case '@' : return SYM_DEF;
            case '#' : return SYM_LABEL;
            case '[' : return SYM_BIN;
            case '\'':
            case '\"': return SYM_STR;
            case '(' : return SYM_EXP_BEGIN;
            case '+' : return SYM_ADD;
            case '-' : return SYM_SUB;
            case ':' : return SYM_TYPE;
            case ',' : return SYM_NEXT;
            case ')' : return SYM_EXP_END;
            default:
                switch(ms_tokentable[c])
                {
                    case TOKEN_NOT_ID:
                    case TOKEN_INVALID:
                        m_err.Format("found invalid char 0x%02X in src file at %p", c, ftell(m_fsrc)-1);
                        return ERR_NORMAL;

                    case TOKEN_ID:
                        ret = SYM_TOKEN;
                        break;

                    case TOKEN_OTHER:
                        if (fseek(m_fsrc, -1, SEEK_CUR))
                        {
                            m_err.Format("can not seek src file at %p", ftell(m_fsrc));
                            return ERR_SEVERE;
                        }
                        return GetNumber(str);
                }
            }
        }
        else if (!ms_tokentable[c] || ms_tokentable[c] == 3)
        {
            if (fseek(m_fsrc, -1, SEEK_CUR))
            {
                m_err.Format("can not seek src file at %p", ftell(m_fsrc));
                return ERR_SEVERE;
            }
            return ret;
        }
        if (c >= 0x81)
        {
            str += (TCHAR)c;
            c = fgetc(m_fsrc);
            if (c < 0)
            {
                if (!feof(m_fsrc))
                    m_err.Format("can not read src file at %p", ftell(m_fsrc));
                else
                    m_err = "found half wide char at the end of src file";
                return ERR_SEVERE;
            }
            if (c < 0x40)
            {
                if (fseek(m_fsrc, -1, SEEK_CUR))
                {
                    m_err.Format("can not seek src file at %p", ftell(m_fsrc));
                    return ERR_SEVERE;
                }
                m_err.Format("found half wide char in src file at %p", ftell(m_fsrc)-1);
                return ERR_NORMAL;
            }
        }
        if (m_Option.bIgnoreCase)
            c = CHAR_LOWER(c);
        str += (TCHAR)c;
    }
}