Tuesday 26 June 2007

Implementation of a LOOK AHEAD function with C++ for a PARSER/CONVERTER

//20070318ARS Break this line into its tokens
tokenSeq = 0;

while (tokenVal != "")
{
tokenVal = objTOKEN.get_ith_token (code_line, tokenSeq);
nextTokenVal = objTOKEN.get_ith_token (code_line, tokenSeq + 1);

if (nextTokenVal == "" && tokenVal != "" && !feof( stream ))
{
filePos = ftell( stream );

if (fgets( line_lookFW, 199, stream) == NULL) cout << "could not read in LookFW" << endl;

nextTokenVal = objTOKEN.get_ith_token (line_lookFW, 0);
cout << "line_lookFW nextTokenVal=" << nextTokenVal << endl;

while (nextTokenVal == "" && !feof( stream ))
{
if (fgets( line_lookFW, 199, stream) == NULL) cout << "could not read in LookFW" << endl;
nextTokenVal = objTOKEN.get_ith_token (line_lookFW, 0);
cout << "1line_lookFW nextTokenVal=" << nextTokenVal << endl;
}
result = fseek( stream, filePos, SEEK_SET);
if (result) printf( "line_lookFW Fseek failedddddddd" );
if (nextTokenVal == "") cout << "EOFFFFFFFFFFffff" << endl;
}

if (tokenVal == "") //tokens on the line are finished
{
cout << "tokens on the line are finished" << endl;
}
else //tokens on the line are being processed.............




//20070318ARS Break this line into its tokens
tokenSeq = 0;

while (tokenVal != "")
{
tokenVal = objTOKEN.get_ith_token (code_line, tokenSeq);
nextTokenVal = objTOKEN.get_ith_token (code_line, tokenSeq + 1);

if (nextTokenVal == "" && tokenVal != "" && !feof( stream ))
{
filePos = ftell( stream );

if (fgets( line_lookFW, 199, stream) == NULL) cout << "could not read in LookFW" << endl;

nextTokenVal = objTOKEN.get_ith_token (line_lookFW, 0);
cout << "line_lookFW nextTokenVal=" << nextTokenVal << endl;

while (nextTokenVal == "" && !feof( stream ))
{
if (fgets( line_lookFW, 199, stream) == NULL) cout << "could not read in LookFW" << endl;
nextTokenVal = objTOKEN.get_ith_token (line_lookFW, 0);
cout << "1line_lookFW nextTokenVal=" << nextTokenVal << endl;
}
result = fseek( stream, filePos, SEEK_SET);
if (result) printf( "line_lookFW Fseek failedddddddd" );
if (nextTokenVal == "") cout << "EOFFFFFFFFFFffff" << endl;
}

if (tokenVal == "") //tokens on the line are finished
{
cout << "tokens on the line are finished" << endl;
}
else //tokens on the line are being processed.............