Index: branches/apertium-separable/src/lsx_processor.cc =================================================================== --- branches/apertium-separable/src/lsx_processor.cc (revision 80998) +++ branches/apertium-separable/src/lsx_processor.cc (revision 81000) @@ -3,6 +3,7 @@ #include #include #include +// #include /* get the text between delim1 and delim2 */ wstring readFullBlock(FILE *input, wchar_t const delim1, wchar_t const delim2); @@ -16,10 +17,23 @@ while(!feof(input) && c != delim2) { - c = static_cast(fgetwc(input)); + c = static_cast(fgetwc_unlocked(input)); result += c; + if(c != L'\\') + { + continue; } + else + { + result += static_cast(readEscaped(input)); + } + } + if(c != delim2) + { + streamError(); + } + return result; } @@ -104,24 +118,31 @@ while(!feof(input)) { int val = fgetwc(input); + // cout << 'v' << (char) val; - if(outOfWord) - { - wstring blank = L""; - while(val != L'^' && !feof(input)) - { - blank += val; - val = fgetwc(input); - } - blanks.push_back(blank); - fputws(blanks.front().c_str(),output); - blanks.pop_front(); - } + // if(outOfWord) + // { + // wstring blank = L""; + // // while(val != L'^' && !feof(input)) + // // { + // blank += val; + // // val = fgetwc(input); + // // } + // // blanks.push_back(blank); + // // fputws(blanks.front().c_str(),output); + // // fflush(output); + // // blanks.pop_front(); + // // outOfWord = false; + // // cout << "val" << (char) val; + // // continue; + // } - if((val == L'^' && !isEscaped && outOfWord)) + if(val == L'^' && !isEscaped )//&& outOfWord) { + // cout << "here"; outOfWord = false; in += val; + // cout << "here" ; continue; } @@ -129,6 +150,7 @@ { alive_states.push_back(*initial_state); fputws(in.c_str(), output); + fflush(output); in = L""; leading = true; } @@ -137,14 +159,19 @@ in = L""; finalFound = false; } - + int i = 0; if((feof(input) || val == L'$') && !isEscaped && !outOfWord) { new_states.clear(); for(vector::const_iterator it = alive_states.begin(); it != alive_states.end(); it++) { + i++; + cout << i; State s = *it; s.step(alphabet(L"<$>")); + fputws(L"($$$)", output); + fflush(output); + // out += L"BLANKHERE"; if(s.size() > 0) { new_states.push_back(s); @@ -209,7 +236,7 @@ for (int i=0; i < (int) out.size(); i++) { - wchar_t c = out[i]; + // wchar_t c = out[i]; /* FIXME these hacks */ // if(c == L'/') // { @@ -228,40 +255,42 @@ // fputwc(L' ', output); // } fputws(out.c_str(), output); + fflush(output); } } alive_states.swap(new_states); } - // else if(outOfWord) // FIXME need to deal with superblank stuff - // { - // - // // wcout << (wchar_t) val << endl; - // if(val == L' ') - // { - // wstring blank = L""; - // blank += static_cast(val); - // blanks.push_back(blank); - // // wcout << "b" << blank << "b"; - // } - // else if(val == L'[') // tag - // { - // wstring blank = readFullBlock(input, L'[', L']'); - // blanks.push_back(blank); - // wcout << "b"<< blank<<"B"; - // } - // // FIXME anything between $ and ^ - // // else - // // { - // // fputwc(val, output); - // // continue; - // // } - // - // if(blanks.size() > 0) - // { - // // wcout << blanks.front(); - // blanks.pop_front(); - // } - // } + else if(outOfWord) // FIXME need to deal with superblank stuff + { + + // wcout << (wchar_t) val << endl; + if(val == L' ') + { + cout << "SPACE" ; + wstring blank = L""; + blank += static_cast(val); + blanks.push_back(blank); + // wcout << "b" << blank << "b"; + } + else if(val == L'[') // tag + { + wstring blank = readFullBlock(input, L'[', L']'); + blanks.push_back(blank); + wcout << "b"<< blank<<"B"; + } + /* FIXME anything between $ and ^*/ + else + { + fputwc(val, output); + continue; + } + + if(blanks.size() > 0) + { + // wcout << blanks.front(); + blanks.pop_front(); + } + } // else // { // wcerr << L"outOfWord error" << endl;