Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
2 - codificador JSON If anidados y else
objeto :- write('{'),aux1, write('}'). atributo :-cadena, write(':'),valor,aux2. aux1 :- read(X),(X='atributo'->atributo; X='fin'->write('')). aux2 :- read(X),(X='atributo'->write(','),atributo; X='fin'->write('')). aux3 :- read(X),(X='valor'->valor,aux4; X='fin'->write('')). aux4 :- read(X),(X='valor'->write(','),valor,aux4; X='fin'->write('')). aux5 :- read(X), (X='return' -> return; X='fin'->write('')). cadena :- read(X),write('"'),write(X),write('"'). numero :- read(X),write(X). booleano :- read(X),write(X). arreglo :- write('['), aux3, write(']'). metodo :- write('"function () {'),instruccion, write('}"'). instruccion :- read(X),(X='asignacion'->asignacion,instruccion; X='decision'-> decision , instruccion; X='else' ->else ,instruccion; X='elseif' ->elseif ,instruccion; X='return'->return , instruccion; X='fin'->write('')). finMetodo :- write(' }"'). asignacion :- read(X) , write(X), write('=') , read(Y) , write(Y) ,write(';'). decision :- write('if (') , read(X) , write(X) , write(') {') , instruccion , write('}'). else :- write('else') , write('{') , instruccion , write('}'). elseif :- write('else if (') , read(X) , write(X) , write(') {') , instruccion , write('}'). return :- read(X), write('return '), write(X). valor :-read(T),(T='cadena'->cadena; T='numero'->numero; T= 'booleano' -> booleano; T='arreglo'->arreglo; T='metodo'->metodo; T='objeto'->objeto). :- objeto.
run
|
edit
|
history
|
help
0
PRODUCTIVAS
Méndez Huerta Janet- Empresa 38
isan
aniki1
Economia con 2 objetos empresa
Base de conocimiento(json) Jerehmi
Empresa
Gonzalez Diaz Jobana
LOCO 0.0
RuizRodriguezEdwinAndres-P1