Arbol Optimizado Flores López Angel Raymundo
objeto:- write('{'), read(X),(X='atributo'->atributo;
write('')),a1,
write('}').
arreglo:- write('['), read(X),(X='valor'->valor;
write('')),a2,
write(']').
a1:- read(X),(X='atributo'->write(','),atributo,a1;
X='fin'->write('')).
a2:- read(X),(X='valor'->write(','),valor,a2;
X='fin'->write('')).
atributo:- cadena, write(':'), valor.
valor:- read(X), (X='numero'->numero;
X='cadena'->cadena;
X='objeto'->objeto;
X='arreglo'->arreglo;
X='metodo'->metodo).
cadena:- write('"'),read(X),write(X),write('"').
numero:- read(X),write(X).
metodo:- write('"function() {'),instruccion,write('}"').
instruccion:- read(X), (X='asignacion'->asignacion,instruccion;
X='decision'->decision,instruccion;
X='finsub'->write('');
X='finm'->write(' return '),read(Y),write(Y),write(';')).
decision:- write('if ('),numero,write(')'),verdadero.
verdadero:- write('{'),instruccion,write('}'),falso.
falso:- read(X),(X='otro'->write('else{'),instruccion,write('}');write('')).
asignacion:- numero,write('='),numero,write('; ').
:- objeto.
|
run
| edit
| history
| help
|
0
|
|
|