int a;
int y;
y = 5;
a = 3 * y + 5;
while( a == 3 && b == c )
{
y = 8;
a = 4;
while( 5 == 7 )
{
w = 5 * u;
}
xy = 57;
d = 8.2;
}
f = 3;
Entrega la siguiente tabla de símbolos y las siguientes gramáticas:
TABLA DE SIMBOLOS
-----------------------------------------------------------------------------------------
LEXEMA TIPO TOKEN TIPO DE DATO REGLA INDICE
-----------------------------------------------------------------------------------------
int PR int int ID 517
a ID int D(D|A)* 0
; SEP NULL S; 516
int PR int int ID 517
y ID int D(D|A)* 1
; SEP NULL S; 516
y ID ; D(D|A)* 2
= AS NULL ID = ID|num 800
5 NE int Aritm. 201
; SEP NULL S; 516
a ID ; D(D|A)* 3
= AS NULL ID = ID|num 800
3 NE int Aritm. 202
* OA Aritm. 510
y ID * D(D|A)* 4
+ OA Aritm. 512
5 NE int Aritm. 203
; SEP NULL S; 516
while PR 0
( PAR NULL (S) 701
a ID ( D(D|A)* 5
== OR 508
3 NE int Aritm. 204
&& OL 501
b ID && D(D|A)* 6
== OR 508
c ID == D(D|A)* 7
) PAR NULL (S) 702
{ LLA NULL {S} 801
y ID { D(D|A)* 8
= AS NULL ID = ID|num 800
8 NE int Aritm. 205
; SEP NULL S; 516
a ID ; D(D|A)* 9
= AS NULL ID = ID|num 800
4 NE int Aritm. 206
; SEP NULL S; 516
while PR 0
( PAR NULL (S) 701
5 NE int Aritm. 207
== OR 508
7 NE int Aritm. 208
) PAR NULL (S) 702
{ LLA NULL {S} 801
w ID { D(D|A)* 10
= AS NULL ID = ID|num 800
5 NE int Aritm. 209
* OA Aritm. 510
u ID * D(D|A)* 11
; SEP NULL S; 516
} LLA NULL {S} 802
xy ID } D(D|A)* 12
= AS NULL ID = ID|num 800
57 NE int Aritm. 210
; SEP NULL S; 516
d ID ; D(D|A)* 13
= AS NULL ID = ID|num 800
8.2 ND Aritm. 301
; SEP NULL S; 516
} LLA NULL {S} 802
f ID } D(D|A)* 14
= AS NULL ID = ID|num 800
3 NE int Aritm. 211
; SEP NULL S; 516
-----------------------------------------------------------------------------------------
=> G
=> int V
=> int ID;
=> G
=> int V
=> int ID;
=> G
=> ID = S
=> ID = NE;
=> G
=> ID = S
=> ID = NE * S
=> ID = NE * ID + S
=> ID = NE * ID + NE;
=> G
=> while(C){G}
=> while(ID OR NE OL C){G}
=> while(ID OR NE && C){G}
=> while(ID OR NE && ID OR ID){G}
=> while(ID OR NE && ID OR ID){G
=> while(ID OR NE && ID OR ID){ID = S
=> while(ID OR NE && ID OR ID){ID = NE;
=> while(ID OR NE && ID OR ID){ID = NE;G
=> while(ID OR NE && ID OR ID){ID = NE;ID = S
=> while(ID OR NE && ID OR ID){ID = NE;ID = NE;
=> while(ID OR NE && ID OR ID){ID = NE;ID = NE;G
=> while(ID OR NE && ID OR ID){ID = NE;ID = NE;while(C){G}
=> while(ID OR NE && ID OR ID){ID = NE;ID = NE;while(NE OR NE){G}
=> while(ID OR NE && ID OR ID){ID = NE;ID = NE;while(NE OR NE){G
=> while(ID OR NE && ID OR ID){ID = NE;ID = NE;while(NE OR NE){ID = S
=> while(ID OR NE && ID OR ID){ID = NE;ID = NE;while(NE OR NE){ID = NE * S
=> while(ID OR NE && ID OR ID){ID = NE;ID = NE;while(NE OR NE){ID = NE * ID;
=> while(ID OR NE && ID OR ID){ID = NE;ID = NE;while(NE OR NE){ID = NE * ID;}
=> while(ID OR NE && ID OR ID){ID = NE;ID = NE;while(NE OR NE){ID = NE * ID;}G
=> while(ID OR NE && ID OR ID){ID = NE;ID = NE;while(NE OR NE){ID = NE * ID;}ID = S
=> while(ID OR NE && ID OR ID){ID = NE;ID = NE;while(NE OR NE){ID = NE * ID;}ID = NE;
=> while(ID OR NE && ID OR ID){ID = NE;ID = NE;while(NE OR NE){ID = NE * ID;}ID = NE;G
=> while(ID OR NE && ID OR ID){ID = NE;ID = NE;while(NE OR NE){ID = NE * ID;}ID = NE;ID = S
=> while(ID OR NE && ID OR ID){ID = NE;ID = NE;while(NE OR NE){ID = NE * ID;}ID = NE;ID = ND;
=> while(ID OR NE && ID OR ID){ID = NE;ID = NE;while(NE OR NE){ID = NE * ID;}ID = NE;ID = ND;}
=> G
=> ID = S
=> ID = NE;
Nota: Los caracteres dentro del paréntesis para la expresión condicional del while se tienen que escribir de momento con espacios entre los paréntesis. Ejemplo: while( a == 5 ). Aún no reconoce expresiones sin espacios entre paréntesis, como la siguiente: while(a == 5).
El programa ya reconoce la gramatica while.
Por ejemplo, el programa siguiente:
Entrega la siguiente tabla de símbolos y las siguientes gramáticas:
Nota: Los caracteres dentro del paréntesis para la expresión condicional del while se tienen que escribir de momento con espacios entre los paréntesis. Ejemplo: while( a == 5 ). Aún no reconoce expresiones sin espacios entre paréntesis, como la siguiente: while(a == 5).