void SharedWorkerProxy::workerContextClosed()
{
    if (isClosing())
        return;
    close();
}
示例#2
0
/* binarySecond - return true if char can be second char in binary symbol */
bool Lexer::binarySecond(char c)
{
    if (isalpha(c) || isdigit(c) || isspace(c) || isClosing(c) || singleBinary(c))
        return(false);
    return(true);
}
示例#3
0
tokentype Lexer::nextToken()
{   
    bool sign;
    std::string strToken;

    /* skip over blanks and comments */
    while(nextChar() && (isspace(m_cc) || (m_cc == '"')))
    {
        if (m_cc == '"') {
            /* read comment */
            while (nextChar() && (m_cc != '"')) ;
            if (! m_cc) break;    /* break if we run into eof */
        }
    }

    strToken.clear();
    strToken.push_back(m_cc);

    if (! m_cc)           /* end of input */
        m_currentToken = inputend;
    else if (isalpha(m_cc)) 
    {     /* identifier */
        while (nextChar() && isalnum(m_cc))
            strToken.push_back(m_cc);
        if (m_cc == ':') 
        {
            strToken.push_back(m_cc);
            m_currentToken = namecolon;
        }
        else 
        {
            pushBack(m_cc);
            m_currentToken = nameconst;
        }
    }
    else if (isdigit(m_cc)) 
    {     /* number */
        long longresult = m_cc - '0';
        while (nextChar() && isdigit(m_cc)) 
        {
            strToken.push_back(m_cc);
            longresult = (longresult * 10) + (m_cc - '0');
        }
        if (longCanBeInt(longresult)) 
        {
            m_tokenInteger = longresult;
            m_currentToken = intconst;
        }
        else 
        {
            m_currentToken = floatconst;
            m_tokenFloat = (double) longresult;
        }
        if (m_cc == '.') 
        {    /* possible float */
            if (nextChar() && isdigit(m_cc)) 
            {
                strToken.push_back('.');
                do
                    strToken.push_back(m_cc);
                while (nextChar() && isdigit(m_cc));
                if (m_cc) pushBack(m_cc);
                m_currentToken = floatconst;
                strToken.push_back('\0');
                m_tokenFloat = atof(strToken.c_str());
                printf("lex: %s\n", strToken.c_str());
            }
            else 
            {
                /* nope, just an ordinary period */
                if (m_cc) pushBack(m_cc);
                pushBack('.');
            }
        }
        else
            pushBack(m_cc);

        if (nextChar() && m_cc == 'e') 
        {  /* possible float */
            if (nextChar() && m_cc == '-') 
            {
                sign = true;
                nextChar();
            }
            else
                sign = false;
            if (m_cc && isdigit(m_cc)) 
            { /* yep, its a float */
                strToken.push_back('e');
                if (sign) 
                    strToken.push_back('-');
                while (m_cc && isdigit(m_cc)) 
                {
                    strToken.push_back(m_cc);
                    nextChar();
                }
                if (m_cc) 
                    pushBack(m_cc);
                m_currentToken = floatconst;
                m_tokenFloat = atof(strToken.c_str());
            }
            else 
            {  /* nope, wrong again */
                if (m_cc) pushBack(m_cc);
                if (sign) pushBack('-');
                pushBack('e');
            }
        }
        else
            if (m_cc) pushBack(m_cc);
    }
    else if (m_cc == '$') 
    {       /* character constant */
        m_tokenInteger = (int) nextChar();
        m_currentToken = charconst;
    }
    else if (m_cc == '#') 
    {       /* symbol */
        strToken.resize(strToken.size()-1); // erase pound sign
        if (nextChar() == '(')
            m_currentToken = arraybegin;
        else 
        {
            pushBack(m_cc);
            while (nextChar() && isSymbolChar(m_cc))
                strToken.push_back(m_cc);
            pushBack(m_cc);
            m_currentToken = symconst;
        }
    }
    else if (m_cc == '\'') 
    {      /* string constant */
        strToken.resize(strToken.size()-1);
strloop:
        while (nextChar() && (m_cc != '\''))
            strToken.push_back(m_cc);
        /* check for nested quote marks */
        if (m_cc && nextChar() && (m_cc == '\'')) 
        {
            strToken.push_back(m_cc);
            goto strloop;
        }
        pushBack(m_cc);
        m_currentToken = strconst;
    }
    else if (isClosing(m_cc))     /* closing expressions */
        m_currentToken = closing;
    else if (singleBinary(m_cc)) 
    {    /* single binary expressions */
        m_currentToken = binary;
    }
    else 
    {              /* anything else is binary */
        if (nextChar() && binarySecond(m_cc))
            strToken.push_back(m_cc);
        else
            pushBack(m_cc);
        m_currentToken = binary;
    }

    m_tokenString = strToken;
    return(m_currentToken);
}
示例#4
0
void SharedWorkerProxy::workerGlobalScopeClosed()
{
    if (isClosing())
        return;
    close();
}