コード例 #1
0
ファイル: cjparser.cpp プロジェクト: EdgarTx/wx
static wxChar* set_comment_text( wxString& text, wxChar* start )
{
    wxChar* end = start;

    // to avoid poluting the queue with this comment
    _gLastSuppresedComment = start;

    skip_comments( end );

    if ( *(end-1) == _T('/') )
        end -= 2;

    start += 2;

    // skip multiple leading '/''s or '*''s
    while( *start == _T('/') && start < end ) ++start;
    while( *start == _T('*') && start < end ) ++start;

    get_string_between( start, end, &text );

    return end;
}
コード例 #2
0
ファイル: cjparser.cpp プロジェクト: Bluehorn/wxPython
void CJSourceParser::AddEnumNode( wxChar*& cur )
{
    // now the cursor is at "enum" keyword
    wxChar* start = cur;

    spEnumeration* pEnum = new spEnumeration();
    mpCurCtx->AddMember( pEnum );

    pEnum->mSrcLineNo = get_line_no();


    AttachComments( *pEnum, cur );

    skip_token( cur );
    if ( !get_next_token( cur ) ) return;

    // check if enumeration has got it's identifier
    if ( *cur != '{' )
    {
        pEnum->m_Name = get_token_str( cur );
    }

    if ( !skip_imp_block( cur ) ) return;

    get_string_between( start, cur, &pEnum->m_EnumContent );

    if ( get_next_token(cur) )
    {
        // check if the identifier if after the {...} block
        if ( *cur != ';' )

            pEnum->m_Name = get_token_str( cur );
    }

    clear_commets_queue();
}
コード例 #3
0
ファイル: cjparser.cpp プロジェクト: Bluehorn/wxPython
void CJSourceParser::AddTypeDefNode( wxChar*& cur )
{
    // now the cursor at the token next to "typedef" keyword

    if ( !get_next_token(cur) ) return;

    wxChar* start = cur;

    spTypeDef* pTDef = new spTypeDef();
    mpCurCtx->AddMember( pTDef );

    pTDef->mSrcLineNo = get_line_no();

    AttachComments( *pTDef, cur );

    skip_statement( cur );

    int tmpLnNo;
    store_line_no( tmpLnNo );

    wxChar* tok = cur-1;
    skip_next_token_back( tok );

    wxChar* nameEnd = tok;

    skip_token_back( tok );

    wxChar* nameStart = tok;

    skip_next_token_back( tok );

    wxChar* typeEnd = tok;

    // check if it's function prototype
    if ( *nameStart == ')' )
    {
        typeEnd = nameStart+1;

        // skip argument list
        while ( *nameStart != '(' ) --nameStart;

        // skip to function type definition
        while ( *nameStart != ')' ) --nameStart;

        skip_next_token_back( nameStart );

        nameEnd = nameStart;

        skip_token_back( nameStart );

        if ( *nameStart == '*' ) ++nameStart;
    }

    get_string_between( start, typeEnd, &pTDef->m_OriginalType );

    get_string_between( nameStart, nameEnd, &pTDef->m_Name );

    clear_commets_queue();

    restore_line_no( tmpLnNo );
}
コード例 #4
0
ファイル: cjparser.cpp プロジェクト: Bluehorn/wxPython
void CJSourceParser::AddMacroNode( wxChar*& cur )
{
    wxChar* start = cur;

    int lineNo = get_line_no();

    skip_preprocessor_dir( cur );

    int tmpLnNo;
    store_line_no( tmpLnNo );

    if ( !mMacrosOn ) return;

    spPreprocessorLine* pPL = new spPreprocessorLine();
    pPL->mSrcLineNo = lineNo;

    AttachComments( *pPL, cur );

    get_string_between( start, cur, &pPL->m_Line );

    ++start; // skip '#'
    get_next_token( start );

    pPL->mDefType = SP_PREP_DEF_OTHER;

    // if we found a definition or redefinition,
    // determine the type exactly and assign
    // a name to the context

    if ( *start == _T('d') )
    {
        if ( cmp_tokens_fast( start, _T("define"), 6 ) )
        {
            char* tok = start+6;

            get_next_token( tok );

            pPL->m_Name = get_token_str( tok );

            skip_token( tok );
            get_next_token( tok);


            if ( tok > cur )
                pPL->mDefType = SP_PREP_DEF_DEFINE_SYMBOL;
            else
                pPL->mDefType = SP_PREP_DEF_REDEFINE_SYMBOL;
        }
    }
    else if ( *start == _T('i') )
    {
        if ( cmp_tokens_fast( start, _T("include"), 7 ) )
        {
            pPL->mDefType = SP_PREP_DEF_INCLUDE_FILE;
        }
        else if ( *++start == _T('f') )
        {
            // either "#if" or "#ifdef"
            cur = start;
            skip_token( cur );
            get_next_token( cur );

            wxString condition = get_token_str( cur );

            // currently, everything except '0' is true
            if ( condition == _T("0") ) {
                // skip until the following else or enif
                while ( cur < _gSrcEnd ) {
                    skip_to_eol( cur );
                    skip_eol( cur );

                    get_next_token( cur );
                    if ( *cur++ == _T('#') && *cur == _T('e') )
                        break;
                }
            }

            // TODO parse the condition...
        }
    }
    else if ( cmp_tokens_fast( start, _T("else"), 4 ) )
    {
        // skip until "#endif"
        while ( cur < _gSrcEnd ) {
            skip_to_eol( cur );
            skip_eol( cur );

            get_next_token( cur );
            if ( *cur++ == _T('#') && cmp_tokens_fast( cur, "endif", 5 ) )
                break;
        }
    }

    mpCurCtx->AddMember( pPL );

    skip_to_eol( cur );
    skip_eol( cur );

    restore_line_no( tmpLnNo );

    clear_commets_queue();
}