@designliquido/delegua 1.3.1 → 1.4.0

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.
Files changed (64) hide show
  1. package/avaliador-sintatico/avaliador-sintatico.d.ts.map +1 -1
  2. package/avaliador-sintatico/avaliador-sintatico.js +3 -0
  3. package/avaliador-sintatico/avaliador-sintatico.js.map +1 -1
  4. package/avaliador-sintatico/dialetos/avaliador-sintatico-pitugues.d.ts.map +1 -1
  5. package/avaliador-sintatico/dialetos/avaliador-sintatico-pitugues.js +14 -7
  6. package/avaliador-sintatico/dialetos/avaliador-sintatico-pitugues.js.map +1 -1
  7. package/bibliotecas/biblioteca-global.d.ts +7 -0
  8. package/bibliotecas/biblioteca-global.d.ts.map +1 -1
  9. package/bibliotecas/biblioteca-global.js +40 -0
  10. package/bibliotecas/biblioteca-global.js.map +1 -1
  11. package/bibliotecas/dialetos/pitugues/primitivas-texto.d.ts.map +1 -1
  12. package/bibliotecas/dialetos/pitugues/primitivas-texto.js +26 -0
  13. package/bibliotecas/dialetos/pitugues/primitivas-texto.js.map +1 -1
  14. package/bibliotecas/dialetos/pitugues/primitivas-vetor.d.ts.map +1 -1
  15. package/bibliotecas/dialetos/pitugues/primitivas-vetor.js +115 -34
  16. package/bibliotecas/dialetos/pitugues/primitivas-vetor.js.map +1 -1
  17. package/bin/package.json +1 -1
  18. package/construtos/tuplas/deceto.js +1 -1
  19. package/construtos/tuplas/deceto.js.map +1 -1
  20. package/construtos/tuplas/dupla.js +1 -1
  21. package/construtos/tuplas/dupla.js.map +1 -1
  22. package/construtos/tuplas/noneto.js +1 -1
  23. package/construtos/tuplas/noneto.js.map +1 -1
  24. package/construtos/tuplas/octeto.js +1 -1
  25. package/construtos/tuplas/octeto.js.map +1 -1
  26. package/construtos/tuplas/quarteto.js +1 -1
  27. package/construtos/tuplas/quarteto.js.map +1 -1
  28. package/construtos/tuplas/quinteto.js +1 -1
  29. package/construtos/tuplas/quinteto.js.map +1 -1
  30. package/construtos/tuplas/septeto.js +1 -1
  31. package/construtos/tuplas/septeto.js.map +1 -1
  32. package/construtos/tuplas/sexteto.js +1 -1
  33. package/construtos/tuplas/sexteto.js.map +1 -1
  34. package/construtos/tuplas/trio.js +1 -1
  35. package/construtos/tuplas/trio.js.map +1 -1
  36. package/inferenciador.d.ts.map +1 -1
  37. package/inferenciador.js +1 -0
  38. package/inferenciador.js.map +1 -1
  39. package/interpretador/comum.d.ts.map +1 -1
  40. package/interpretador/comum.js +1 -0
  41. package/interpretador/comum.js.map +1 -1
  42. package/interpretador/interpretador-base.d.ts.map +1 -1
  43. package/interpretador/interpretador-base.js +87 -7
  44. package/interpretador/interpretador-base.js.map +1 -1
  45. package/interpretador/pilha-escopos-execucao.d.ts.map +1 -1
  46. package/interpretador/pilha-escopos-execucao.js +9 -0
  47. package/interpretador/pilha-escopos-execucao.js.map +1 -1
  48. package/lexador/lexador-base.d.ts +12 -0
  49. package/lexador/lexador-base.d.ts.map +1 -1
  50. package/lexador/lexador-base.js +20 -0
  51. package/lexador/lexador-base.js.map +1 -1
  52. package/lexador/lexador.d.ts +6 -0
  53. package/lexador/lexador.d.ts.map +1 -1
  54. package/lexador/lexador.js +85 -0
  55. package/lexador/lexador.js.map +1 -1
  56. package/package.json +1 -1
  57. package/tipos-de-dados/delegua.d.ts +2 -0
  58. package/tipos-de-dados/delegua.d.ts.map +1 -1
  59. package/tipos-de-dados/delegua.js +2 -0
  60. package/tipos-de-dados/delegua.js.map +1 -1
  61. package/tradutores/tradutor-mermaidjs.d.ts.map +1 -1
  62. package/tradutores/tradutor-mermaidjs.js +18 -6
  63. package/tradutores/tradutor-mermaidjs.js.map +1 -1
  64. package/umd/delegua.js +290 -30
package/umd/delegua.js CHANGED
@@ -3753,6 +3753,9 @@ class AvaliadorSintatico extends avaliador_sintatico_base_1.AvaliadorSintaticoBa
3753
3753
  this.pilhaEscopos.definirInformacoesVariavel('inteiro', new informacao_elemento_sintatico_1.InformacaoElementoSintatico('inteiro', 'inteiro', true, [
3754
3754
  new informacao_elemento_sintatico_1.InformacaoElementoSintatico('valor', 'qualquer'),
3755
3755
  ]));
3756
+ this.pilhaEscopos.definirInformacoesVariavel('longo', new informacao_elemento_sintatico_1.InformacaoElementoSintatico('longo', 'longo', true, [
3757
+ new informacao_elemento_sintatico_1.InformacaoElementoSintatico('valor', 'qualquer'),
3758
+ ]));
3756
3759
  this.pilhaEscopos.definirInformacoesVariavel('intervalo', new informacao_elemento_sintatico_1.InformacaoElementoSintatico('intervalo', 'inteiro[]', true, [
3757
3760
  new informacao_elemento_sintatico_1.InformacaoElementoSintatico('valorInicial', 'qualquer'),
3758
3761
  new informacao_elemento_sintatico_1.InformacaoElementoSintatico('valorFinal', 'qualquer'),
@@ -5095,13 +5098,17 @@ class AvaliadorSintaticoPitugues {
5095
5098
  case pitugues_2.default.INTERPOLACAO:
5096
5099
  const simboloInterpolacao = this.avancarEDevolverAnterior();
5097
5100
  const conteudoOriginal = simboloInterpolacao.literal;
5098
- // Transforma "Olá {nome}" em '"Olá " + (nome) + ""'
5099
- // Adicionado parênteses em volta das variáveis para garantir precedência na soma
5100
- const codigoTransformado = '"' +
5101
- conteudoOriginal
5102
- .replace(/\{/g, '" + (')
5103
- .replace(/\}/g, ') + "') +
5104
- '"';
5101
+ const codigoTransformado = '"' + conteudoOriginal.replace(/\{(.*?)\}/g, (_, miolo) => {
5102
+ // 'miolo' é o texto que estava dentro das chaves. Ex: "valor" ou "valor:.2f"
5103
+ if (miolo.includes(':')) {
5104
+ const [variavel, formato] = miolo.split(':').map(s => s.trim());
5105
+ if (variavel !== "") {
5106
+ // Transforma {valor:.2f} em "{:.2f}".formatar(valor)
5107
+ return '" + "{:' + formato + '}".formatar(' + variavel + ') + "';
5108
+ }
5109
+ }
5110
+ return '" + (' + miolo.trim() + ') + "';
5111
+ }) + '"';
5105
5112
  const microLexador = new micro_lexador_pitugues_1.MicroLexadorPitugues();
5106
5113
  const retornoMicroLexador = microLexador.mapear(codigoTransformado);
5107
5114
  const microAvaliadorSintatico = new micro_avaliador_sintatico_pitugues_1.MicroAvaliadorSintaticoPitugues();
@@ -6013,6 +6020,9 @@ class AvaliadorSintaticoPitugues {
6013
6020
  this.pilhaEscopos.definirInformacoesVariavel('inteiro', new informacao_elemento_sintatico_1.InformacaoElementoSintatico('inteiro', 'inteiro', true, [
6014
6021
  new informacao_elemento_sintatico_1.InformacaoElementoSintatico('valor', 'qualquer'),
6015
6022
  ]));
6023
+ this.pilhaEscopos.definirInformacoesVariavel('longo', new informacao_elemento_sintatico_1.InformacaoElementoSintatico('longo', 'longo', true, [
6024
+ new informacao_elemento_sintatico_1.InformacaoElementoSintatico('valor', 'qualquer'),
6025
+ ]));
6016
6026
  this.pilhaEscopos.definirInformacoesVariavel('intervalo', new informacao_elemento_sintatico_1.InformacaoElementoSintatico('intervalo', 'inteiro[]', true, [
6017
6027
  new informacao_elemento_sintatico_1.InformacaoElementoSintatico('valorInicial', 'qualquer'),
6018
6028
  new informacao_elemento_sintatico_1.InformacaoElementoSintatico('valorFinal', 'qualquer'),
@@ -8840,6 +8850,7 @@ exports.encontrarUltimoIndice = encontrarUltimoIndice;
8840
8850
  exports.filtrarPor = filtrarPor;
8841
8851
  exports.incluido = incluido;
8842
8852
  exports.inteiro = inteiro;
8853
+ exports.longo = longo;
8843
8854
  exports.intervalo = intervalo;
8844
8855
  exports.mapear = mapear;
8845
8856
  exports.maximo = maximo;
@@ -9321,6 +9332,45 @@ async function inteiro(interpretador, valorParaConverter) {
9321
9332
  const resultadoValidacao = validacaoComumNumeros(interpretador, valor);
9322
9333
  return resultadoValidacao || Promise.resolve(parseInt(valor));
9323
9334
  }
9335
+ /**
9336
+ * Converte um valor em um número longo (BigInt).
9337
+ * @param {InterpretadorInterface} interpretador A instância do interpretador.
9338
+ * @param {VariavelInterface | any} valorParaConverter O valor a ser convertido.
9339
+ * @returns {Promise<any>} Uma Promise com o resultado da conversão para BigInt.
9340
+ */
9341
+ async function longo(interpretador, valorParaConverter) {
9342
+ if (valorParaConverter === null || valorParaConverter === undefined) {
9343
+ return Promise.resolve(BigInt(0));
9344
+ }
9345
+ const valor = valorParaConverter.hasOwnProperty('valor')
9346
+ ? valorParaConverter.valor
9347
+ : valorParaConverter;
9348
+ // Se já é BigInt, retorna direto
9349
+ if (typeof valor === 'bigint') {
9350
+ return Promise.resolve(valor);
9351
+ }
9352
+ // Se é número, converte para BigInt (trunca decimais)
9353
+ if (typeof valor === 'number') {
9354
+ return Promise.resolve(BigInt(Math.floor(valor)));
9355
+ }
9356
+ // Para strings, remove parte decimal se presente
9357
+ const strValue = String(valor).trim();
9358
+ // Trata string vazia
9359
+ if (!strValue || strValue === '') {
9360
+ return Promise.resolve(BigInt(0));
9361
+ }
9362
+ // Remove parte decimal da string (ex: "3.14" -> "3")
9363
+ const integerPart = strValue.split('.')[0];
9364
+ try {
9365
+ return Promise.resolve(BigInt(integerPart));
9366
+ }
9367
+ catch (e) {
9368
+ return Promise.reject(new excecoes_1.ErroEmTempoDeExecucao({
9369
+ hashArquivo: interpretador.hashArquivoDeclaracaoAtual,
9370
+ linha: interpretador.linhaDeclaracaoAtual,
9371
+ }, `Não foi possível converter '${valor}' para longo. O valor deve ser um número ou texto numérico.`));
9372
+ }
9373
+ }
9324
9374
  /**
9325
9375
  * Cria um vetor com números inteiros no intervalo especificado.
9326
9376
  * O valor inicial é inclusivo e o valor final é exclusivo.
@@ -12053,7 +12103,7 @@ class Deceto extends tupla_1.Tupla {
12053
12103
  ` />`);
12054
12104
  }
12055
12105
  paraTextoSaida() {
12056
- return `[(${this.primeiro.paraTextoSaida()}, ${this.segundo.paraTextoSaida()}, ${this.terceiro.paraTextoSaida()}, ${this.quarto.paraTextoSaida()}, ${this.quinto.paraTextoSaida()}, ${this.sexto.paraTextoSaida()}, ${this.setimo.paraTextoSaida()}, ${this.oitavo.paraTextoSaida()}, ${this.nono.paraTextoSaida()}, ${this.decimo.paraTextoSaida()})]`;
12106
+ return `(${this.primeiro.paraTextoSaida()}, ${this.segundo.paraTextoSaida()}, ${this.terceiro.paraTextoSaida()}, ${this.quarto.paraTextoSaida()}, ${this.quinto.paraTextoSaida()}, ${this.sexto.paraTextoSaida()}, ${this.setimo.paraTextoSaida()}, ${this.oitavo.paraTextoSaida()}, ${this.nono.paraTextoSaida()}, ${this.decimo.paraTextoSaida()})`;
12057
12107
  }
12058
12108
  }
12059
12109
  exports.Deceto = Deceto;
@@ -12075,7 +12125,7 @@ class Dupla extends tupla_1.Tupla {
12075
12125
  ` />`);
12076
12126
  }
12077
12127
  paraTextoSaida() {
12078
- return `[(${this.primeiro.paraTextoSaida()}, ${this.segundo.paraTextoSaida()})]`;
12128
+ return `(${this.primeiro.paraTextoSaida()}, ${this.segundo.paraTextoSaida()})`;
12079
12129
  }
12080
12130
  }
12081
12131
  exports.Dupla = Dupla;
@@ -12185,7 +12235,7 @@ class Noneto extends tupla_1.Tupla {
12185
12235
  ` />`);
12186
12236
  }
12187
12237
  paraTextoSaida() {
12188
- return `[(${this.primeiro.paraTextoSaida()}, ${this.segundo.paraTextoSaida()}, ${this.terceiro.paraTextoSaida()}, ${this.quarto.paraTextoSaida()}, ${this.quinto.paraTextoSaida()}, ${this.sexto.paraTextoSaida()}, ${this.setimo.paraTextoSaida()}, ${this.oitavo.paraTextoSaida()}, ${this.nono.paraTextoSaida()})]`;
12238
+ return `(${this.primeiro.paraTextoSaida()}, ${this.segundo.paraTextoSaida()}, ${this.terceiro.paraTextoSaida()}, ${this.quarto.paraTextoSaida()}, ${this.quinto.paraTextoSaida()}, ${this.sexto.paraTextoSaida()}, ${this.setimo.paraTextoSaida()}, ${this.oitavo.paraTextoSaida()}, ${this.nono.paraTextoSaida()})`;
12189
12239
  }
12190
12240
  }
12191
12241
  exports.Noneto = Noneto;
@@ -12225,7 +12275,7 @@ class Octeto extends tupla_1.Tupla {
12225
12275
  ` />`);
12226
12276
  }
12227
12277
  paraTextoSaida() {
12228
- return `[(${this.primeiro.paraTextoSaida()}, ${this.segundo.paraTextoSaida()}, ${this.terceiro.paraTextoSaida()}, ${this.quarto.paraTextoSaida()}, ${this.quinto.paraTextoSaida()}, ${this.sexto.paraTextoSaida()}, ${this.setimo.paraTextoSaida()}, ${this.oitavo.paraTextoSaida()})]`;
12278
+ return `(${this.primeiro.paraTextoSaida()}, ${this.segundo.paraTextoSaida()}, ${this.terceiro.paraTextoSaida()}, ${this.quarto.paraTextoSaida()}, ${this.quinto.paraTextoSaida()}, ${this.sexto.paraTextoSaida()}, ${this.setimo.paraTextoSaida()}, ${this.oitavo.paraTextoSaida()})`;
12229
12279
  }
12230
12280
  }
12231
12281
  exports.Octeto = Octeto;
@@ -12251,7 +12301,7 @@ class Quarteto extends tupla_1.Tupla {
12251
12301
  ` />`);
12252
12302
  }
12253
12303
  paraTextoSaida() {
12254
- return `[(${this.primeiro.paraTextoSaida()}, ${this.segundo.paraTextoSaida()}, ${this.terceiro.paraTextoSaida()}, ${this.quarto.paraTextoSaida()})]`;
12304
+ return `(${this.primeiro.paraTextoSaida()}, ${this.segundo.paraTextoSaida()}, ${this.terceiro.paraTextoSaida()}, ${this.quarto.paraTextoSaida()})`;
12255
12305
  }
12256
12306
  }
12257
12307
  exports.Quarteto = Quarteto;
@@ -12279,7 +12329,7 @@ class Quinteto extends tupla_1.Tupla {
12279
12329
  ` />`);
12280
12330
  }
12281
12331
  paraTextoSaida() {
12282
- return `[(${this.primeiro.paraTextoSaida()}, ${this.segundo.paraTextoSaida()}, , ${this.terceiro.paraTextoSaida()}, ${this.quarto.paraTextoSaida()}, ${this.quinto.paraTextoSaida()})]`;
12332
+ return `(${this.primeiro.paraTextoSaida()}, ${this.segundo.paraTextoSaida()}, , ${this.terceiro.paraTextoSaida()}, ${this.quarto.paraTextoSaida()}, ${this.quinto.paraTextoSaida()})`;
12283
12333
  }
12284
12334
  }
12285
12335
  exports.Quinteto = Quinteto;
@@ -12317,7 +12367,7 @@ class Septeto extends tupla_1.Tupla {
12317
12367
  ` />`);
12318
12368
  }
12319
12369
  paraTextoSaida() {
12320
- return `[(${this.primeiro.paraTextoSaida()}, ${this.segundo.paraTextoSaida()}, ${this.terceiro.paraTextoSaida()}, ${this.quarto.paraTextoSaida()}, ${this.quinto.paraTextoSaida()}, ${this.sexto.paraTextoSaida()}, ${this.setimo.paraTextoSaida()})]`;
12370
+ return `(${this.primeiro.paraTextoSaida()}, ${this.segundo.paraTextoSaida()}, ${this.terceiro.paraTextoSaida()}, ${this.quarto.paraTextoSaida()}, ${this.quinto.paraTextoSaida()}, ${this.sexto.paraTextoSaida()}, ${this.setimo.paraTextoSaida()})`;
12321
12371
  }
12322
12372
  }
12323
12373
  exports.Septeto = Septeto;
@@ -12347,7 +12397,7 @@ class Sexteto extends tupla_1.Tupla {
12347
12397
  ` />`);
12348
12398
  }
12349
12399
  paraTextoSaida() {
12350
- return `[(${this.primeiro.paraTextoSaida()}, ${this.segundo.paraTextoSaida()}, ${this.terceiro.paraTextoSaida()}, ${this.quarto.paraTextoSaida()}, ${this.quinto.paraTextoSaida()}, ${this.sexto.paraTextoSaida()})]`;
12400
+ return `(${this.primeiro.paraTextoSaida()}, ${this.segundo.paraTextoSaida()}, ${this.terceiro.paraTextoSaida()}, ${this.quarto.paraTextoSaida()}, ${this.quinto.paraTextoSaida()}, ${this.sexto.paraTextoSaida()})`;
12351
12401
  }
12352
12402
  }
12353
12403
  exports.Sexteto = Sexteto;
@@ -12371,7 +12421,7 @@ class Trio extends tupla_1.Tupla {
12371
12421
  ` />`);
12372
12422
  }
12373
12423
  paraTextoSaida() {
12374
- return `[(${this.primeiro.paraTextoSaida()}, ${this.segundo.paraTextoSaida()}, ${this.terceiro.paraTextoSaida()})]`;
12424
+ return `(${this.primeiro.paraTextoSaida()}, ${this.segundo.paraTextoSaida()}, ${this.terceiro.paraTextoSaida()})`;
12375
12425
  }
12376
12426
  }
12377
12427
  exports.Trio = Trio;
@@ -15205,6 +15255,7 @@ function inferirTipoVariavel(variavel) {
15205
15255
  case 'Number':
15206
15256
  case 'number':
15207
15257
  return 'número';
15258
+ case 'BigInt':
15208
15259
  case 'bigint':
15209
15260
  return 'longo';
15210
15261
  case 'Boolean':
@@ -15521,6 +15572,7 @@ function carregarBibliotecasGlobais(pilhaEscoposExecucao) {
15521
15572
  pilhaEscoposExecucao.definirVariavel('filtrarPor', new funcao_padrao_1.FuncaoPadrao(2, bibliotecaGlobal.filtrarPor));
15522
15573
  pilhaEscoposExecucao.definirVariavel('incluido', new funcao_padrao_1.FuncaoPadrao(2, bibliotecaGlobal.incluido));
15523
15574
  pilhaEscoposExecucao.definirVariavel('inteiro', new funcao_padrao_1.FuncaoPadrao(1, bibliotecaGlobal.inteiro));
15575
+ pilhaEscoposExecucao.definirVariavel('longo', new funcao_padrao_1.FuncaoPadrao(1, bibliotecaGlobal.longo));
15524
15576
  pilhaEscoposExecucao.definirVariavel('intervalo', new funcao_padrao_1.FuncaoPadrao(2, bibliotecaGlobal.intervalo));
15525
15577
  pilhaEscoposExecucao.definirVariavel('mapear', new funcao_padrao_1.FuncaoPadrao(2, bibliotecaGlobal.mapear));
15526
15578
  pilhaEscoposExecucao.definirVariavel('maximo', new funcao_padrao_1.FuncaoPadrao(1, bibliotecaGlobal.maximo));
@@ -16514,6 +16566,7 @@ class InterpretadorBase {
16514
16566
  this.regexInterpolacao = /\${(.*?)}/g;
16515
16567
  this.tiposNumericos = [
16516
16568
  delegua_2.default.INTEIRO,
16569
+ delegua_2.default.LONGO,
16517
16570
  delegua_2.default.NUMERO,
16518
16571
  delegua_2.default.NÚMERO,
16519
16572
  delegua_2.default.REAL,
@@ -16844,7 +16897,11 @@ class InterpretadorBase {
16844
16897
  case delegua_1.default.NEGACAO:
16845
16898
  return !this.eVerdadeiro(valor);
16846
16899
  case delegua_1.default.BIT_NOT:
16847
- return ~valor;
16900
+ // Mantém BigInt como BigInt, converte outros para Number
16901
+ if (typeof valor === 'bigint') {
16902
+ return ~valor;
16903
+ }
16904
+ return ~Number(valor);
16848
16905
  // Para incrementar e decrementar, primeiro precisamos saber se o operador
16849
16906
  // veio antes do literal ou variável.
16850
16907
  // Se veio antes e o operando é uma variável, precisamos incrementar/decrementar,
@@ -16913,6 +16970,13 @@ class InterpretadorBase {
16913
16970
  return true;
16914
16971
  if (esquerda === null)
16915
16972
  return false;
16973
+ // Handle BigInt/Number comparison
16974
+ if (typeof esquerda === 'bigint' && typeof direita === 'number') {
16975
+ return esquerda == BigInt(direita);
16976
+ }
16977
+ if (typeof esquerda === 'number' && typeof direita === 'bigint') {
16978
+ return BigInt(esquerda) == direita;
16979
+ }
16916
16980
  return esquerda === direita;
16917
16981
  }
16918
16982
  /**
@@ -16928,12 +16992,16 @@ class InterpretadorBase {
16928
16992
  ? direita.tipo
16929
16993
  : typeof direita === primitivos_1.default.NUMERO
16930
16994
  ? delegua_2.default.NUMERO
16931
- : String(NaN);
16995
+ : typeof direita === 'bigint'
16996
+ ? delegua_2.default.LONGO
16997
+ : String(NaN);
16932
16998
  const tipoEsquerda = esquerda.tipo
16933
16999
  ? esquerda.tipo
16934
17000
  : typeof esquerda === primitivos_1.default.NUMERO
16935
17001
  ? delegua_2.default.NUMERO
16936
- : String(NaN);
17002
+ : typeof esquerda === 'bigint'
17003
+ ? delegua_2.default.LONGO
17004
+ : String(NaN);
16937
17005
  if (this.tiposNumericos.includes(tipoDireita) && this.tiposNumericos.includes(tipoEsquerda))
16938
17006
  return;
16939
17007
  if (this.tiposNumericos.includes(tipoEsquerda) && tipoDireita === 'qualquer')
@@ -16963,29 +17031,41 @@ class InterpretadorBase {
16963
17031
  switch (expressao.operador.tipo) {
16964
17032
  case delegua_1.default.EXPONENCIACAO:
16965
17033
  this.verificarOperandosNumeros(expressao.operador, esquerda, direita);
17034
+ // Auto-promove para BigInt se qualquer operando for BigInt
17035
+ if (typeof valorEsquerdo === 'bigint' || typeof valorDireito === 'bigint') {
17036
+ const esq = typeof valorEsquerdo === 'bigint' ? valorEsquerdo : BigInt(Math.floor(Number(valorEsquerdo)));
17037
+ const dir = typeof valorDireito === 'bigint' ? valorDireito : BigInt(Math.floor(Number(valorDireito)));
17038
+ return esq ** dir;
17039
+ }
16966
17040
  const resultadoExponenciacao = Math.pow(valorEsquerdo, valorDireito);
16967
17041
  return resultadoExponenciacao;
16968
17042
  case delegua_1.default.MAIOR:
16969
17043
  if (this.tiposNumericos.includes(tipoEsquerdo) &&
16970
17044
  this.tiposNumericos.includes(tipoDireito)) {
16971
- return Number(valorEsquerdo) > Number(valorDireito);
17045
+ return valorEsquerdo > valorDireito;
16972
17046
  }
16973
17047
  return String(valorEsquerdo) > String(valorDireito);
16974
17048
  case delegua_1.default.MAIOR_IGUAL:
16975
17049
  this.verificarOperandosNumeros(expressao.operador, esquerda, direita);
16976
- return Number(valorEsquerdo) >= Number(valorDireito);
17050
+ return valorEsquerdo >= valorDireito;
16977
17051
  case delegua_1.default.MENOR:
16978
17052
  if (this.tiposNumericos.includes(tipoEsquerdo) &&
16979
17053
  this.tiposNumericos.includes(tipoDireito)) {
16980
- return Number(valorEsquerdo) < Number(valorDireito);
17054
+ return valorEsquerdo < valorDireito;
16981
17055
  }
16982
17056
  return String(valorEsquerdo) < String(valorDireito);
16983
17057
  case delegua_1.default.MENOR_IGUAL:
16984
17058
  this.verificarOperandosNumeros(expressao.operador, esquerda, direita);
16985
- return Number(valorEsquerdo) <= Number(valorDireito);
17059
+ return valorEsquerdo <= valorDireito;
16986
17060
  case delegua_1.default.SUBTRACAO:
16987
17061
  case delegua_1.default.MENOS_IGUAL:
16988
17062
  this.verificarOperandosNumeros(expressao.operador, esquerda, direita);
17063
+ // Auto-promove para BigInt se qualquer operando for BigInt
17064
+ if (typeof valorEsquerdo === 'bigint' || typeof valorDireito === 'bigint') {
17065
+ const esq = typeof valorEsquerdo === 'bigint' ? valorEsquerdo : BigInt(Math.floor(Number(valorEsquerdo)));
17066
+ const dir = typeof valorDireito === 'bigint' ? valorDireito : BigInt(Math.floor(Number(valorDireito)));
17067
+ return esq - dir;
17068
+ }
16989
17069
  return Number(valorEsquerdo) - Number(valorDireito);
16990
17070
  case delegua_1.default.ADICAO:
16991
17071
  case delegua_1.default.MAIS_IGUAL:
@@ -16993,6 +17073,12 @@ class InterpretadorBase {
16993
17073
  if (Array.isArray(valorEsquerdo) && Array.isArray(valorDireito)) {
16994
17074
  return valorEsquerdo.concat(valorDireito);
16995
17075
  }
17076
+ // Auto-promove para BigInt se qualquer operando for BigInt
17077
+ if (typeof valorEsquerdo === 'bigint' || typeof valorDireito === 'bigint') {
17078
+ const esq = typeof valorEsquerdo === 'bigint' ? valorEsquerdo : BigInt(Math.floor(Number(valorEsquerdo)));
17079
+ const dir = typeof valorDireito === 'bigint' ? valorDireito : BigInt(Math.floor(Number(valorDireito)));
17080
+ return esq + dir;
17081
+ }
16996
17082
  if (this.tiposNumericos.includes(tipoEsquerdo) &&
16997
17083
  this.tiposNumericos.includes(tipoDireito)) {
16998
17084
  return Number(valorEsquerdo) + Number(valorDireito);
@@ -17006,13 +17092,29 @@ class InterpretadorBase {
17006
17092
  case delegua_1.default.DIVISAO:
17007
17093
  case delegua_1.default.DIVISAO_IGUAL:
17008
17094
  this.verificarOperandosNumeros(expressao.operador, esquerda, direita);
17095
+ // SEMPRE retorna Number para precisão decimal (preferência do usuário)
17096
+ // Mesmo se operandos forem BigInt, converte para Number
17009
17097
  return Number(valorEsquerdo) / Number(valorDireito);
17010
17098
  case delegua_1.default.DIVISAO_INTEIRA:
17011
17099
  case delegua_1.default.DIVISAO_INTEIRA_IGUAL:
17012
17100
  this.verificarOperandosNumeros(expressao.operador, esquerda, direita);
17101
+ // Retorna BigInt se qualquer operando for BigInt
17102
+ if (typeof valorEsquerdo === 'bigint' || typeof valorDireito === 'bigint') {
17103
+ const esq = typeof valorEsquerdo === 'bigint' ? valorEsquerdo : BigInt(Math.floor(Number(valorEsquerdo)));
17104
+ const dir = typeof valorDireito === 'bigint' ? valorDireito : BigInt(Math.floor(Number(valorDireito)));
17105
+ return esq / dir; // Trunca automaticamente
17106
+ }
17013
17107
  return Math.floor(Number(valorEsquerdo) / Number(valorDireito));
17014
17108
  case delegua_1.default.MULTIPLICACAO:
17015
17109
  case delegua_1.default.MULTIPLICACAO_IGUAL:
17110
+ // Auto-promove para BigInt se qualquer operando for BigInt (e não for texto)
17111
+ if ((typeof valorEsquerdo === 'bigint' || typeof valorDireito === 'bigint') &&
17112
+ tipoEsquerdo !== delegua_2.default.TEXTO &&
17113
+ tipoDireito !== delegua_2.default.TEXTO) {
17114
+ const esq = typeof valorEsquerdo === 'bigint' ? valorEsquerdo : BigInt(Math.floor(Number(valorEsquerdo)));
17115
+ const dir = typeof valorDireito === 'bigint' ? valorDireito : BigInt(Math.floor(Number(valorDireito)));
17116
+ return esq * dir;
17117
+ }
17016
17118
  if (tipoEsquerdo === delegua_2.default.TEXTO ||
17017
17119
  tipoDireito === delegua_2.default.TEXTO) {
17018
17120
  // Sem ambos os valores resolvem como texto, multiplica normal.
@@ -17052,18 +17154,48 @@ class InterpretadorBase {
17052
17154
  return Number(valorEsquerdo) % Number(valorDireito);
17053
17155
  case delegua_1.default.BIT_AND:
17054
17156
  this.verificarOperandosNumeros(expressao.operador, esquerda, direita);
17157
+ // Auto-promove para BigInt se qualquer operando for BigInt
17158
+ if (typeof valorEsquerdo === 'bigint' || typeof valorDireito === 'bigint') {
17159
+ const esq = typeof valorEsquerdo === 'bigint' ? valorEsquerdo : BigInt(Math.floor(Number(valorEsquerdo)));
17160
+ const dir = typeof valorDireito === 'bigint' ? valorDireito : BigInt(Math.floor(Number(valorDireito)));
17161
+ return esq & dir;
17162
+ }
17055
17163
  return Number(valorEsquerdo) & Number(valorDireito);
17056
17164
  case delegua_1.default.BIT_XOR:
17057
17165
  this.verificarOperandosNumeros(expressao.operador, esquerda, direita);
17166
+ // Auto-promove para BigInt se qualquer operando for BigInt
17167
+ if (typeof valorEsquerdo === 'bigint' || typeof valorDireito === 'bigint') {
17168
+ const esq = typeof valorEsquerdo === 'bigint' ? valorEsquerdo : BigInt(Math.floor(Number(valorEsquerdo)));
17169
+ const dir = typeof valorDireito === 'bigint' ? valorDireito : BigInt(Math.floor(Number(valorDireito)));
17170
+ return esq ^ dir;
17171
+ }
17058
17172
  return Number(valorEsquerdo) ^ Number(valorDireito);
17059
17173
  case delegua_1.default.BIT_OR:
17060
17174
  this.verificarOperandosNumeros(expressao.operador, esquerda, direita);
17175
+ // Auto-promove para BigInt se qualquer operando for BigInt
17176
+ if (typeof valorEsquerdo === 'bigint' || typeof valorDireito === 'bigint') {
17177
+ const esq = typeof valorEsquerdo === 'bigint' ? valorEsquerdo : BigInt(Math.floor(Number(valorEsquerdo)));
17178
+ const dir = typeof valorDireito === 'bigint' ? valorDireito : BigInt(Math.floor(Number(valorDireito)));
17179
+ return esq | dir;
17180
+ }
17061
17181
  return Number(valorEsquerdo) | Number(valorDireito);
17062
17182
  case delegua_1.default.MENOR_MENOR:
17063
17183
  this.verificarOperandosNumeros(expressao.operador, esquerda, direita);
17184
+ // Auto-promove para BigInt se qualquer operando for BigInt
17185
+ if (typeof valorEsquerdo === 'bigint' || typeof valorDireito === 'bigint') {
17186
+ const esq = typeof valorEsquerdo === 'bigint' ? valorEsquerdo : BigInt(Math.floor(Number(valorEsquerdo)));
17187
+ const dir = typeof valorDireito === 'bigint' ? valorDireito : BigInt(Math.floor(Number(valorDireito)));
17188
+ return esq << dir;
17189
+ }
17064
17190
  return Number(valorEsquerdo) << Number(valorDireito);
17065
17191
  case delegua_1.default.MAIOR_MAIOR:
17066
17192
  this.verificarOperandosNumeros(expressao.operador, esquerda, direita);
17193
+ // Auto-promove para BigInt se qualquer operando for BigInt
17194
+ if (typeof valorEsquerdo === 'bigint' || typeof valorDireito === 'bigint') {
17195
+ const esq = typeof valorEsquerdo === 'bigint' ? valorEsquerdo : BigInt(Math.floor(Number(valorEsquerdo)));
17196
+ const dir = typeof valorDireito === 'bigint' ? valorDireito : BigInt(Math.floor(Number(valorDireito)));
17197
+ return esq >> dir;
17198
+ }
17067
17199
  return Number(valorEsquerdo) >> Number(valorDireito);
17068
17200
  case delegua_1.default.DIFERENTE:
17069
17201
  return !this.eIgual(valorEsquerdo, valorDireito);
@@ -19498,6 +19630,15 @@ class PilhaEscoposExecucao {
19498
19630
  switch (tipo) {
19499
19631
  case 'inteiro':
19500
19632
  return parseInt(valor);
19633
+ case 'longo':
19634
+ // Converte para BigInt
19635
+ if (typeof valor === 'bigint')
19636
+ return valor;
19637
+ if (typeof valor === 'number')
19638
+ return BigInt(Math.floor(valor));
19639
+ // Para strings, remove parte decimal antes de converter
19640
+ const strValue = String(valor).split('.')[0].trim();
19641
+ return BigInt(strValue || '0');
19501
19642
  case 'logico':
19502
19643
  case 'lógico':
19503
19644
  return Boolean(valor);
@@ -22355,6 +22496,26 @@ class LexadorBase {
22355
22496
  eAlfabetoOuDigito(caractere) {
22356
22497
  return this.eDigito(caractere) || this.eAlfabeto(caractere);
22357
22498
  }
22499
+ /**
22500
+ * Verifica se o caractere é um dígito hexadecimal (0-9, a-f, A-F).
22501
+ */
22502
+ eHexDigito(caractere) {
22503
+ return ((caractere >= '0' && caractere <= '9') ||
22504
+ (caractere >= 'a' && caractere <= 'f') ||
22505
+ (caractere >= 'A' && caractere <= 'F'));
22506
+ }
22507
+ /**
22508
+ * Verifica se o caractere é um dígito binário (0 ou 1).
22509
+ */
22510
+ eBinarioDigito(caractere) {
22511
+ return caractere === '0' || caractere === '1';
22512
+ }
22513
+ /**
22514
+ * Verifica se o caractere é um dígito octal (0-7).
22515
+ */
22516
+ eOctalDigito(caractere) {
22517
+ return caractere >= '0' && caractere <= '7';
22518
+ }
22358
22519
  /**
22359
22520
  * Indica se o código está na última linha.
22360
22521
  * @returns Verdadeiro se contador de linhas está na última linha.
@@ -22474,6 +22635,17 @@ class Lexador {
22474
22635
  eAlfabetoOuDigito(caractere) {
22475
22636
  return this.eDigito(caractere) || this.eAlfabeto(caractere);
22476
22637
  }
22638
+ eHexDigito(caractere) {
22639
+ return ((caractere >= '0' && caractere <= '9') ||
22640
+ (caractere >= 'a' && caractere <= 'f') ||
22641
+ (caractere >= 'A' && caractere <= 'F'));
22642
+ }
22643
+ eBinarioDigito(caractere) {
22644
+ return caractere === '0' || caractere === '1';
22645
+ }
22646
+ eOctalDigito(caractere) {
22647
+ return caractere >= '0' && caractere <= '7';
22648
+ }
22477
22649
  eFinalDaLinha() {
22478
22650
  if (this.codigo.length === this.linha) {
22479
22651
  return true;
@@ -22577,7 +22749,81 @@ class Lexador {
22577
22749
  mensagem: 'Texto não finalizado.',
22578
22750
  });
22579
22751
  }
22752
+ analisarHexadecimal() {
22753
+ this.avancar(); // Pula '0'
22754
+ this.avancar(); // Pula 'x' ou 'X'
22755
+ while (this.eHexDigito(this.simboloAtual())) {
22756
+ this.avancar();
22757
+ }
22758
+ const hexString = this.codigo[this.linha].substring(this.inicioSimbolo, this.atual);
22759
+ try {
22760
+ const bigintValue = BigInt(hexString);
22761
+ this.adicionarSimbolo(delegua_1.default.NUMERO, bigintValue);
22762
+ }
22763
+ catch (e) {
22764
+ this.erros.push({
22765
+ linha: this.linha + 1,
22766
+ caractere: this.simboloAnterior(),
22767
+ mensagem: `Literal hexadecimal inválido: ${hexString}`,
22768
+ });
22769
+ }
22770
+ }
22771
+ analisarBinario() {
22772
+ this.avancar(); // Pula '0'
22773
+ this.avancar(); // Pula 'b' ou 'B'
22774
+ while (this.eBinarioDigito(this.simboloAtual())) {
22775
+ this.avancar();
22776
+ }
22777
+ const binaryString = this.codigo[this.linha].substring(this.inicioSimbolo, this.atual);
22778
+ try {
22779
+ const bigintValue = BigInt(binaryString);
22780
+ this.adicionarSimbolo(delegua_1.default.NUMERO, bigintValue);
22781
+ }
22782
+ catch (e) {
22783
+ this.erros.push({
22784
+ linha: this.linha + 1,
22785
+ caractere: this.simboloAnterior(),
22786
+ mensagem: `Literal binário inválido: ${binaryString}`,
22787
+ });
22788
+ }
22789
+ }
22790
+ analisarOctal() {
22791
+ this.avancar(); // Pula '0'
22792
+ this.avancar(); // Pula 'o' ou 'O'
22793
+ while (this.eOctalDigito(this.simboloAtual())) {
22794
+ this.avancar();
22795
+ }
22796
+ const octalString = this.codigo[this.linha].substring(this.inicioSimbolo, this.atual);
22797
+ try {
22798
+ const bigintValue = BigInt(octalString);
22799
+ this.adicionarSimbolo(delegua_1.default.NUMERO, bigintValue);
22800
+ }
22801
+ catch (e) {
22802
+ this.erros.push({
22803
+ linha: this.linha + 1,
22804
+ caractere: this.simboloAnterior(),
22805
+ mensagem: `Literal octal inválido: ${octalString}`,
22806
+ });
22807
+ }
22808
+ }
22580
22809
  analisarNumero() {
22810
+ // Verifica se é um literal especial (hexadecimal, binário ou octal)
22811
+ if (this.simboloAtual() === '0') {
22812
+ const proximoChar = this.proximoSimbolo();
22813
+ if (proximoChar === 'x' || proximoChar === 'X') {
22814
+ this.analisarHexadecimal();
22815
+ return;
22816
+ }
22817
+ else if (proximoChar === 'b' || proximoChar === 'B') {
22818
+ this.analisarBinario();
22819
+ return;
22820
+ }
22821
+ else if (proximoChar === 'o' || proximoChar === 'O') {
22822
+ this.analisarOctal();
22823
+ return;
22824
+ }
22825
+ }
22826
+ // Análise de número decimal normal
22581
22827
  while (this.eDigito(this.simboloAtual())) {
22582
22828
  this.avancar();
22583
22829
  }
@@ -23652,6 +23898,7 @@ exports.default = {
23652
23898
  INTEIRO: 'inteiro',
23653
23899
  LOGICO: 'logico',
23654
23900
  LÓGICO: 'lógico',
23901
+ LONGO: 'longo',
23655
23902
  MODULO: 'modulo',
23656
23903
  MÓDULO: 'módulo',
23657
23904
  NUMERO: 'numero',
@@ -23667,6 +23914,7 @@ exports.default = {
23667
23914
  VETOR_INTEIRO: 'inteiro[]',
23668
23915
  VETOR_LOGICO: 'logico[]',
23669
23916
  VETOR_LÓGICO: 'lógico[]',
23917
+ VETOR_LONGO: 'longo[]',
23670
23918
  VETOR_NUMERO: 'numero[]',
23671
23919
  VETOR_NÚMERO: 'número[]',
23672
23920
  VETOR_QUALQUER: 'qualquer[]',
@@ -40763,6 +41011,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
40763
41011
  Object.defineProperty(exports, "__esModule", { value: true });
40764
41012
  exports.TradutorMermaidJs = void 0;
40765
41013
  const construtos_1 = require("../construtos");
41014
+ const declaracoes_1 = require("../declaracoes");
40766
41015
  const mermaid_1 = require("./mermaid");
40767
41016
  const delegua_1 = __importDefault(require("../tipos-de-simbolos/delegua"));
40768
41017
  /**
@@ -41051,9 +41300,19 @@ class TradutorMermaidJs {
41051
41300
  : aresta;
41052
41301
  if (declaracao.caminhoSenao) {
41053
41302
  this.anteriores = [];
41054
- const arestaSenao = new mermaid_1.ArestaFluxograma(declaracao, `Linha${declaracao.caminhoSenao.linha}(senão)`);
41055
- vertices.push(new mermaid_1.VerticeFluxograma(aresta, arestaSenao, 'Não'));
41056
- this.anteriores.push(arestaSenao);
41303
+ // Verifica se é "senão se" ou apenas "senão"
41304
+ const ehSenaoSe = declaracao.caminhoSenao.constructor === declaracoes_1.Se;
41305
+ if (ehSenaoSe) {
41306
+ // Para "senão se", conecta diretamente ao próximo condicional sem nó intermediário
41307
+ this.anteriores.push(aresta);
41308
+ this.ultimaDicaVertice = 'Não';
41309
+ }
41310
+ else {
41311
+ // Para "senão" simples, cria o nó intermediário
41312
+ const arestaSenao = new mermaid_1.ArestaFluxograma(declaracao, `Linha${declaracao.caminhoSenao.linha}(senão)`);
41313
+ vertices.push(new mermaid_1.VerticeFluxograma(aresta, arestaSenao, 'Não'));
41314
+ this.anteriores.push(arestaSenao);
41315
+ }
41057
41316
  const verticesSenao = await declaracao.caminhoSenao.aceitar(this);
41058
41317
  vertices = vertices.concat(verticesSenao);
41059
41318
  }
@@ -41508,11 +41767,12 @@ class TradutorMermaidJs {
41508
41767
  });
41509
41768
  }
41510
41769
  async logicaComumTraducaoVarEConst(declaracaoVarOuConst, textoInicial) {
41770
+ let adicional = '';
41511
41771
  if (declaracaoVarOuConst.inicializador) {
41512
- textoInicial += `, iniciada com: ${await declaracaoVarOuConst.inicializador.aceitar(this)}`;
41772
+ adicional += `, iniciada com: ${await declaracaoVarOuConst.inicializador.aceitar(this)}`;
41513
41773
  }
41514
- textoInicial += ')';
41515
- return Promise.resolve(textoInicial);
41774
+ adicional += ')';
41775
+ return Promise.resolve(adicional);
41516
41776
  }
41517
41777
  /**
41518
41778
  * Ponto de entrada para a tradução de declarações em um fluxograma
@@ -41571,7 +41831,7 @@ class TradutorMermaidJs {
41571
41831
  }
41572
41832
  exports.TradutorMermaidJs = TradutorMermaidJs;
41573
41833
 
41574
- },{"../construtos":62,"../tipos-de-simbolos/delegua":212,"./mermaid":222}],236:[function(require,module,exports){
41834
+ },{"../construtos":62,"../declaracoes":109,"../tipos-de-simbolos/delegua":212,"./mermaid":222}],236:[function(require,module,exports){
41575
41835
  "use strict";
41576
41836
  Object.defineProperty(exports, "__esModule", { value: true });
41577
41837
  exports.TradutorPortugolIpt = void 0;