. , , ,

,,,

FORTRAN — ,

, .

.

.

FORTRAN.

: .

: .

: 513.

: .

: .

: .

: 30 1997 .

:


.


.

FORTRAN.

IF(<>) LABEL1,LABEL2,LABEL3

- .

LABEL1,LABEL2,LABEL3 - ,

.


.

G[<>]:

1.  <> IF(<>)

2. 

3.  <> T | <>+T | <>-T

4.  T O | T*O | T/O | T**O

5.  O (<>) | <> | <>

6.  <> {|}

7.  <> {}[L]

8.  <> {}[.{}]

:

.

.

.

.

.

**

.

LABEL

.

.

L

().

.


.

G[<>], , -, , , .

A a, AÎVn, aÎV*.

G[<>] , . S - .


.

, -.

, (), , .

.

C++, .


.

. .

, , , (), .


.

¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

IF(((6/t+g*456)/(9.347*y-555))**6) 64,44,548

¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

( - 40.

AB - .

( - 40.

Term - .

Operand - .

AB - .

( - 40.

Term - .

Operand - .

AB - .

6 - 54.

Term - .

Operand - .

IDENT - 6.

FLOAT - 6.

/ - 47.

t - 116.

Term - .

Operand - .

IDENT - t.

+ - 43.

AB - .

g - 103.

Term - .

Operand - .

IDENT - g.

* - 42.

4 - 52.

Term - .

Operand - .

IDENT - 4.

FLOAT - 4.

5 - 53.

6 - 54.

) - 41.

/ - 47.

( - 40.

Term - .

Operand - .

AB - .

9 - 57.

Term - .

Operand - .

IDENT - 9.

FLOAT - 9.

. - 46.

3 - 51.

4 - 52.

7 - 55.

* - 42.

y - 121.

Term - .

Operand - .

IDENT - y.

- - 45.

AB - .

5 - 53.

Term - .

Operand - .

IDENT - 5.

FLOAT - 5.

5 - 53.

5 - 53.

) - 41.

) - 41.

* - 42.

* - 42.

6 - 54.

Term - .

Operand - .

IDENT - 6.

FLOAT - 6.

) - 41.

렠 - 32.

6 - 54.

ABS - 6.

4 - 52.

, - 44.

4 - 52.

ABS - 4.

4 - 52.

, - 44.

5 - 53.

ABS - 5.

4 - 52.

8 - 56.

NULL - 0.

¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

IF(r**34/50.22) 3,56,1

¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

( - 40.

AB - .

r - 114.

Term - .

Operand - .

IDENT - r.

* - 42.

* - 42.

3 - 51.

Term - .

Operand - .

IDENT - 3.

FLOAT - 3.

4 - 52.

/ - 47.

5 - 53.

Term - .

Operand - .

IDENT - 5.

FLOAT - 5.

0 - 48.

. - 46.

2 - 50.

2 - 50.

) - 41.

렠 - 32.

3 - 51.

ABS - 3.

, - 44.

5 - 53.

ABS - 5.

6 - 54.

, - 44.

1 - 49.

ABS - 1.

NULL - 0.

¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾


.

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

// FILE "KURSOVIC.CPP".

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

// H # 2.

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

// FORTRAN.

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

// pࠠ : .

// pࠠ : -513.

// 򠠠 : .

// p : , p p p,

// 򠠠 p p.

// ࠠ : 30 1997.

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

// .

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

# include

# include

# include

# include

# include "keyboard.h"

# include

# include

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

// .

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

# define FILE_NAME "TEXT.TXT"

# define YES 1

# define NO 2

# define OK 3

//# define TEST

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

// .

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

char file1[22][60]; // .

char mes[22][30][50]; // .

char bufer[4096]; // .

int com=0; // : .

int pos=2; // .

char string[80]; // .

char nx; // .

int e1=0; // .

int e2=0; // .

int l=0; // .

FILE* fl=fopen("MESSAGE.TXT","wt"); // .

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

// .

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

void Windows(int,int,int,int,char*); // .

void Beep(int,int); // .

void Open_File(void); // .

void Second_Window(void); // .

void MyPuts(char*,int); // puts(char*).

void Print_File(void); // .

void Menu(void); // .

int i_readkey(void); // .

void Help(void); // .

void Grammar(void); // .

void Language(void); // .

void Compile(void); // .

void Operator(char*); // .

void Scan(void); // .

void Label(void); // Label.

int ABS(void); // ABS.

int IDENT(void); // IDENT.

int AB(void); // AB.

void Error(int); // .

int Term(void); // Term.

int Operand(void); // Operand.

int Float(void); // Float.

void Message(int); // .

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

// MAIN.

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

void main()

{

_setcursortype(_SOLIDCURSOR);

window(1,1,80,25);

textattr(113);

clrscr();

for(int i=0;i<24;i++)

cputs("ŽŽŽŽŽŽŽŽŽŽŽŽŽŽŽŽŽŽŽŽŽŽŽŽŽŽŽŽŽŽŽŽŽŽŽŽŽŽŽŽŽŽŽŽŽŽŽŽŽŽ");

textcolor(BLACK);

cputs(" Enter filename");

window(20,7,60,17);

textattr(127);

clrscr();

Windows(20,7,60,17,"Open a File");

gotoxy(4,3);

puts("Name ");

gotoxy(6,7);

puts(" ");

gotoxy(17,8);

puts(FILE_NAME);

window(23,10,57,10);

textattr(31);

clrscr();

Open_File();

Second_Window();

Print_File();

_setcursortype(_NOCURSOR);

Menu();

}

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

// .

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

void Beep(int tone,int pause)

{

sound(tone);

delay(pause);

nosound();

}

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

// .

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

void Windows(int x,int y,int x1,int y1,char* string)

{

y1++;

for(int i=2;i

{

gotoxy(i,1);

putch('=');

gotoxy(i,y1-y);

putch('=');

}

for(i=1;i

{

gotoxy(2,i);

putch('');

gotoxy(x1-x,i);

putch('');

}

gotoxy(2,1);

putch('');

gotoxy(x1-x,1);

putch('');

gotoxy(x1-x,y1-y);

putch('-');

gotoxy(2,y1-y);

putch('L');

gotoxy((x1-x-strlen(string)+2)/2,1);

puts(string);

}

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

// .

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

void Open_File(void)

{

char filename[38];

filename[0]=35;

char* p=cgets(filename);

strcpy(filename,p);

if(filename[0]==NULL)

strcpy(filename,FILE_NAME);

FILE *file;

if ((file = fopen(filename, "rt"))== NULL)

{

window(1,1,80,25);

textattr(7);

_setcursortype(_NORMALCURSOR);

clrscr();

perror("ERROR");

fcloseall();

getch();

exit(1);

}

for(int i=0;i<22;i++)

{

char temp[255];

if((fgets(temp,80,file))==NULL)

break;

strcpy(file1[i],temp);

}

fclose(file);

}

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

// .

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

void Second_Window(void)

{

window(1,1,80,25);

textattr(17);

clrscr();

window(1,1,80,24);

textattr(31);

clrscr();

Windows(1,1,80,24,"File");

window(1,25,80,25);

textattr(127);

clrscr();

MyPuts(" ~F1~ Help ~F2~ Grammar ~F3~ Language ~F4~ Compile ~ESC~ Exit",

LIGHTBLUE);

}

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

// MyPuts.

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

void MyPuts(char* string,int color)

{

int j=0;

for(int i=0;string[i] != NULL;i++)

{

if(string[i]=='~' && j==0)

{

textcolor(color);

i++;

j++;

}

if(string[i]=='~' && j!=0)

{

textcolor(BLACK);

i++;

j--;

}

cprintf("%c",string[i]);

if(string[i]==NULL)

break;

}

}

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

// .

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

void Print_File(void)

{

window(3,2,77,24);

textattr(31);

for(int i=0;i<22;i++)

{

cputs(file1[i]);

putch('r');

}

}

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

// .

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

void Menu(void)

{

gettext(1,1,80,25,bufer); // .

int y=1; // .

gotoxy(1,1);

textattr(63);

clreol();

cputs(file1[0]);

textattr(31);

gotoxy(5,23);

cprintf(" %-2d ",y);

while(1)

{

switch (i_readkey())

{

case EASC_F1:

gettext(1,1,80,25,bufer);

Help();

puttext(1,1,80,25,bufer);

break;

case EASC_F2:

gettext(1,1,80,25,bufer);

Grammar();

puttext(1,1,80,25,bufer);

break;

case EASC_F3:

gettext(1,1,80,25,bufer);

Language();

puttext(1,1,80,25,bufer);

break;

case EASC_F4:

gettext(1,1,80,25,bufer);

Compile();

puttext(1,1,80,25,bufer);

window(48,2,78,23);

textattr(95);

clrscr();

Windows(49,3,79,24,"Message");

Message(y-1);

break;

case EASC_Esc:

window(1,1,80,25);

textattr(7);

clrscr();

fcloseall();

exit(1);

break;

case EASC_Up:

if(y>1)

{

if(com>0)

window(3,2,47,24);

else

window(3,2,77,24);

y--;

gotoxy(1,y);

textattr(63);

clreol();

cputs(file1[y-1]);

gotoxy(1,y+1);

textattr(31);

clreol();

cputs(file1[y]);

gotoxy(5,23);

cprintf(" %d ",y);

if(com>0)

Message(y-1);

}

break;

case EASC_Down:

if(y<22)

{

if(com>0)

window(3,2,47,24);

else

window(3,2,77,24);

gotoxy(1,++y);

textattr(63);

clreol();

cputs(file1[y-1]);

gotoxy(1,y-1);

textattr(31);

clreol();

cputs(file1[y-2]);

gotoxy(5,23);

cprintf(" %d ",y);

if(com>0)

Message(y-1);

}

break;

}

}

}

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

// Help.

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

void Help(void)

{

window(1,1,80,25);

textattr(78);

clrscr();

Windows(1,1,80,25,"Help");

window(4,3,77,23);

cprintf("

nnr");

cprintf(" nnr");

cprintf(" :nr");

cprintf(" " FORTRAN".nnr");

cprintf(" -513nnr");

cprintf(" .nnr");

cprintf(" :nr");

cprintf(" F1 - Help.nr");

cprintf(" F2 - .nr");

cprintf(" F3 - .nr");

cprintf(" F4 - .nr");

cprintf(" ESC - .nnr");

cprintf(" Help .");

getch();

}

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

// .

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

void Grammar(void)

{

window(10,2,70,23);

textattr(46);

clrscr();

Windows(10,2,70,23,"Grammar");

window(12,4,68,22);

cprintf(" 1. <> -> IF(<>)

cprintf(" 2.

cprintf(" 3. <> -> T | <>+T | <>-Tnr");

cprintf(" 4. T -> O | T*O | T/O | T**Onr");

cprintf(" 5. O -> (<>) | <> | <>nr");

cprintf(" 6. <> -> {|}nr");

cprintf(" 7. <> -> {}nr");

cprintf(" 8. <> -> {}[.{}]nnr");

cprintf(" :nr");

cprintf(" T - .nr");

cprintf(" O - .nr");

cprintf(" - .nr");

cprintf(" ֠ - .nr");

cprintf(" Ǡ - .nr");

cprintf(" Ǡ - .nr");

cprintf(" ** - .nr");

cprintf("

cprintf(" <> - .");

getch();

}

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

// .

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

void Language(void)

{

window(20,7,60,17);

textattr(62);

clrscr();

Windows(20,7,60,17,"Language");

window(22,9,58,16);

cprintf(" IF(<>) LABEL1,LABEL2,LABEL3nnr");

cprintf(" - .nr");

cprintf(" LABEL1,LABEL2,LABEL3 - , .nr");

getch();

}

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

// .

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

void Compile(void)

{

window(20,7,55,13);

textattr(94);

clrscr();

Windows(20,7,55,13,"Compile");

window(22,8,58,16);

gotoxy(1,1);

if(com!=0)

{

cprintf("nn !");

Beep(900,1000);

return;

}

cputs("n .rnn , ...");

#ifdef TEST

window(1,1,80,25);

clrscr();

#endif

for(int i=0;file1[i][0]!=NULL;i++)

{

Operator(file1[i]);

if(l!=3 && l!=0)

Error(11);

e1++;

e2=0;

}

com++;

delay(300);

Beep(1000,200);

}

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

// .

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

void Operator(char* str)

{

pos=2;

l=0;

string[0]=NULL;

strcpy(string,str);

string[strlen(string)-1]=NULL;

char temp[3];

temp[0]=str[0];

temp[1]=str[1];

temp[2]=NULL;

#ifdef TEST

puts(string);

puts(temp);

getch();

#endif

fprintf(fl," ¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾n");

fprintf(fl,"%sn",string);

if(strcmp(temp,"IF")!=0)

{

#ifdef TEST

printf(" IF.n");

#endif

Error(10);

return;

}

Scan();

if(nx==' ')

Scan();

if(nx!='(')

Error(7);

if(nx==NULL)

{

Error(12);

Error(9);

return;

}

AB();

while(nx!=')' && nx!=NULL && nx!=' ')

Scan();

if(nx!=')')

Error(3);

if(nx==NULL)

{

Error(9);

return;

}

Scan();

if(nx==NULL)

{

Error(9);

return;

}

if(nx==' ')

Scan();

Label();

if(nx!=',')

{

Error(5);

Scan();

}

else

Scan();

if(nx==NULL)

return;

Label();

if(nx!=',')

{

Error(5);

Scan();

}

else

Scan();

if(nx==NULL)

return;

Label();

if(nx!=NULL)

{

Error(6);

Scan();

}

return;

}

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

// Scan.

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

void Scan(void)

{

nx=string[pos++];

#ifdef TEST

printf(" %c - %d.n",nx,nx);

#endif

fprintf(fl," %c - %d.n",nx,nx);

}

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

// .

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

void Label(void)

{

if(ABS() == NO)

{

Error(8);

Scan();

}

else

l++;

}

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

// .

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

int ABS(void)

{

#ifdef TEST

cprintf("ABS - %c.rn",nx);

#endif

fprintf(fl,"ABS - %c.n",nx);

if(isdigit(nx))

{

while(isdigit(nx))

Scan();

return(YES);

}

return(NO);

}

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

// .

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

int AB(void)

{

#ifdef TEST

cprintf("AB - .rn");

#endif

fprintf(fl,"AB - .n");

Scan();

if(nx==')')

{

Error(12);

return(NO);

}

Term();

if(nx=='+')

{

AB();

}

else if(nx=='-')

{

AB();

}

if(nx==NULL)

return(OK);

else if(nx!='*' && nx!='/' && nx!=')')

Error(1);

return(YES);

}

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

// .

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

int Term(void)

{

#ifdef TEST

cprintf("Term - .rn");

#endif

fprintf(fl,"Term - .n");

Operand();

if(nx=='/')

{

Scan();

Term();

}

else if(nx=='*')

{

Scan();

if(nx=='*')

{

Scan();

Term();

}

else Term();

}

if(nx==NULL)

return(OK);

else if(nx!='+' && nx!='-' && nx!=')')

Error(2);

return(OK);

}

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

// .

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

int Operand(void)

{

#ifdef TEST

cprintf("Operand - .rn");

#endif

fprintf(fl,"Operand - .n");

if(nx=='(')

{

AB();

if(nx!=')')

Error(3);

else

{

Scan();

return(OK);

}

}

else if(IDENT() == NO)

{

if(Float() == NO)

Error(4);

}

return(OK);

}

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

// .

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

int IDENT(void)

{

#ifdef TEST

cprintf("IDENT - %c.rn",nx);

#endif

fprintf(fl,"IDENT - %c.n",nx);

if(isalpha(nx))

{

while(isalpha(nx) || isdigit(nx))

Scan();

return(YES);

}

return(NO);

}

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

// .

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

void Error(int num)

{

char *E[]={

" '+' '-'.",

" '*','/' '**'.",

" ).",

" .",

" ','.",

" .",

" (.",

" - .",

" .",

" IF.",

" .",

" AB.",

NULL

};

sprintf(mes[e1][e2],"%s",E[num-1]);

e2++;

#ifdef TEST

Beep(1000,100);

cprintf(": %srn",E[num-1]);

getch();

#endif

fprintf(fl," ¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾n");

fprintf(fl,": %srn",E[num-1]);

}

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

// Float.

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

int Float(void)

{

#ifdef TEST

cprintf("FLOAT - %c.rn",nx);

#endif

fprintf(fl,"FLOAT - %c.n",nx);

if(isdigit(nx))

{

while(isdigit(nx))

Scan();

if(nx=='.')

{

Scan();

while(isdigit(nx))

Scan();

}

return(YES);

}

return(NO);

}

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

// Message.

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

void Message(int x)

{

window(50,3,76,22);

textattr(95);

clrscr();

gotoxy(1,1);

for(int i=0;mes[x][i][0]!=NULL;i++)

cprintf("%srn",mes[x][i]);

}

//¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾


.

1. .

2. C .

, . . .

 

 

 

! , , , .
. , :