engine/source/preprocessorlib/pp_lexer.c
/******************************************************************************
*  Number -- This method extracts a numerical constant from the stream.  It
*  only extracts the digits that make up the number.  No conversion from string
*  to numeral is performed here.
*  Parameters: theNextToken -- address of the next CToken found in the stream
*  Returns: S_OK
*           E_FAIL
******************************************************************************/
- This method extracts a numerical constant from the stream.  It
only extracts the digits that make up the number.  No conversion from string
to numeral is performed here.
Parameters: theNextToken -- address of the next CToken found in the stream
Returns: S_OK
E_FAIL
- This method extracts a numerical constant from the stream . It only extracts the digits that make up the number . No conversion from string to numeral is performed here . Parameters : theNextToken -- address of the next CToken found in the stream Returns : S_OK E_FAIL
HRESULT pp_lexer_GetTokenNumber(pp_lexer *plexer, pp_token *theNextToken)
{
    if (( !strncmp( plexer->pcurChar, "0X", 2)) || ( !strncmp( plexer->pcurChar, "0x", 2)))
    {
        CONSUMECHARACTER;
        CONSUMECHARACTER;
        while ((*plexer->pcurChar >= '0' && *plexer->pcurChar <= '9') ||
                (*plexer->pcurChar >= 'a' && *plexer->pcurChar <= 'f') ||
                (*plexer->pcurChar >= 'A' && *plexer->pcurChar <= 'F'))
        {
            CONSUMECHARACTER;
        }
        if (( !strncmp( plexer->pcurChar, "u", 1)) || ( !strncmp( plexer->pcurChar, "U", 1)) ||
                ( !strncmp( plexer->pcurChar, "l", 1)) || ( !strncmp( plexer->pcurChar, "L", 1)))
        {
            CONSUMECHARACTER;
        }
        MAKETOKEN( PP_TOKEN_HEXCONSTANT );
    }
    else
    {
        while (*plexer->pcurChar >= '0' && *plexer->pcurChar <= '9')
        {
            CONSUMECHARACTER;
        }
        if (( !strncmp( plexer->pcurChar, "E", 1)) || ( !strncmp( plexer->pcurChar, "e", 1)))
        {
            CONSUMECHARACTER;
            while (*plexer->pcurChar >= '0' && *plexer->pcurChar <= '9')
            {
                CONSUMECHARACTER;
            }
            if (( !strncmp( plexer->pcurChar, "f", 1)) || ( !strncmp( plexer->pcurChar, "F", 1)) ||
                    ( !strncmp( plexer->pcurChar, "l", 1)) || ( !strncmp( plexer->pcurChar, "L", 1)))
            {
                CONSUMECHARACTER;
            }
            MAKETOKEN( PP_TOKEN_FLOATCONSTANT );
        }
        else if ( !strncmp( plexer->pcurChar, ".", 1))
        {
            CONSUMECHARACTER;
            while (*plexer->pcurChar >= '0' && *plexer->pcurChar <= '9')
            {
                CONSUMECHARACTER;
            }
            if (( !strncmp( plexer->pcurChar, "E", 1)) || ( !strncmp( plexer->pcurChar, "e", 1)))
            {
                CONSUMECHARACTER;
                while (*plexer->pcurChar >= '0' && *plexer->pcurChar <= '9')
                {
                    CONSUMECHARACTER;
                }
                if (( !strncmp( plexer->pcurChar, "f", 1)) ||
                        ( !strncmp( plexer->pcurChar, "F", 1)) ||
                        ( !strncmp( plexer->pcurChar, "l", 1)) ||
                        ( !strncmp( plexer->pcurChar, "L", 1)))
                {
                    CONSUMECHARACTER;
                }
            }
            MAKETOKEN( PP_TOKEN_FLOATCONSTANT );
        }
        else
        {
            if (( !strncmp( plexer->pcurChar, "u", 1)) || ( !strncmp( plexer->pcurChar, "U", 1)) ||
                    ( !strncmp( plexer->pcurChar, "l", 1)) || ( !strncmp( plexer->pcurChar, "L", 1)))
            {
                CONSUMECHARACTER;
            }
            MAKETOKEN( PP_TOKEN_INTCONSTANT );
        }
    }
    return S_OK;
}
HRESULT pp_lexer_GetTokenNumber ( pp_lexer * plexer , pp_token * theNextToken ) { if ( ( ! strncmp ( plexer -> pcurChar , " " , 2 ) ) || ( ! strncmp ( plexer -> pcurChar , " " , 2 ) ) ) { CONSUMECHARACTER ; CONSUMECHARACTER ; while ( ( * plexer -> pcurChar >= ' ' && * plexer -> pcurChar <= ' ' ) || ( * plexer -> pcurChar >= ' ' && * plexer -> pcurChar <= ' ' ) || ( * plexer -> pcurChar >= ' ' && * plexer -> pcurChar <= ' ' ) ) { CONSUMECHARACTER ; } if ( ( ! strncmp ( plexer -> pcurChar , " " , 1 ) ) || ( ! strncmp ( plexer -> pcurChar , " " , 1 ) ) || ( ! strncmp ( plexer -> pcurChar , " " , 1 ) ) || ( ! strncmp ( plexer -> pcurChar , " " , 1 ) ) ) { CONSUMECHARACTER ; } MAKETOKEN ( PP_TOKEN_HEXCONSTANT ) ; } else { while ( * plexer -> pcurChar >= ' ' && * plexer -> pcurChar <= ' ' ) { CONSUMECHARACTER ; } if ( ( ! strncmp ( plexer -> pcurChar , " " , 1 ) ) || ( ! strncmp ( plexer -> pcurChar , " " , 1 ) ) ) { CONSUMECHARACTER ; while ( * plexer -> pcurChar >= ' ' && * plexer -> pcurChar <= ' ' ) { CONSUMECHARACTER ; } if ( ( ! strncmp ( plexer -> pcurChar , " " , 1 ) ) || ( ! strncmp ( plexer -> pcurChar , " " , 1 ) ) || ( ! strncmp ( plexer -> pcurChar , " " , 1 ) ) || ( ! strncmp ( plexer -> pcurChar , " " , 1 ) ) ) { CONSUMECHARACTER ; } MAKETOKEN ( PP_TOKEN_FLOATCONSTANT ) ; } else if ( ! strncmp ( plexer -> pcurChar , " " , 1 ) ) { CONSUMECHARACTER ; while ( * plexer -> pcurChar >= ' ' && * plexer -> pcurChar <= ' ' ) { CONSUMECHARACTER ; } if ( ( ! strncmp ( plexer -> pcurChar , " " , 1 ) ) || ( ! strncmp ( plexer -> pcurChar , " " , 1 ) ) ) { CONSUMECHARACTER ; while ( * plexer -> pcurChar >= ' ' && * plexer -> pcurChar <= ' ' ) { CONSUMECHARACTER ; } if ( ( ! strncmp ( plexer -> pcurChar , " " , 1 ) ) || ( ! strncmp ( plexer -> pcurChar , " " , 1 ) ) || ( ! strncmp ( plexer -> pcurChar , " " , 1 ) ) || ( ! strncmp ( plexer -> pcurChar , " " , 1 ) ) ) { CONSUMECHARACTER ; } } MAKETOKEN ( PP_TOKEN_FLOATCONSTANT ) ; } else { if ( ( ! strncmp ( plexer -> pcurChar , " " , 1 ) ) || ( ! strncmp ( plexer -> pcurChar , " " , 1 ) ) || ( ! strncmp ( plexer -> pcurChar , " " , 1 ) ) || ( ! strncmp ( plexer -> pcurChar , " " , 1 ) ) ) { CONSUMECHARACTER ; } MAKETOKEN ( PP_TOKEN_INTCONSTANT ) ; } } return S_OK ; }
Number -- This method extracts a numerical constant from the stream.
Number -- This method extracts a numerical constant from the stream .
//copy the source that makes up this token //a constant is one of these: //0[xX][a-fA-F0-9]+{u|U|l|L} //0{D}+{u|U|l|L}