@designliquido/delegua 1.3.2 → 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.
- package/avaliador-sintatico/avaliador-sintatico.d.ts.map +1 -1
- package/avaliador-sintatico/avaliador-sintatico.js +3 -0
- package/avaliador-sintatico/avaliador-sintatico.js.map +1 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-pitugues.d.ts.map +1 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-pitugues.js +14 -7
- package/avaliador-sintatico/dialetos/avaliador-sintatico-pitugues.js.map +1 -1
- package/bibliotecas/biblioteca-global.d.ts +7 -0
- package/bibliotecas/biblioteca-global.d.ts.map +1 -1
- package/bibliotecas/biblioteca-global.js +40 -0
- package/bibliotecas/biblioteca-global.js.map +1 -1
- package/bibliotecas/dialetos/pitugues/primitivas-texto.d.ts.map +1 -1
- package/bibliotecas/dialetos/pitugues/primitivas-texto.js +26 -0
- package/bibliotecas/dialetos/pitugues/primitivas-texto.js.map +1 -1
- package/bibliotecas/dialetos/pitugues/primitivas-vetor.d.ts.map +1 -1
- package/bibliotecas/dialetos/pitugues/primitivas-vetor.js +115 -34
- package/bibliotecas/dialetos/pitugues/primitivas-vetor.js.map +1 -1
- package/bin/package.json +1 -1
- package/construtos/tuplas/deceto.js +1 -1
- package/construtos/tuplas/deceto.js.map +1 -1
- package/construtos/tuplas/dupla.js +1 -1
- package/construtos/tuplas/dupla.js.map +1 -1
- package/construtos/tuplas/noneto.js +1 -1
- package/construtos/tuplas/noneto.js.map +1 -1
- package/construtos/tuplas/octeto.js +1 -1
- package/construtos/tuplas/octeto.js.map +1 -1
- package/construtos/tuplas/quarteto.js +1 -1
- package/construtos/tuplas/quarteto.js.map +1 -1
- package/construtos/tuplas/quinteto.js +1 -1
- package/construtos/tuplas/quinteto.js.map +1 -1
- package/construtos/tuplas/septeto.js +1 -1
- package/construtos/tuplas/septeto.js.map +1 -1
- package/construtos/tuplas/sexteto.js +1 -1
- package/construtos/tuplas/sexteto.js.map +1 -1
- package/construtos/tuplas/trio.js +1 -1
- package/construtos/tuplas/trio.js.map +1 -1
- package/inferenciador.d.ts.map +1 -1
- package/inferenciador.js +1 -0
- package/inferenciador.js.map +1 -1
- package/interpretador/comum.d.ts.map +1 -1
- package/interpretador/comum.js +1 -0
- package/interpretador/comum.js.map +1 -1
- package/interpretador/interpretador-base.d.ts.map +1 -1
- package/interpretador/interpretador-base.js +87 -7
- package/interpretador/interpretador-base.js.map +1 -1
- package/interpretador/pilha-escopos-execucao.d.ts.map +1 -1
- package/interpretador/pilha-escopos-execucao.js +9 -0
- package/interpretador/pilha-escopos-execucao.js.map +1 -1
- package/lexador/lexador-base.d.ts +12 -0
- package/lexador/lexador-base.d.ts.map +1 -1
- package/lexador/lexador-base.js +20 -0
- package/lexador/lexador-base.js.map +1 -1
- package/lexador/lexador.d.ts +6 -0
- package/lexador/lexador.d.ts.map +1 -1
- package/lexador/lexador.js +85 -0
- package/lexador/lexador.js.map +1 -1
- package/package.json +1 -1
- package/tipos-de-dados/delegua.d.ts +2 -0
- package/tipos-de-dados/delegua.d.ts.map +1 -1
- package/tipos-de-dados/delegua.js +2 -0
- package/tipos-de-dados/delegua.js.map +1 -1
- package/umd/delegua.js +271 -23
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
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
|
|
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 `
|
|
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 `
|
|
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 `
|
|
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 `
|
|
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 `
|
|
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 `
|
|
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 `
|
|
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 `
|
|
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 `
|
|
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
|
-
|
|
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
|
-
:
|
|
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
|
-
:
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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[]',
|