.


:




:

































 

 

 

 


-




 

 

- , .. (_, __). :

1) , (!,!F, R, W) , ;

2) 0, .. (0,p) - , p- ;

3) , -- -- (, ), - 4, - 5.

, P, free - :

 

#define MAXLEN_P 10000

struct lex

{int class;

int value;}

struct lex P [ MAXLEN_P];

int free = 0;

 

P put_lex:

 

void put_lex (struct lex l)

{P[ free++] = l;}

 

, - put_lex5, , 4- 5- ( value):

 

void put_lex5 (struct lex l)

{ l.class = 5; P[ free++] = l;}

 

struct lex make_op(char *op),

op (2, i), i - .

 

, , "" ; , , .

, :

 

void checkop_p (void)

{char *op; char *t1; char *t2; char *res;

t2 = spop(); op = spop(); t1 = spop();

res = gettype (op,t1,t2);

if (strcmp (res, "no"))

{spush (res);

put_lex (make_op (op));} /* ! -

op */

else ERROR();

}

 

, , :

E E1 | E1 [ = | > | < ] < spush (TD [curr_lex.value]) > E1 < checkop_p() >

E1 T { [ + | - | or] < spush (TD [curr_lex.value]) > T < checkop_p() > }

T F { [ * | / | and] < spush (TD [curr_lex.value]) > F < checkop_p() > }

F I < checkid(); put_lex (curr_lex) > | N < spush("int"); put_lex (curr_lex) > |

[ true | false ] < spush ("bool"); put_lex (curr_lex) > |

not F < checknot(); put_lex (make_op ("not")) > | (E)

 

, , :

S I < checkid(); put_lex5 (curr_lex) >:=

E < eqtype(); put_lex (make_op (":=")) >

 

P . if E then S1 else S2 , " " :

if (!E) goto l2; S1; goto l3; l2: S2; l3:...

P, , , , .

struct lex make_labl (int k),

- (0,k).

, , :

S if E < eqbool(); pl2 = free++; put_lex (make_op ("!F")) >

then S < pl3 = free++; put_lex (make_op ("!")); P[pl2] = make_labl (free) >

else S < P[pl3] = make_lable (free) >

 

: pl2 pl3 S, .

.





:


: 2017-02-25; !; : 445 |


:

:

- - , .
==> ...

929 - | 972 -


© 2015-2024 lektsii.org - -

: 0.01 .