Разработка транслятора с языка PROST на язык С++, страница 3

continue;

}

if(lex[i][0] == 20 && lex[i][1] == 4)

{

pop(&stack);

push(&stack,EXPR);

push(&stack,EXPRESSION);

i++;

continue;

}

if(lex[i][0] == 20 && lex[i][1] == 0)

{

pop(&stack);

push(&stack,EXPR);

push(&stack,CS);

push(&stack,EXPRESSION);

i++;

continue;

}

}

case EXPR:

{

if(lex[i][0] == 20 && ( lex[i][1] == 3  ||

lex[i][1] == 4  ||

lex[i][1] == 5  ||

lex[i][1] == 6) )

{

pop(&stack);

push(&stack,EXPR);

push(&stack,EXPRESSION);

push(&stack,BINOP);

continue;

}

if(lex[i][0] == 20 && ( lex[i][1] == 7  ||

lex[i][1] == 8  ||

lex[i][1] == 13 ||

lex[i][1] == 11 ||

lex[i][1] == 10 ||

lex[i][1] == 9  ||

lex[i][1] == 1  ||

lex[i][1] == 2) )

{

pop(&stack);

continue;

}

}

case ELSE:

{

if(lex[i][0] == 10 && ( lex[i][1] == 5  ||

lex[i][1] == 1  ||

lex[i][1] == 12 ||

lex[i][1] == 6  ||

lex[i][1] == 14 ||

lex[i][1] == 9  ||

lex[i][1] == 11) )

{

pop(&stack);

continue;

}

if(lex[i][0] == 30)

{

pop(&stack);

continue;

}

if(lex[i][0] == 10 && lex[i][1] == 10)

{

pop(&stack);

push(&stack,OPERATORS);

i++;

fprintf(out,"  else {\n");

continue;

}

}

case OPERATOR:

if(lex[i][0] == 10 && ( lex[i][1] == 5 ||

lex[i][1] == 6 ||

lex[i][1] == 11) )

{

pop(&stack);

push(&stack,TZ);

push(&stack,ID);

i++;

if(lex[i-1][1] == 5)flag = 1;

if(lex[i-1][1] == 6)fprintf(out,"  cout<<\"\\n>>: \";\n  cin>>");

if(lex[i-1][1] == 11)fprintf(out," goto ");

continue;

}

if(lex[i][0] == 30)

{

pop(&stack);

push(&stack,TZ);

push(&stack,EXPRESSION);

push(&stack,PRISV);

i++;

fprintf(out,"  %s",T_id[lex[i-1][1]]);

continue;

}

if(lex[i][0] == 10 && lex[i][1] == 12)

{

pop(&stack);

push(&stack,OPERATORS);

push(&stack,Do);

push(&stack,CS);

push(&stack,EXPRESSION);

push(&stack,CONDITION);

push(&stack,EXPRESSION);

push(&stack,OS);

i++;

fprintf(out,"  while");

continue;

}

if(lex[i][0] == 10 && lex[i][1] == 14)

{

pop(&stack);

push(&stack,TZ);

push(&stack,EXPRESSION);

i++;

fprintf(out,"  cout<<\"\\n<<: \"<<");

continue;

}

if(lex[i][0] == 10 && lex[i][1] == 9)

{

pop(&stack);

push(&stack,TZ);

push(&stack,STRC);

i++;

fprintf(out," cout<<");

continue;

}

if(lex[i][0] == 10 && lex[i][1] == 7)

{

pop(&stack);

push(&stack,ELSE);

push(&stack,OPERATORS);

push(&stack,then);

push(&stack,CS);

push(&stack,EXPRESSION);

push(&stack,CONDITION);

push(&stack,EXPRESSION);

push(&stack,OS);

i++;

fprintf(out,"  if");

continue;

}

case OPERATORS:

if(lex[i][0] == 10 && ( lex[i][1] == 5  ||

lex[i][1] == 12 ||

lex[i][1] == 6  ||

lex[i][1] == 14 ||

lex[i][1] == 9  ||

lex[i][1] == 11 ||

lex[i][1] == 7) )

{

pop(&stack);

push(&stack,OPERATORS);

push(&stack,OPERATOR);

continue;

}

if(lex[i][0] == 30)

{

pop(&stack);

push(&stack,OPERATORS);

push(&stack,OPERATOR);

continue;

}

if(lex[i][0] == 10 && lex[i][1] == 17)

{

i+=2;

fprintf(out," break;\n");