Vous êtes sur la page 1sur 1

int A ( ) { int Sh, Bv, Av, Ss; Bv = B ( );

A B { Sh = Bv } S { Av = Ss } S +B { S1h = Sh + Bv } S1 { Ss = S1s } S - B { S1h = Sh - Bv } S1 { Ss = S1s } S e { Ss = Sh } .... C num { Cv = atoi ( lookahead lexema ) } C id { Cv = lookaheadsimbvalor } C ( A ) { Cv = Av } Sh = Bv; Ss = S ( Sh ); Av = Ss return Av;

} int S ( int Sh ) { int Bv, S1h, S1s, Ss; if ( lookAheadlexema[0] == + ) { lookAhead = lookAheadprox; Bv = B( );
S1h = Sh + Bv; S1s = S ( S1h );

Analex.h Struct token { char lexema ... } struct token * analex ( char * a ); .h Analex.c

Ss = S1s; } else if ( lookAheadlexema[0] == - ) { lookAhead = lookAheadprox; Bv = B( );


S1h = Sh - Bv; S1s = S ( S1h );

.c main.c #include <analex.h> #include <anasinx.h> lookAhead (Global) lookAhead = analex ( extrada.txt); result = A( ); Anasin.h int A ( ); // prototipo Anasin.c #include <analex.h> extern struct token lookAhead; ...... }

Ss = S1s; } else { Ss = Sh; } return Ss;

//C id { Cv = lookaheadsimbvalor }

int C ( ) { if ( ... ) { } else if (lookaheadtipo == 1 ) { aux = lookaheadsimbvalor; lookAhead = lookAheadprox;


Cv = aux;

} else if ( ... ) {} else ERRO ( operando ou ( esperado );

Vous aimerez peut-être aussi