Ignore:
Timestamp:
May 8, 2008, 2:20:23 PM (16 years ago)
Author:
dai_9181
Message:

LexicalAnalyzer::ConstMacroToExpressionメソッドを実装。

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/Const.cpp

    r543 r578  
    8686}
    8787
    88 
    89 bool ConstMacro::GetCalcBuffer( const char *parameterStr, char *dest ) const
    90 {
    91     extern HANDLE hHeap;
    92     int i2,i3,i4,num;
    93     char temporary[VN_SIZE];
    94     char *pParms[MAX_PARMS];
    95     num=0;
    96     i2=0;
    97     while(1){
    98         i2=GetOneParameter(parameterStr,i2,temporary);
    99 
    100         pParms[num]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);
    101         lstrcpy(pParms[num],temporary);
    102 
    103         num++;
    104         if(parameterStr[i2]=='\0') break;
    105     }
    106     if( num != this->GetParameters().size() ){
    107         extern int cp;
    108         for(i2=0;i2<num;i2++) HeapDefaultFree(pParms[i2]);
    109         compiler.errorMessenger.Output(10,GetName().c_str(),cp);
    110         lstrcpy(dest,"0");
    111         return 1;
    112     }
    113 
    114     i2=0;
    115     i4=0;
    116     while(1){
    117 
    118         //数式内の項を取得
    119         for(i3=0;;i2++,i3++){
    120             if(!IsVariableChar( this->GetExpression()[i2] )){
    121                 temporary[i3]=0;
    122                 break;
    123             }
    124             temporary[i3] = this->GetExpression()[i2];
    125         }
    126 
    127         //パラメータと照合する
    128         for( i3=0; i3<(int)this->GetParameters().size(); i3++ ){
    129             if( this->GetParameters()[i3] == temporary ) break;
    130         }
    131 
    132         if( i3 == (int)this->GetParameters().size() ){
    133             //パラメータでないとき
    134             lstrcpy(dest+i4,temporary);
    135             i4+=lstrlen(temporary);
    136         }
    137         else{
    138             //パラメータのとき
    139             lstrcpy(dest+i4,pParms[i3]);
    140             i4+=lstrlen(pParms[i3]);
    141         }
    142 
    143         //演算子をコピー
    144         for(;;i2++,i4++){
    145             if( this->GetExpression()[i2] == 1 ){
    146                 dest[i4++] = this->GetExpression()[i2++];
    147                 dest[i4] = this->GetExpression()[i2];
    148                 continue;
    149             }
    150             if(IsVariableTopChar( this->GetExpression()[i2] )) break;
    151             dest[i4] = this->GetExpression()[i2];
    152             if( this->GetExpression()[i2] == '\0' ) break;
    153         }
    154 
    155         if( this->GetExpression()[i2] == '\0' ) break;
    156     }
    157 
    158     for(i2=0;i2<num;i2++) HeapDefaultFree(pParms[i2]);
    159 
    160     return 1;
    161 }
    162 
    16388// マクロ定数を追加するための関数
    16489void ConstMacros::Add( const NamespaceScopes &namespaceScopes, const std::string &name, const char *parameterStr )
Note: See TracChangeset for help on using the changeset viewer.