Thursday 28 June 2007

Actual Conversion in Converting Natural Programs to JAVA

Add statement without giving key word is chosen
to demonstrate the conversion process… The parts
related to parsing and other keyword options are
omitted.

In the conversion process, the tokens are popped
from the token stack and placed in param vars
according to their spatial positions. The JAVA
statement is assembled from these variables.
The JAVA statement is written into the output
file.

The instruction stack and the token stack are
cleaned.


void beginADDstatement()
{

}

void continueADDstatement(std::string tokenVal)
{
if (tokenVal == "END")
{
endADDstatementWithoutGiving();
return;
}

if (object.last(head)->meaning == "ADD")
{

else
//if parm2
if (object.last(head)->meaning == "ADD-TO")
{
head=object.push(head, tokenVal, "ADD-PARM2");
cout << "ADDprocessss tokenVal=" << nexttokenval=" << nextTokenVal << endl; if (objTOKEN.is_characteristic(nextTokenVal) nextTokenVal == " statement_text = "\n" statement_text =" object.last(head)-">element + statement_text;
PARM2_text = object.last(head)->element;
PARM2_text = convertVarNames(PARM2_text);

if (object.pop(head) == NULL) head = NULL;
else statement_text = object.last(head)->element + " " + statement_text;
if (object.pop(head) == NULL) head = NULL;
else
{
statement_text = object.last(head)->element + " " + statement_text;
PARM1_text = object.last(head)->element;
PARM1_text = convertVarNames(PARM1_text);
}
if (object.pop(head) == NULL) head = NULL;
else statement_text = object.last(head)->element + " " + statement_text;
if (object.pop(head) == NULL) head = NULL;

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

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);
}