mais j'ai quand même une question
bonjour,:D
J'ai un code qui me compile pas et le message est abscons :
Je vous met le code et le message
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229
| erc CVirtualEquations::ProcessVirtualEquations( CAnalysedSegmentM^ pSegment)
{ // 0
erc ErrorCode = 0;
int nPos;
int nEqParParagraph = 0;
int nOldParagraph;
CElementSemantiqueM^ pProposition;
CAnalysedChunkM^ pChunk;
CVirtualEquations^ pEquation;
CAnalysedWordM^ pPreviousWord;
CAnalysedWordM^ pNextWord;
CAnalysedWordM^ pNext2Word;
System::String^ wsProposition;
System::String^ wsWord;
System::String^ wsNext2Word;
System::String^ wsLemma;
System::String^ wsSubject;
System::String^ wsOperator;
System::String^ wsOperande;
List<CElementSemantiqueM^>::Enumerator itProposition;
List<CAnalysedWordM^>::Enumerator itWord;
List<CAnalysedWordM^>::Enumerator itBack;
const wchar_t* chars;
enPOSM^ POS;
bool bNewEquation = false;
bool bOperator = false;
bool bSubject = false;
size_t iSize;
try
{ // 1
itWord = pSegment->pLinguisticSegment->pListWord->GetEnumerator();
itWord.MoveNext();
itBack = itWord;
for each( CChunker::pWord in pSegment->pLinguisticSegment->pListWord) //ligne 284
{ // 2
if( itWord.MoveNext())
{ // 3
pNextWord = itWord.Current;
if( itWord.MoveNext())
{ // 4
pNext2Word = itWord.Current;
} // 4
} // 3
itWord = itBack;
itWord.MoveNext();
wsWord = CChunker::pWord->wsWord;
POS = CChunker::pWord->POS;
wsLemma = CChunker::pWord->wsLemma;
switch( CChunker::pWord->POS)
{ // 3
case enPOSM::POS_NOUN:
if( wsOperator->Length == 0)
{ // 4
wsWord = CChunker::pWord->wsWord;
wsSubject += CChunker::pWord->wsWord;
wsSubject += L" ";
} // 4
else
{ // 4
if( bOperator == false)
{ // 5
wsOperande += CChunker::pWord->wsWord;
wsOperande += L" ";
} // 5
else
bOperator = false;
} // 4
break;
case enPOSM::POS_ADJ:
if( wsSubject->Length == 0)
{ // 4
wsSubject += CChunker::pWord->wsWord;
wsSubject += L" ";
bSubject = true;
} // 4
if( bSubject == false && bOperator == false)
{ // 4
wsOperande += CChunker::pWord->wsWord;
wsOperande += L" ";
bOperator = false;
} // 4
else
{ // 4
bOperator = false;
bSubject = false;
} // 4
break;
case enPOSM::POS_VERB:
wsNext2Word = pNext2Word->wsWord;
wsWord = CChunker::pWord->wsWord;
if( wsWord == L"increases")
{ // 4
bOperator = true;
wsOperator = L"++";
} // 4
else if( wsWord == L"decreases")
{ // 4
bOperator = true;
wsOperator = L"--";
} // 4
else if( wsWord == L"is" && pNextWord->wsWord == L"greater")
{ // 4
bOperator = true;
wsOperator = L">";
} // 4
else if( wsWord == L"is" && pNextWord->wsWord == L"over")
{ // 4
bOperator = true;
wsOperator = L">";
} // 4
else if( wsWord == L"is" && pNextWord->wsWord == L"lower")
{ // 4
bOperator = true;
wsOperator = L"<";
} // 4
else if( wsWord == L"is" && pNextWord->POS == enPOSM::POS_COLOR)
{ // 4
bOperator = true;
wsOperator = L"=";
} // 4
else if( wsWord == L"has")
{ // 4
bOperator = true;
wsOperator = L"==";
} // 4
else if( wsWord == L"keeps" && pNext2Word->wsWord == L"same")
{ // 4
bOperator = true;
wsOperator = L"==";
} // 4
break;
case enPOSM::POS_NB:
nPos = CChunker::pWord->wsWord->IndexOf( L"-", nPos);
if( nPos > 0 && nPos < 3)
{ // 4
//erreur lexicale
if( pSegment->pLinguisticSegment->pListProposition->Count > 0)
{ // 5
itProposition = pSegment->pLinguisticSegment->pListProposition->GetEnumerator();
if( itProposition.MoveNext())
{ // 6
pProposition = itProposition.Current;
nParagraph = pProposition->idParagraph;
for each( pChunk in pProposition->pListChunk)
{ // 7
for each( CChunker::pWord in pChunk->pListWord)
{ // 8
wsProposition += CChunker::pWord->wsWord;
wsProposition += L"";
} // 8
} // 7
} // 6
chars = (const wchar_t*)(Marshal::StringToHGlobalUni( wsProposition)).ToPointer();
string sProposition = CStrConv::awcstombs( (wchar_t*)chars);
Marshal::FreeHGlobal(IntPtr((void*)chars));
string msg = "error: there is a non acceptable charachter in this sentence : " + sProposition;
CStrConv::StrFreeA( (char*)sProposition.c_str());
throw Doc_exception ( msg.c_str(), nParagraph);
} // 5
} // 4
else if( pNextWord->POS != enPOSM::POS_MARK && pNextWord->wsWord != L"-")
{ // 4
wsOperande = pNextWord->wsWord;
} //4
break;
case enPOSM::POS_COLOR:
if( pNextWord->POS != enPOSM::POS_MARK && pNextWord->wsWord != L"-")
{ // 4
wsWord = CChunker::pWord->wsWord;
wsOperande = pNextWord->wsWord;
} // 4
break;
case enPOSM::POS_COMMA:
case enPOSM::POS_CONJ:
case enPOSM::POS_PIVOT:
bNewEquation = true;
break;
case enPOSM::POS_STOPMARK:
case enPOSM::POS_MARK:
if( wsSubject->Length != 0 && wsOperator->Length != 0 && wsOperande->Length != 0)
{ // 4
bNewEquation = true;
if( nParagraph >= nOldParagraph)
{ // 5
nEqParParagraph++;
nOldParagraph = nParagraph;
} // 5
} // 4
break;
default:
break;
} // 3
int len;
if( bNewEquation == true)
{ // 3
if( wsOperator->Length > 0)
{ // 4
pEquation = gcnew CVirtualEquations;
pEquation->wsSubject = wsSubject;
pEquation->wsOperator = wsOperator;
pEquation->wsOperande = wsOperande;
pEquation->idParagraph = nParagraph;
pEquation->nEqParParagraph = nEqParParagraph;
pSegment->pLinguisticSegment->pListEquations.Add( pEquation);
iSize = pSegment->pLinguisticSegment->pListEquations.Count;
len = iSize;
wsSubject = L"";
wsOperator = L"";
wsOperande = L"";
} // 4
bNewEquation = false;
} // 3
pPreviousWord = CChunker::pWord;
} // 2
} // 1
catch( Doc_exception &e )
{ // 1
size_t len;
string msg = e.Doc_exception::what();
msg = msg + "\n";
// il reste à gèrer la mise en fichier et la libération des ressources (à voir)
// errno_t fopen_s( FILE** pFile, const char *filename, const char *mode)
fopen_s( &fp, sLogFile.c_str(), "a");
len = fprintf( fp, msg.c_str());
fclose( fp);
} // 1
return( ErrorCode);
} // 0 |
le message est :
Code:
1>..\..\..\..\Linguistic\Analyser\src\VirtualEquation.cpp(284): fatal error C1506: impossible de récupérer l'erreur relative à la portée du bloc
celui qui m'aidera sera :ccool:
Le code a été décomposé et j'en arrive à ...
Le code a été décomposé et j'en arrive à une fonction simple qui provoque la même erreur qui est la seule erreur.
Quant à la question de marchal J'ai trouvé cet exemple sur le forum MSDN
Je donne le code et le diagnostique
Code:
1 2 3 4 5 6 7 8 9 10
| System::String^ CVirtualEquations::EditChunk( CAnalysedChunkM^ pChunk)
{
System::String^ wsProposition;
for each( CChunker::pWord in pChunk->pListWord)
{ // 1
wsProposition += CChunker::pWord->wsWord;
wsProposition += L"";
} // 1
return( wsProposition);
} |
et l'erreur toujours la même:
alors j'ai modifié la méthode qui est devenu:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| System::String^ CVirtualEquations::EditChunk( CAnalysedChunkM^ pChunk, CAnalysedWordM^ pWord)
{
System::String^ wsProposition;
for each( pWord in pChunk->pListWord)
{ // 1
wsProposition += pWord->wsWord;
wsProposition += L"";
} // 1
return( wsProposition);
}
System::String^ CVirtualEquations::EditProposition( CAnalysedChunkM^ pChunk, CElementSemantiqueM^ pProposition)
{ // 0
System::String^ wsProposition;
for each( pChunk in pProposition->pListChunk)
{ // 1
} // 1
return( wsProposition);
}; |
et ça marche