@designliquido/delegua 0.34.1 → 0.34.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/package.json +1 -1
- package/package.json +1 -1
- package/tradutores/tradutor-assemblyscript.d.ts +4 -1
- package/tradutores/tradutor-assemblyscript.d.ts.map +1 -1
- package/tradutores/tradutor-assemblyscript.js +16 -0
- package/tradutores/tradutor-assemblyscript.js.map +1 -1
- package/tradutores/tradutor-javascript.d.ts +4 -1
- package/tradutores/tradutor-javascript.d.ts.map +1 -1
- package/tradutores/tradutor-javascript.js +16 -0
- package/tradutores/tradutor-javascript.js.map +1 -1
- package/tradutores/tradutor-python.d.ts +25 -22
- package/tradutores/tradutor-python.d.ts.map +1 -1
- package/tradutores/tradutor-python.js +167 -151
- package/tradutores/tradutor-python.js.map +1 -1
- package/umd/delegua.js +199 -151
package/umd/delegua.js
CHANGED
|
@@ -25399,6 +25399,7 @@ class TradutorAssemblyScript {
|
|
|
25399
25399
|
Atribuir: this.traduzirConstrutoAtribuir.bind(this),
|
|
25400
25400
|
Binario: this.traduzirConstrutoBinario.bind(this),
|
|
25401
25401
|
Chamada: this.traduzirConstrutoChamada.bind(this),
|
|
25402
|
+
Comentario: this.traduzirConstrutoComentario.bind(this),
|
|
25402
25403
|
DefinirValor: this.traduzirConstrutoDefinirValor.bind(this),
|
|
25403
25404
|
FuncaoConstruto: this.traduzirFuncaoConstruto.bind(this),
|
|
25404
25405
|
Isto: () => 'this',
|
|
@@ -25412,6 +25413,7 @@ class TradutorAssemblyScript {
|
|
|
25412
25413
|
this.dicionarioDeclaracoes = {
|
|
25413
25414
|
Bloco: this.traduzirDeclaracaoBloco.bind(this),
|
|
25414
25415
|
Enquanto: this.traduzirDeclaracaoEnquanto.bind(this),
|
|
25416
|
+
Comentario: this.traduzirConstrutoComentario.bind(this),
|
|
25415
25417
|
Continua: () => 'continue',
|
|
25416
25418
|
Escolha: this.traduzirDeclaracaoEscolha.bind(this),
|
|
25417
25419
|
Expressao: this.traduzirDeclaracaoExpressao.bind(this),
|
|
@@ -25893,6 +25895,20 @@ class TradutorAssemblyScript {
|
|
|
25893
25895
|
resultado += ')';
|
|
25894
25896
|
return resultado;
|
|
25895
25897
|
}
|
|
25898
|
+
traduzirConstrutoComentario(comentario) {
|
|
25899
|
+
let resultado = '';
|
|
25900
|
+
if (comentario.multilinha) {
|
|
25901
|
+
resultado += `/*`;
|
|
25902
|
+
for (let linhaComentario of comentario.conteudo) {
|
|
25903
|
+
resultado += `${linhaComentario}\n`;
|
|
25904
|
+
}
|
|
25905
|
+
resultado += `*/`;
|
|
25906
|
+
}
|
|
25907
|
+
else {
|
|
25908
|
+
resultado += `// ${comentario.conteudo}`;
|
|
25909
|
+
}
|
|
25910
|
+
return resultado;
|
|
25911
|
+
}
|
|
25896
25912
|
traduzirConstrutoBinario(binario) {
|
|
25897
25913
|
let resultado = '';
|
|
25898
25914
|
if (binario.esquerda.constructor.name === 'Agrupamento')
|
|
@@ -25980,6 +25996,7 @@ class TradutorJavaScript {
|
|
|
25980
25996
|
Atribuir: this.traduzirConstrutoAtribuir.bind(this),
|
|
25981
25997
|
Binario: this.traduzirConstrutoBinario.bind(this),
|
|
25982
25998
|
Chamada: this.traduzirConstrutoChamada.bind(this),
|
|
25999
|
+
Comentario: this.traduzirConstrutoComentario.bind(this),
|
|
25983
26000
|
DefinirValor: this.traduzirConstrutoDefinirValor.bind(this),
|
|
25984
26001
|
FuncaoConstruto: this.traduzirFuncaoConstruto.bind(this),
|
|
25985
26002
|
Isto: () => 'this',
|
|
@@ -25994,6 +26011,7 @@ class TradutorJavaScript {
|
|
|
25994
26011
|
Bloco: this.traduzirDeclaracaoBloco.bind(this),
|
|
25995
26012
|
Classe: this.traduzirDeclaracaoClasse.bind(this),
|
|
25996
26013
|
Const: this.traduzirDeclaracaoConst.bind(this),
|
|
26014
|
+
Comentario: this.traduzirConstrutoComentario.bind(this),
|
|
25997
26015
|
Continua: () => 'continue',
|
|
25998
26016
|
Enquanto: this.traduzirDeclaracaoEnquanto.bind(this),
|
|
25999
26017
|
Escolha: this.traduzirDeclaracaoEscolha.bind(this),
|
|
@@ -26149,6 +26167,20 @@ class TradutorJavaScript {
|
|
|
26149
26167
|
resultado += ')';
|
|
26150
26168
|
return resultado;
|
|
26151
26169
|
}
|
|
26170
|
+
traduzirConstrutoComentario(comentario) {
|
|
26171
|
+
let resultado = '';
|
|
26172
|
+
if (comentario.multilinha) {
|
|
26173
|
+
resultado += `/*`;
|
|
26174
|
+
for (let linhaComentario of comentario.conteudo) {
|
|
26175
|
+
resultado += `${linhaComentario}\n`;
|
|
26176
|
+
}
|
|
26177
|
+
resultado += `*/`;
|
|
26178
|
+
}
|
|
26179
|
+
else {
|
|
26180
|
+
resultado += `// ${comentario.conteudo}`;
|
|
26181
|
+
}
|
|
26182
|
+
return resultado;
|
|
26183
|
+
}
|
|
26152
26184
|
logicaComumBlocoEscopo(declaracoes) {
|
|
26153
26185
|
let resultado = '{\n';
|
|
26154
26186
|
this.indentacao += 4;
|
|
@@ -26594,6 +26626,7 @@ class TradutorPython {
|
|
|
26594
26626
|
Atribuir: this.traduzirConstrutoAtribuir.bind(this),
|
|
26595
26627
|
Binario: this.traduzirConstrutoBinario.bind(this),
|
|
26596
26628
|
Chamada: this.traduzirConstrutoChamada.bind(this),
|
|
26629
|
+
Comentario: this.traduzirConstrutoComentario.bind(this),
|
|
26597
26630
|
DefinirValor: this.traduzirConstrutoDefinirValor.bind(this),
|
|
26598
26631
|
Literal: this.traduzirConstrutoLiteral.bind(this),
|
|
26599
26632
|
Logico: this.traduzirConstrutoLogico.bind(this),
|
|
@@ -26603,6 +26636,7 @@ class TradutorPython {
|
|
|
26603
26636
|
this.dicionarioDeclaracoes = {
|
|
26604
26637
|
Bloco: this.traduzirDeclaracaoBloco.bind(this),
|
|
26605
26638
|
Classe: this.traduzirDeclaracaoClasse.bind(this),
|
|
26639
|
+
Comentario: this.traduzirConstrutoComentario.bind(this),
|
|
26606
26640
|
Const: this.traduzirDeclaracaoConst.bind(this),
|
|
26607
26641
|
Continua: () => 'continue',
|
|
26608
26642
|
Escreva: this.traduzirDeclaracaoEscreva.bind(this),
|
|
@@ -26713,54 +26747,6 @@ class TradutorPython {
|
|
|
26713
26747
|
resultado += ' '.repeat(this.indentacao) + '\n';
|
|
26714
26748
|
return resultado;
|
|
26715
26749
|
}
|
|
26716
|
-
traduzirDeclaracaoTente(declaracaoTente) {
|
|
26717
|
-
let resultado = 'try:\n';
|
|
26718
|
-
this.indentacao += 4;
|
|
26719
|
-
resultado += ' '.repeat(this.indentacao);
|
|
26720
|
-
for (let condicao of declaracaoTente.caminhoTente) {
|
|
26721
|
-
resultado += this.dicionarioDeclaracoes[condicao.constructor.name](condicao) + '\n';
|
|
26722
|
-
resultado += ' '.repeat(this.indentacao);
|
|
26723
|
-
}
|
|
26724
|
-
if (declaracaoTente.caminhoPegue !== null) {
|
|
26725
|
-
resultado += '\nexcept:\n';
|
|
26726
|
-
resultado += ' '.repeat(this.indentacao);
|
|
26727
|
-
if (Array.isArray(declaracaoTente.caminhoPegue)) {
|
|
26728
|
-
for (let declaracao of declaracaoTente.caminhoPegue) {
|
|
26729
|
-
resultado += this.dicionarioDeclaracoes[declaracao.constructor.name](declaracao) + '\n';
|
|
26730
|
-
}
|
|
26731
|
-
}
|
|
26732
|
-
else {
|
|
26733
|
-
for (let corpo of declaracaoTente.caminhoPegue.corpo) {
|
|
26734
|
-
resultado += this.dicionarioDeclaracoes[corpo.constructor.name](corpo) + '\n';
|
|
26735
|
-
}
|
|
26736
|
-
}
|
|
26737
|
-
resultado += ' '.repeat(this.indentacao);
|
|
26738
|
-
}
|
|
26739
|
-
if (declaracaoTente.caminhoFinalmente !== null) {
|
|
26740
|
-
resultado += '\nfinally:\n';
|
|
26741
|
-
resultado += ' '.repeat(this.indentacao);
|
|
26742
|
-
for (let finalmente of declaracaoTente.caminhoFinalmente) {
|
|
26743
|
-
resultado += this.dicionarioDeclaracoes[finalmente.constructor.name](finalmente) + '\n';
|
|
26744
|
-
}
|
|
26745
|
-
}
|
|
26746
|
-
return resultado;
|
|
26747
|
-
}
|
|
26748
|
-
traduzirConstrutoLogico(logico) {
|
|
26749
|
-
let direita = this.dicionarioConstrutos[logico.direita.constructor.name](logico.direita);
|
|
26750
|
-
let operador = this.traduzirSimboloOperador(logico.operador);
|
|
26751
|
-
let esquerda = this.dicionarioConstrutos[logico.esquerda.constructor.name](logico.esquerda);
|
|
26752
|
-
return `${esquerda} ${operador} ${direita}`;
|
|
26753
|
-
}
|
|
26754
|
-
traduzirConstrutoLiteral(literal) {
|
|
26755
|
-
if (typeof literal.valor === 'string')
|
|
26756
|
-
return `'${literal.valor}'`;
|
|
26757
|
-
if (typeof literal.valor === 'boolean') {
|
|
26758
|
-
return literal.valor ? 'True' : 'False';
|
|
26759
|
-
}
|
|
26760
|
-
if (!literal.valor)
|
|
26761
|
-
return 'None';
|
|
26762
|
-
return literal.valor;
|
|
26763
|
-
}
|
|
26764
26750
|
trazudirConstrutoAcessoMetodo(acessoMetodo) {
|
|
26765
26751
|
if (acessoMetodo.objeto instanceof construtos_1.Variavel) {
|
|
26766
26752
|
let objetoVariavel = acessoMetodo.objeto;
|
|
@@ -26775,24 +26761,12 @@ class TradutorPython {
|
|
|
26775
26761
|
}
|
|
26776
26762
|
return `self.${acessoMetodo.simbolo.lexema}`;
|
|
26777
26763
|
}
|
|
26778
|
-
|
|
26779
|
-
|
|
26780
|
-
for (const argumento of declaracaoEscreva.argumentos) {
|
|
26781
|
-
const valor = this.dicionarioConstrutos[argumento.constructor.name](argumento);
|
|
26782
|
-
resultado += valor + ', ';
|
|
26783
|
-
}
|
|
26784
|
-
resultado = resultado.slice(0, -2);
|
|
26785
|
-
resultado += ')';
|
|
26786
|
-
return resultado;
|
|
26764
|
+
traduzirConstrutoAgrupamento(agrupamento) {
|
|
26765
|
+
return this.dicionarioConstrutos[agrupamento.constructor.name](agrupamento.expressao || agrupamento);
|
|
26787
26766
|
}
|
|
26788
|
-
|
|
26789
|
-
let resultado =
|
|
26790
|
-
|
|
26791
|
-
const valor = this.dicionarioConstrutos[argumento.constructor.name](argumento);
|
|
26792
|
-
resultado += valor + ', ';
|
|
26793
|
-
}
|
|
26794
|
-
resultado = resultado.slice(0, -2);
|
|
26795
|
-
resultado += ')';
|
|
26767
|
+
traduzirConstrutoAtribuir(atribuir) {
|
|
26768
|
+
let resultado = atribuir.simbolo.lexema;
|
|
26769
|
+
resultado += ' = ' + this.dicionarioConstrutos[atribuir.valor.constructor.name](atribuir.valor);
|
|
26796
26770
|
return resultado;
|
|
26797
26771
|
}
|
|
26798
26772
|
traduzirConstrutoBinario(binario) {
|
|
@@ -26809,17 +26783,85 @@ class TradutorPython {
|
|
|
26809
26783
|
resultado += this.dicionarioConstrutos[binario.direita.constructor.name](binario.direita);
|
|
26810
26784
|
return resultado;
|
|
26811
26785
|
}
|
|
26812
|
-
|
|
26813
|
-
let resultado = '
|
|
26814
|
-
|
|
26815
|
-
|
|
26816
|
-
|
|
26786
|
+
traduzirConstrutoChamada(chamada) {
|
|
26787
|
+
let resultado = '';
|
|
26788
|
+
const retorno = `${this.dicionarioConstrutos[chamada.entidadeChamada.constructor.name](chamada.entidadeChamada)}`;
|
|
26789
|
+
resultado += retorno;
|
|
26790
|
+
if (!resultado.includes('in ') && !resultado.includes('len') && !resultado.includes('pop(')) {
|
|
26791
|
+
resultado += '(';
|
|
26817
26792
|
}
|
|
26818
|
-
if (
|
|
26793
|
+
if (!resultado.includes('len(')) {
|
|
26794
|
+
for (let parametro of chamada.argumentos) {
|
|
26795
|
+
const parametroTratado = this.dicionarioConstrutos[parametro.constructor.name](parametro);
|
|
26796
|
+
if (resultado.includes('in ') || resultado.includes('len')) {
|
|
26797
|
+
resultado = `${parametroTratado} ${resultado}`;
|
|
26798
|
+
}
|
|
26799
|
+
else {
|
|
26800
|
+
resultado += parametroTratado + ', ';
|
|
26801
|
+
}
|
|
26802
|
+
}
|
|
26803
|
+
if (chamada.argumentos.length > 0 && !resultado.includes('in ') && !resultado.includes('len')) {
|
|
26804
|
+
resultado = resultado.slice(0, -2);
|
|
26805
|
+
}
|
|
26806
|
+
if (!resultado.includes(')') && !resultado.includes('in ')) {
|
|
26807
|
+
resultado += ')';
|
|
26808
|
+
}
|
|
26809
|
+
}
|
|
26810
|
+
return resultado;
|
|
26811
|
+
}
|
|
26812
|
+
traduzirConstrutoComentario(comentario) {
|
|
26813
|
+
let resultado = '';
|
|
26814
|
+
if (comentario.multilinha) {
|
|
26815
|
+
resultado += `'''`;
|
|
26816
|
+
for (let linhaComentario of comentario.conteudo) {
|
|
26817
|
+
resultado += `${linhaComentario}\n`;
|
|
26818
|
+
}
|
|
26819
|
+
resultado += `'''`;
|
|
26820
|
+
}
|
|
26821
|
+
else {
|
|
26822
|
+
resultado += `# ${comentario.conteudo}`;
|
|
26823
|
+
}
|
|
26824
|
+
return resultado;
|
|
26825
|
+
}
|
|
26826
|
+
traduzirConstrutoDefinirValor(definirValor) {
|
|
26827
|
+
let resultado = '';
|
|
26828
|
+
if (definirValor.objeto instanceof construtos_1.Isto) {
|
|
26829
|
+
resultado = 'self.' + definirValor.nome.lexema + ' = ';
|
|
26830
|
+
}
|
|
26831
|
+
resultado += definirValor.valor.simbolo.lexema;
|
|
26832
|
+
return resultado;
|
|
26833
|
+
}
|
|
26834
|
+
traduzirConstrutoLiteral(literal) {
|
|
26835
|
+
if (typeof literal.valor === 'string')
|
|
26836
|
+
return `'${literal.valor}'`;
|
|
26837
|
+
if (typeof literal.valor === 'boolean') {
|
|
26838
|
+
return literal.valor ? 'True' : 'False';
|
|
26839
|
+
}
|
|
26840
|
+
if (!literal.valor)
|
|
26841
|
+
return 'None';
|
|
26842
|
+
return literal.valor;
|
|
26843
|
+
}
|
|
26844
|
+
traduzirConstrutoLogico(logico) {
|
|
26845
|
+
let direita = this.dicionarioConstrutos[logico.direita.constructor.name](logico.direita);
|
|
26846
|
+
let operador = this.traduzirSimboloOperador(logico.operador);
|
|
26847
|
+
let esquerda = this.dicionarioConstrutos[logico.esquerda.constructor.name](logico.esquerda);
|
|
26848
|
+
return `${esquerda} ${operador} ${direita}`;
|
|
26849
|
+
}
|
|
26850
|
+
traduzirConstrutoVariavel(variavel) {
|
|
26851
|
+
return variavel.simbolo.lexema;
|
|
26852
|
+
}
|
|
26853
|
+
traduzirConstrutoVetor(vetor) {
|
|
26854
|
+
if (!vetor.valores.length) {
|
|
26855
|
+
return '[]';
|
|
26856
|
+
}
|
|
26857
|
+
let resultado = '[';
|
|
26858
|
+
for (let valor of vetor.valores) {
|
|
26859
|
+
resultado += `${this.dicionarioConstrutos[valor.constructor.name](valor)}, `;
|
|
26860
|
+
}
|
|
26861
|
+
if (vetor.valores.length > 0) {
|
|
26819
26862
|
resultado = resultado.slice(0, -2);
|
|
26820
26863
|
}
|
|
26821
|
-
resultado += '
|
|
26822
|
-
resultado += this.logicaComumBlocoEscopo(declaracaoFuncao.funcao.corpo);
|
|
26864
|
+
resultado += ']';
|
|
26823
26865
|
return resultado;
|
|
26824
26866
|
}
|
|
26825
26867
|
traduzirDeclaracaoSe(declaracaoSe, iniciarComIf = true) {
|
|
@@ -26886,6 +26928,9 @@ class TradutorPython {
|
|
|
26886
26928
|
this.indentacao -= 4;
|
|
26887
26929
|
return resultado;
|
|
26888
26930
|
}
|
|
26931
|
+
traduzirDeclaracaoBloco(declaracaoBloco) {
|
|
26932
|
+
return this.logicaComumBlocoEscopo(declaracaoBloco.declaracoes);
|
|
26933
|
+
}
|
|
26889
26934
|
traduzirDeclaracaoClasse(declaracaoClasse) {
|
|
26890
26935
|
let resultado = 'class ';
|
|
26891
26936
|
if (declaracaoClasse.superClasse)
|
|
@@ -26899,88 +26944,115 @@ class TradutorPython {
|
|
|
26899
26944
|
}
|
|
26900
26945
|
return resultado;
|
|
26901
26946
|
}
|
|
26902
|
-
|
|
26947
|
+
traduzirDeclaracaoConst(declaracaoConst) {
|
|
26903
26948
|
let resultado = '';
|
|
26904
|
-
|
|
26905
|
-
resultado +=
|
|
26906
|
-
|
|
26907
|
-
|
|
26908
|
-
|
|
26909
|
-
|
|
26910
|
-
for (let parametro of chamada.argumentos) {
|
|
26911
|
-
const parametroTratado = this.dicionarioConstrutos[parametro.constructor.name](parametro);
|
|
26912
|
-
if (resultado.includes('in ') || resultado.includes('len')) {
|
|
26913
|
-
resultado = `${parametroTratado} ${resultado}`;
|
|
26914
|
-
}
|
|
26915
|
-
else {
|
|
26916
|
-
resultado += parametroTratado + ', ';
|
|
26917
|
-
}
|
|
26918
|
-
}
|
|
26919
|
-
if (chamada.argumentos.length > 0 && !resultado.includes('in ') && !resultado.includes('len')) {
|
|
26920
|
-
resultado = resultado.slice(0, -2);
|
|
26949
|
+
resultado += this.traduzirNomeVariavel(declaracaoConst.simbolo.lexema);
|
|
26950
|
+
resultado += ' = ';
|
|
26951
|
+
const inicializador = declaracaoConst.inicializador;
|
|
26952
|
+
if (inicializador) {
|
|
26953
|
+
if (this.dicionarioConstrutos[inicializador.constructor.name]) {
|
|
26954
|
+
resultado += this.dicionarioConstrutos[declaracaoConst.inicializador.constructor.name](declaracaoConst.inicializador);
|
|
26921
26955
|
}
|
|
26922
|
-
|
|
26923
|
-
resultado +=
|
|
26956
|
+
else {
|
|
26957
|
+
resultado += this.dicionarioDeclaracoes[declaracaoConst.inicializador.constructor.name](declaracaoConst.inicializador);
|
|
26924
26958
|
}
|
|
26925
26959
|
}
|
|
26960
|
+
else {
|
|
26961
|
+
resultado += 'None';
|
|
26962
|
+
}
|
|
26926
26963
|
return resultado;
|
|
26927
26964
|
}
|
|
26928
|
-
|
|
26929
|
-
let resultado = '
|
|
26930
|
-
const
|
|
26931
|
-
|
|
26932
|
-
|
|
26933
|
-
traduzirConstrutoVetor(vetor) {
|
|
26934
|
-
if (!vetor.valores.length) {
|
|
26935
|
-
return '[]';
|
|
26965
|
+
traduzirDeclaracaoEscreva(declaracaoEscreva) {
|
|
26966
|
+
let resultado = 'print(';
|
|
26967
|
+
for (const argumento of declaracaoEscreva.argumentos) {
|
|
26968
|
+
const valor = this.dicionarioConstrutos[argumento.constructor.name](argumento);
|
|
26969
|
+
resultado += valor + ', ';
|
|
26936
26970
|
}
|
|
26937
|
-
|
|
26938
|
-
|
|
26939
|
-
|
|
26971
|
+
resultado = resultado.slice(0, -2);
|
|
26972
|
+
resultado += ')';
|
|
26973
|
+
return resultado;
|
|
26974
|
+
}
|
|
26975
|
+
traduzirDeclaracaoExpressao(declaracaoExpressao) {
|
|
26976
|
+
return this.dicionarioConstrutos[declaracaoExpressao.expressao.constructor.name](declaracaoExpressao.expressao);
|
|
26977
|
+
}
|
|
26978
|
+
traduzirDeclaracaoFuncao(declaracaoFuncao) {
|
|
26979
|
+
let resultado = 'def ';
|
|
26980
|
+
resultado += declaracaoFuncao.simbolo.lexema + '(';
|
|
26981
|
+
for (const parametro of declaracaoFuncao.funcao.parametros) {
|
|
26982
|
+
resultado += parametro.nome.lexema + ', ';
|
|
26940
26983
|
}
|
|
26941
|
-
if (
|
|
26984
|
+
if (declaracaoFuncao.funcao.parametros.length > 0) {
|
|
26942
26985
|
resultado = resultado.slice(0, -2);
|
|
26943
26986
|
}
|
|
26944
|
-
resultado += '
|
|
26987
|
+
resultado += '):';
|
|
26988
|
+
resultado += this.logicaComumBlocoEscopo(declaracaoFuncao.funcao.corpo);
|
|
26945
26989
|
return resultado;
|
|
26946
26990
|
}
|
|
26947
|
-
|
|
26948
|
-
let resultado = '';
|
|
26949
|
-
|
|
26950
|
-
|
|
26991
|
+
traduzirDeclaracaoLeia(declaracaoLeia) {
|
|
26992
|
+
let resultado = 'input(';
|
|
26993
|
+
for (const argumento of declaracaoLeia.argumentos) {
|
|
26994
|
+
const valor = this.dicionarioConstrutos[argumento.constructor.name](argumento);
|
|
26995
|
+
resultado += valor + ', ';
|
|
26951
26996
|
}
|
|
26952
|
-
resultado
|
|
26997
|
+
resultado = resultado.slice(0, -2);
|
|
26998
|
+
resultado += ')';
|
|
26953
26999
|
return resultado;
|
|
26954
27000
|
}
|
|
26955
|
-
|
|
26956
|
-
let resultado =
|
|
26957
|
-
resultado +=
|
|
26958
|
-
|
|
26959
|
-
|
|
26960
|
-
|
|
26961
|
-
|
|
26962
|
-
|
|
27001
|
+
traduzirDeclaracaoParaCada(declaracaoParaCada) {
|
|
27002
|
+
let resultado = `for ${declaracaoParaCada.nomeVariavelIteracao} in `;
|
|
27003
|
+
resultado +=
|
|
27004
|
+
this.dicionarioConstrutos[declaracaoParaCada.vetor.constructor.name](declaracaoParaCada.vetor) + ':\n';
|
|
27005
|
+
resultado += this.dicionarioDeclaracoes[declaracaoParaCada.corpo.constructor.name](declaracaoParaCada.corpo);
|
|
27006
|
+
return resultado;
|
|
27007
|
+
}
|
|
27008
|
+
traduzirDeclaracaoRetorna(declaracaoRetorna) {
|
|
27009
|
+
let resultado = 'return ';
|
|
27010
|
+
const nomeConstrutor = declaracaoRetorna.valor.constructor.name;
|
|
27011
|
+
return (resultado += this.dicionarioConstrutos[nomeConstrutor](declaracaoRetorna === null || declaracaoRetorna === void 0 ? void 0 : declaracaoRetorna.valor));
|
|
27012
|
+
}
|
|
27013
|
+
traduzirDeclaracaoTente(declaracaoTente) {
|
|
27014
|
+
let resultado = 'try:\n';
|
|
27015
|
+
this.indentacao += 4;
|
|
27016
|
+
resultado += ' '.repeat(this.indentacao);
|
|
27017
|
+
for (let condicao of declaracaoTente.caminhoTente) {
|
|
27018
|
+
resultado += this.dicionarioDeclaracoes[condicao.constructor.name](condicao) + '\n';
|
|
27019
|
+
resultado += ' '.repeat(this.indentacao);
|
|
27020
|
+
}
|
|
27021
|
+
if (declaracaoTente.caminhoPegue !== null) {
|
|
27022
|
+
resultado += '\nexcept:\n';
|
|
27023
|
+
resultado += ' '.repeat(this.indentacao);
|
|
27024
|
+
if (Array.isArray(declaracaoTente.caminhoPegue)) {
|
|
27025
|
+
for (let declaracao of declaracaoTente.caminhoPegue) {
|
|
27026
|
+
resultado += this.dicionarioDeclaracoes[declaracao.constructor.name](declaracao) + '\n';
|
|
27027
|
+
}
|
|
26963
27028
|
}
|
|
26964
27029
|
else {
|
|
26965
|
-
|
|
27030
|
+
for (let corpo of declaracaoTente.caminhoPegue.corpo) {
|
|
27031
|
+
resultado += this.dicionarioDeclaracoes[corpo.constructor.name](corpo) + '\n';
|
|
27032
|
+
}
|
|
26966
27033
|
}
|
|
27034
|
+
resultado += ' '.repeat(this.indentacao);
|
|
26967
27035
|
}
|
|
26968
|
-
|
|
26969
|
-
resultado += '
|
|
27036
|
+
if (declaracaoTente.caminhoFinalmente !== null) {
|
|
27037
|
+
resultado += '\nfinally:\n';
|
|
27038
|
+
resultado += ' '.repeat(this.indentacao);
|
|
27039
|
+
for (let finalmente of declaracaoTente.caminhoFinalmente) {
|
|
27040
|
+
resultado += this.dicionarioDeclaracoes[finalmente.constructor.name](finalmente) + '\n';
|
|
27041
|
+
}
|
|
26970
27042
|
}
|
|
26971
27043
|
return resultado;
|
|
26972
27044
|
}
|
|
26973
|
-
|
|
27045
|
+
traduzirDeclaracaoVar(declaracaoVar) {
|
|
26974
27046
|
let resultado = '';
|
|
26975
|
-
resultado += this.traduzirNomeVariavel(
|
|
27047
|
+
resultado += this.traduzirNomeVariavel(declaracaoVar.simbolo.lexema);
|
|
26976
27048
|
resultado += ' = ';
|
|
26977
|
-
const inicializador =
|
|
27049
|
+
const inicializador = declaracaoVar.inicializador;
|
|
26978
27050
|
if (inicializador) {
|
|
26979
27051
|
if (this.dicionarioConstrutos[inicializador.constructor.name]) {
|
|
26980
|
-
resultado += this.dicionarioConstrutos[
|
|
27052
|
+
resultado += this.dicionarioConstrutos[declaracaoVar.inicializador.constructor.name](declaracaoVar.inicializador);
|
|
26981
27053
|
}
|
|
26982
27054
|
else {
|
|
26983
|
-
resultado += this.dicionarioDeclaracoes[
|
|
27055
|
+
resultado += this.dicionarioDeclaracoes[declaracaoVar.inicializador.constructor.name](declaracaoVar.inicializador);
|
|
26984
27056
|
}
|
|
26985
27057
|
}
|
|
26986
27058
|
else {
|
|
@@ -26988,30 +27060,6 @@ class TradutorPython {
|
|
|
26988
27060
|
}
|
|
26989
27061
|
return resultado;
|
|
26990
27062
|
}
|
|
26991
|
-
traduzirDeclaracaoParaCada(declaracaoParaCada) {
|
|
26992
|
-
let resultado = `for ${declaracaoParaCada.nomeVariavelIteracao} in `;
|
|
26993
|
-
resultado +=
|
|
26994
|
-
this.dicionarioConstrutos[declaracaoParaCada.vetor.constructor.name](declaracaoParaCada.vetor) + ':\n';
|
|
26995
|
-
resultado += this.dicionarioDeclaracoes[declaracaoParaCada.corpo.constructor.name](declaracaoParaCada.corpo);
|
|
26996
|
-
return resultado;
|
|
26997
|
-
}
|
|
26998
|
-
traduzirConstrutoAtribuir(atribuir) {
|
|
26999
|
-
let resultado = atribuir.simbolo.lexema;
|
|
27000
|
-
resultado += ' = ' + this.dicionarioConstrutos[atribuir.valor.constructor.name](atribuir.valor);
|
|
27001
|
-
return resultado;
|
|
27002
|
-
}
|
|
27003
|
-
traduzirConstrutoVariavel(variavel) {
|
|
27004
|
-
return variavel.simbolo.lexema;
|
|
27005
|
-
}
|
|
27006
|
-
traduzirDeclaracaoExpressao(declaracaoExpressao) {
|
|
27007
|
-
return this.dicionarioConstrutos[declaracaoExpressao.expressao.constructor.name](declaracaoExpressao.expressao);
|
|
27008
|
-
}
|
|
27009
|
-
traduzirDeclaracaoBloco(declaracaoBloco) {
|
|
27010
|
-
return this.logicaComumBlocoEscopo(declaracaoBloco.declaracoes);
|
|
27011
|
-
}
|
|
27012
|
-
traduzirConstrutoAgrupamento(agrupamento) {
|
|
27013
|
-
return this.dicionarioConstrutos[agrupamento.constructor.name](agrupamento.expressao || agrupamento);
|
|
27014
|
-
}
|
|
27015
27063
|
traduzir(declaracoes) {
|
|
27016
27064
|
let resultado = '';
|
|
27017
27065
|
for (const declaracao of declaracoes) {
|