Sei sulla pagina 1di 3

Problema 1

S-> E
E-> class id { {: B.padreh = id; :} B ;
B -> {: L.padreh = B.padreh; :} L }
|}
L-> public: {: C.padreh = L.padreh; :} C private: {: C1.padreh = L.padreh; :} C
{: C.vistah = public; :}
{: C1.vistah = private; :}
| private: {: C.padreh = L.padreh; :} C public: {: C1.padreh = L.padreh; :} C
{: C.vistah = private; :}
{: C1.vistah=public;
:}
| private: {: C.padreh = L.padreh; C.vistah = private; :} C
| public: {: C1.padreh = L.padreh; C.vistah = public; :} C
C -> {: C1.padreh=C.padreh; C1.vistah=C.vistah; :} C {: F.padreh = C.padreh; F.vistah = C.vistah; :} F
| {: F.padreh = C.padreh; F.vistah = C.vistah :} F
F -> class id {: B.padreh = id; :} { B {: Printf (clase,F.padreh,::,id,::,F.vistah); :}
|TIPO id ( PAR ; {: if (TIPO.tip==1){TIPO.cad = entero;} else { TIPO.cad = real; }
{: Printf (metodo,F.padreh,::,id,::,F.vistah,devuelve,TIPO.cad,
{:
,,recibe,PAR.entero,enteros y, PAR.real,reales);
PAR -> LIST ) {: PAR.entero = LIST.entero; PAR.real = LISTA.real; :}
| )

{: PAR.entero = 0; PAR.real = 0; :}

LIST -> LIST , TIPO id {: LIST.entero = LIST1.entero; LIST.real = LIST1.real;


:}
{: If(TIPO.tip==1) { LIST.entero++; } else { LIST.real++; } :}
| TIPO id {: LIST.entero =0; LIST.real =0;
:}
{: If(TIPO.tip==1) { LIST.entero++; } :}
{: else { LIST.real++; }
:}
TIPO -> int {: TIPO.TIP = 1; :}
| real {: TIPO.TIP = 0; :}

:}
:}
:}

Problema 2 (Ascendente)
S -> M {: Print(M.cad); :}
M-> M , [ L {: M.cad = concat([,L.cad,,,M.cad); :}
| [ L {: M.cad = concat([,L.cad); :}
L -> H ] {: L.cad = concat(H.cad,]); :}
| ] {: L.cad = ]; :}
H -> H , E {: E.cad = Convert(E.val); H.cad = Concat(H1.cad,,,E.cad); :}
{: If(E.val>H1.max) { H.max = E.val; }
:}
{: else { H.max = H1.max;} :}
:}
| E {: H.cad = Convert(E.val); H.max = E.val; :}
E -> E + T {: E.val = E1.val+T.val; :}
|T {: E.val = T.val; :}
T -> T * F {: T.val = T1.val*F.val; :}
|F {: T.val = F.val; :}
F -> num {: F.val = getval(num); :}
Problema 2 (Descendente)
S -> M {: Print(M.cad); :}
M -> L ] , M {: M.cad = concat(M.cad,,,L.cad,]); :}
| L ] {: M.cad = concat(L.cad,]); :}
L -> [ H {: L.cad = concat([,H.cad); :}
| [ {: L.cad = [; :}
H -> E , H {: E.cad = Convert(E.val); H.cad = Concat(E.cad,,,H1.cad); :}
{: If(E.val>H1.max) { H.max = E.val; }
:}
{: else { H.max = H1.max;} :}
:}
| E {: H.cad = Convert(E.val); H.max = E.val; :}
E -> T {: T.hval = E.hval; :} E {: E.val = E.sval; :}

E -> + T {: E1.hval = E.hval+T.val; :} E {: E.sval = E1.hval; :}


| {: E.sval = E.hval; :}
T -> F {: T.val = F.val; :} T {: T.val = T.sval; :}
T -> * T {: T1.hval = T.hval *F.val; :} T {: T.sval = T1.hval; :}
| {: T.sval = T.hval; :}
F -> num {: F.val = getval(num); :}

Potrebbero piacerti anche