Wednesday 27 June 2007

Statement continuation for a Parser/converter from Natural to JAVA

Statement continuation includes parsing and
conversion processes. This outline excludes
statements related to conversion and simplifies
the program generally.

// ADD A + 1 TO B GIVING C
// ADD A + 1 TO B END

void continueADDstatement(std::string tokenVal)
{
//if END
if (tokenVal == "END")
{
endADDstatementWithoutGiving();
return;
}
//if move
if (object.last(head)->meaning == "ADD")
{
if (tokenVal == "TO")
{

//push CONDITION from the calcSTACK to the tokenSTACK
… object.push(head,statement_text,"CALC");

head=object.push(head, tokenVal, "ADD-TO");
}
else
{
//call CONDITION processing with (tokenVal)Take in(A + 1)
calcPARSE(tokenVal);
}
}
else
//if parm2 (B)
if (object.last(head)->meaning == "ADD-TO")
{
head=object.push(head, tokenVal, "ADD-PARM2");

if (objTOKEN.is_characteristic(nextTokenVal) nextTokenVal == "END-IF") //if End of statement
{
endADDstatementWithoutGiving();
}
}
else
//if giving
if (object.last(head)->meaning == "ADD-PARM2")
{
head=object.push(head, tokenVal, "ADD-GIVING");
}
else
//if parm3
if (object.last(head)->meaning == "ADD-GIVING")
{
head=object.push(head, tokenVal, "ADD-PARM3");

// CONVERT


JAVA_statement_text = "" + PARM3_text + " = " + PARM2_text + " + " + PARM1_text + ";" + "\n";

fputs( JAVA_statement_text.c_str(), outFile);
}

if (instrObject.pop(instrHead) == NULL) instrHead = NULL;

if (instrHead == NULL) object.stack_delete();
}
}
void endADDstatementWithoutGiving()
{

// pop the TOKEN stack and create the output code line for MOVE
// CONVERTTTTTTTTTTTTTTTTTTTTttttttttttttttt

JAVA_statement_text = PARM2_text + ".add(" + PARM1_text + ");\n";

//if (head == NULL)
if (opened_output_file == true)
{
fputs( JAVA_statement_text.c_str(), outFile);
}

if (instrObject.pop(instrHead) == NULL) instrHead = NULL;

if (instrHead == NULL) object.stack_delete();
instrObject.stack_display(instrHead);
object.stack_display(head);
}