@designliquido/delegua 0.72.0 → 1.0.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/analisador-semantico/analisador-semantico.js +1 -1
- package/analisador-semantico/analisador-semantico.js.map +1 -1
- package/analisador-semantico/dialetos/analisador-semantico-pitugues.js +4 -4
- package/analisador-semantico/dialetos/analisador-semantico-pitugues.js.map +1 -1
- package/avaliador-sintatico/avaliador-sintatico-base.d.ts +34 -34
- package/avaliador-sintatico/avaliador-sintatico-base.d.ts.map +1 -1
- package/avaliador-sintatico/avaliador-sintatico-base.js +35 -34
- package/avaliador-sintatico/avaliador-sintatico-base.js.map +1 -1
- package/avaliador-sintatico/avaliador-sintatico.d.ts +77 -73
- package/avaliador-sintatico/avaliador-sintatico.d.ts.map +1 -1
- package/avaliador-sintatico/avaliador-sintatico.js +266 -245
- package/avaliador-sintatico/avaliador-sintatico.js.map +1 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-calango.d.ts +14 -14
- package/avaliador-sintatico/dialetos/avaliador-sintatico-calango.d.ts.map +1 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-calango.js +29 -28
- package/avaliador-sintatico/dialetos/avaliador-sintatico-calango.js.map +1 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-egua-classico.d.ts +1 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-egua-classico.d.ts.map +1 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-egua-classico.js +3 -3
- package/avaliador-sintatico/dialetos/avaliador-sintatico-egua-classico.js.map +1 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-guarani.d.ts +13 -13
- package/avaliador-sintatico/dialetos/avaliador-sintatico-guarani.d.ts.map +1 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-guarani.js +17 -17
- package/avaliador-sintatico/dialetos/avaliador-sintatico-guarani.js.map +1 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-pitugues.d.ts +41 -40
- package/avaliador-sintatico/dialetos/avaliador-sintatico-pitugues.d.ts.map +1 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-pitugues.js +208 -140
- package/avaliador-sintatico/dialetos/avaliador-sintatico-pitugues.js.map +1 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-portugol-ipt.d.ts +13 -13
- package/avaliador-sintatico/dialetos/avaliador-sintatico-portugol-ipt.d.ts.map +1 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-portugol-ipt.js +25 -25
- package/avaliador-sintatico/dialetos/avaliador-sintatico-portugol-ipt.js.map +1 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-prisma.d.ts +37 -38
- package/avaliador-sintatico/dialetos/avaliador-sintatico-prisma.d.ts.map +1 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-prisma.js +105 -110
- package/avaliador-sintatico/dialetos/avaliador-sintatico-prisma.js.map +1 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-tenda.d.ts +35 -35
- package/avaliador-sintatico/dialetos/avaliador-sintatico-tenda.d.ts.map +1 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-tenda.js +98 -101
- package/avaliador-sintatico/dialetos/avaliador-sintatico-tenda.js.map +1 -1
- package/avaliador-sintatico/traducao/avaliador-sintatico-javascript.d.ts +1 -1
- package/avaliador-sintatico/traducao/avaliador-sintatico-javascript.d.ts.map +1 -1
- package/avaliador-sintatico/traducao/avaliador-sintatico-javascript.js +3 -3
- package/avaliador-sintatico/traducao/avaliador-sintatico-javascript.js.map +1 -1
- package/bibliotecas/biblioteca-global.d.ts +3 -2
- package/bibliotecas/biblioteca-global.d.ts.map +1 -1
- package/bibliotecas/biblioteca-global.js +92 -151
- package/bibliotecas/biblioteca-global.js.map +1 -1
- package/bibliotecas/dialetos/pitugues/biblioteca-global.d.ts +3 -2
- package/bibliotecas/dialetos/pitugues/biblioteca-global.d.ts.map +1 -1
- package/bibliotecas/dialetos/pitugues/biblioteca-global.js +20 -25
- package/bibliotecas/dialetos/pitugues/biblioteca-global.js.map +1 -1
- package/bibliotecas/dialetos/pitugues/primitivas-tupla.d.ts +6 -0
- package/bibliotecas/dialetos/pitugues/primitivas-tupla.d.ts.map +1 -0
- package/bibliotecas/dialetos/pitugues/primitivas-tupla.js +23 -0
- package/bibliotecas/dialetos/pitugues/primitivas-tupla.js.map +1 -0
- package/bibliotecas/dialetos/pitugues/primitivas-vetor.d.ts.map +1 -1
- package/bibliotecas/dialetos/pitugues/primitivas-vetor.js +16 -0
- package/bibliotecas/dialetos/pitugues/primitivas-vetor.js.map +1 -1
- package/bibliotecas/primitivas-tupla.d.ts +6 -0
- package/bibliotecas/primitivas-tupla.d.ts.map +1 -0
- package/bibliotecas/primitivas-tupla.js +45 -0
- package/bibliotecas/primitivas-tupla.js.map +1 -0
- package/bibliotecas/primitivas-vetor.d.ts.map +1 -1
- package/bibliotecas/primitivas-vetor.js +38 -0
- package/bibliotecas/primitivas-vetor.js.map +1 -1
- package/bin/package.json +1 -1
- package/construtos/dicionario.d.ts +2 -1
- package/construtos/dicionario.d.ts.map +1 -1
- package/construtos/dicionario.js +2 -1
- package/construtos/dicionario.js.map +1 -1
- package/construtos/literal.d.ts +1 -1
- package/construtos/literal.d.ts.map +1 -1
- package/construtos/literal.js +4 -0
- package/construtos/literal.js.map +1 -1
- package/estilizador/regras/index.d.ts +1 -0
- package/estilizador/regras/index.d.ts.map +1 -1
- package/estilizador/regras/index.js +1 -0
- package/estilizador/regras/index.js.map +1 -1
- package/estilizador/regras/paradigma-consistente.d.ts +45 -0
- package/estilizador/regras/paradigma-consistente.d.ts.map +1 -0
- package/estilizador/regras/paradigma-consistente.js +89 -0
- package/estilizador/regras/paradigma-consistente.js.map +1 -0
- package/formatadores/formatador-delegua.d.ts.map +1 -1
- package/formatadores/formatador-delegua.js +10 -3
- package/formatadores/formatador-delegua.js.map +1 -1
- package/interfaces/avaliador-sintatico-interface.d.ts +1 -1
- package/interfaces/avaliador-sintatico-interface.d.ts.map +1 -1
- package/interpretador/dialetos/calango/index.d.ts +2 -0
- package/interpretador/dialetos/calango/index.d.ts.map +1 -0
- package/interpretador/dialetos/calango/index.js +18 -0
- package/interpretador/dialetos/calango/index.js.map +1 -0
- package/interpretador/dialetos/egua-classico/interpretador-egua-classico.d.ts +1 -1
- package/interpretador/dialetos/egua-classico/interpretador-egua-classico.js +1 -1
- package/interpretador/dialetos/egua-classico/interpretador-egua-classico.js.map +1 -1
- package/interpretador/dialetos/index.d.ts +2 -0
- package/interpretador/dialetos/index.d.ts.map +1 -1
- package/interpretador/dialetos/index.js +2 -0
- package/interpretador/dialetos/index.js.map +1 -1
- package/interpretador/dialetos/pitugues/comum.d.ts.map +1 -1
- package/interpretador/dialetos/pitugues/comum.js +19 -0
- package/interpretador/dialetos/pitugues/comum.js.map +1 -1
- package/interpretador/dialetos/pitugues/interpretador-pitugues.d.ts +2 -1
- package/interpretador/dialetos/pitugues/interpretador-pitugues.d.ts.map +1 -1
- package/interpretador/dialetos/pitugues/interpretador-pitugues.js +42 -1
- package/interpretador/dialetos/pitugues/interpretador-pitugues.js.map +1 -1
- package/interpretador/dialetos/portugol-ipt/interpretador-portugol-ipt.d.ts +1 -1
- package/interpretador/dialetos/portugol-ipt/interpretador-portugol-ipt.d.ts.map +1 -1
- package/interpretador/dialetos/portugol-ipt/interpretador-portugol-ipt.js +3 -4
- package/interpretador/dialetos/portugol-ipt/interpretador-portugol-ipt.js.map +1 -1
- package/interpretador/interpretador-base.d.ts.map +1 -1
- package/interpretador/interpretador-base.js +60 -15
- package/interpretador/interpretador-base.js.map +1 -1
- package/interpretador/interpretador.d.ts.map +1 -1
- package/interpretador/interpretador.js +53 -23
- package/interpretador/interpretador.js.map +1 -1
- package/lexador/dialetos/lexador-pitugues.d.ts.map +1 -1
- package/lexador/dialetos/lexador-pitugues.js +8 -0
- package/lexador/dialetos/lexador-pitugues.js.map +1 -1
- package/lexador/filtro-paradigma.d.ts +15 -0
- package/lexador/filtro-paradigma.d.ts.map +1 -0
- package/lexador/filtro-paradigma.js +51 -0
- package/lexador/filtro-paradigma.js.map +1 -0
- package/lexador/lexador.d.ts.map +1 -1
- package/lexador/lexador.js +4 -0
- package/lexador/lexador.js.map +1 -1
- package/lexador/mapeamento-paradigmas.d.ts +47 -0
- package/lexador/mapeamento-paradigmas.d.ts.map +1 -0
- package/lexador/mapeamento-paradigmas.js +183 -0
- package/lexador/mapeamento-paradigmas.js.map +1 -0
- package/package.json +1 -1
- package/tipos-de-simbolos/delegua.d.ts +1 -0
- package/tipos-de-simbolos/delegua.d.ts.map +1 -1
- package/tipos-de-simbolos/delegua.js +1 -0
- package/tipos-de-simbolos/delegua.js.map +1 -1
- package/tipos-de-simbolos/pitugues.d.ts +2 -0
- package/tipos-de-simbolos/pitugues.d.ts.map +1 -1
- package/tipos-de-simbolos/pitugues.js +2 -0
- package/tipos-de-simbolos/pitugues.js.map +1 -1
- package/tradutores/tradutor-assembly-x64.js +122 -122
- package/tradutores/tradutor-assemblyscript.js +1 -1
- package/tradutores/tradutor-assemblyscript.js.map +1 -1
- package/tradutores/tradutor-calango.d.ts +4 -3
- package/tradutores/tradutor-calango.d.ts.map +1 -1
- package/tradutores/tradutor-calango.js +7 -14
- package/tradutores/tradutor-calango.js.map +1 -1
- package/tradutores/tradutor-javascript.d.ts.map +1 -1
- package/tradutores/tradutor-javascript.js +12 -5
- package/tradutores/tradutor-javascript.js.map +1 -1
- package/tradutores/tradutor-mermaidjs.js +1 -1
- package/tradutores/tradutor-mermaidjs.js.map +1 -1
- package/tradutores/tradutor-portugol-ipt.d.ts +1 -1
- package/tradutores/tradutor-portugol-ipt.d.ts.map +1 -1
- package/tradutores/tradutor-portugol-ipt.js +3 -3
- package/tradutores/tradutor-portugol-ipt.js.map +1 -1
- package/tradutores/tradutor-python.d.ts.map +1 -1
- package/tradutores/tradutor-python.js +12 -5
- package/tradutores/tradutor-python.js.map +1 -1
- package/tradutores/tradutor-reverso-tenda.js +1 -1
- package/tradutores/tradutor-reverso-tenda.js.map +1 -1
- package/umd/delegua.js +1827 -1584
|
@@ -20,6 +20,7 @@ const primitivas_dicionario_1 = __importDefault(require("../../bibliotecas/primi
|
|
|
20
20
|
const primitivas_numero_1 = __importDefault(require("../../bibliotecas/primitivas-numero"));
|
|
21
21
|
const primitivas_texto_1 = __importDefault(require("../../bibliotecas/primitivas-texto"));
|
|
22
22
|
const primitivas_vetor_1 = __importDefault(require("../../bibliotecas/primitivas-vetor"));
|
|
23
|
+
const primitivas_tupla_1 = __importDefault(require("../../bibliotecas/dialetos/pitugues/primitivas-tupla"));
|
|
23
24
|
const micro_lexador_pitugues_1 = require("../../lexador/micro-lexador-pitugues");
|
|
24
25
|
const micro_avaliador_sintatico_pitugues_1 = require("./micro-avaliador-sintatico-pitugues");
|
|
25
26
|
/**
|
|
@@ -43,6 +44,7 @@ class AvaliadorSintaticoPitugues {
|
|
|
43
44
|
(0, comum_1.registrarPrimitiva)(this.primitivasConhecidas, 'número', primitivas_numero_1.default);
|
|
44
45
|
(0, comum_1.registrarPrimitiva)(this.primitivasConhecidas, 'texto', primitivas_texto_1.default);
|
|
45
46
|
(0, comum_1.registrarPrimitiva)(this.primitivasConhecidas, 'vetor', primitivas_vetor_1.default);
|
|
47
|
+
(0, comum_1.registrarPrimitiva)(this.primitivasConhecidas, 'tupla', primitivas_tupla_1.default);
|
|
46
48
|
}
|
|
47
49
|
logicaComumInferenciaTiposVariaveisEConstantes(inicializador, tipoPrevio) {
|
|
48
50
|
if (tipoPrevio !== 'qualquer') {
|
|
@@ -115,12 +117,12 @@ class AvaliadorSintaticoPitugues {
|
|
|
115
117
|
return inicializador.tipo;
|
|
116
118
|
}
|
|
117
119
|
}
|
|
118
|
-
expressaoLeia() {
|
|
120
|
+
async expressaoLeia() {
|
|
119
121
|
const simboloLeia = this.avancarEDevolverAnterior();
|
|
120
122
|
this.consumir(pitugues_2.default.PARENTESE_ESQUERDO, "Esperado '(' antes dos valores em leia.");
|
|
121
123
|
const argumentos = [];
|
|
122
124
|
do {
|
|
123
|
-
argumentos.push(this.expressao());
|
|
125
|
+
argumentos.push(await this.expressao());
|
|
124
126
|
} while (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.VIRGULA));
|
|
125
127
|
this.consumir(pitugues_2.default.PARENTESE_DIREITO, "Esperado ')' após os valores em leia.");
|
|
126
128
|
return new construtos_1.Leia(simboloLeia, argumentos);
|
|
@@ -137,13 +139,13 @@ class AvaliadorSintaticoPitugues {
|
|
|
137
139
|
return false;
|
|
138
140
|
}
|
|
139
141
|
}
|
|
140
|
-
declaracaoImplicitaVariaveis() {
|
|
142
|
+
async declaracaoImplicitaVariaveis() {
|
|
141
143
|
const identificador = this.consumir(pitugues_2.default.IDENTIFICADOR, 'Esperado nome de variável.');
|
|
142
144
|
this.consumir(pitugues_2.default.IGUAL, "Esperado '=' após identificador.");
|
|
143
145
|
if (this.estaNoFinal()) {
|
|
144
146
|
throw this.erro(this.simboloAnterior(), 'Esperado valor após o símbolo de igual.');
|
|
145
147
|
}
|
|
146
|
-
const valor = this.expressao();
|
|
148
|
+
const valor = await this.expressao();
|
|
147
149
|
const tipo = this.logicaComumInferenciaTiposVariaveisEConstantes(valor, 'qualquer');
|
|
148
150
|
this.pilhaEscopos.definirInformacoesVariavel(identificador.lexema, new informacao_elemento_sintatico_1.InformacaoElementoSintatico(identificador.lexema, tipo));
|
|
149
151
|
return new declaracoes_1.Var(identificador, valor, tipo);
|
|
@@ -231,13 +233,13 @@ class AvaliadorSintaticoPitugues {
|
|
|
231
233
|
} while (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.VIRGULA));
|
|
232
234
|
return { simbolos: identificadores, indexResto };
|
|
233
235
|
}
|
|
234
|
-
consumirInicializadores() {
|
|
236
|
+
async consumirInicializadores() {
|
|
235
237
|
const inicializadores = [];
|
|
236
238
|
do {
|
|
237
239
|
if (this.estaNoFinal()) {
|
|
238
240
|
throw this.erro(this.simboloAtual(), 'Esperado inicializador após vírgula.');
|
|
239
241
|
}
|
|
240
|
-
inicializadores.push(this.expressao());
|
|
242
|
+
inicializadores.push(await this.expressao());
|
|
241
243
|
} while (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.VIRGULA));
|
|
242
244
|
return inicializadores;
|
|
243
245
|
}
|
|
@@ -249,10 +251,10 @@ class AvaliadorSintaticoPitugues {
|
|
|
249
251
|
const falha = new declaracoes_1.Falhar(new lexador_1.Simbolo(pitugues_2.default.FALHAR, "falhar", null, linha, -1), new construtos_1.Literal(this.hashArquivo, linha, mensagem, 'texto'));
|
|
250
252
|
return new declaracoes_1.Se(condicaoErro, new declaracoes_1.Bloco(this.hashArquivo, linha, [falha]), [], null);
|
|
251
253
|
}
|
|
252
|
-
declaracaoDeVariaveis() {
|
|
254
|
+
async declaracaoDeVariaveis() {
|
|
253
255
|
const { simbolos: identificadores, indexResto } = this.consumirIdentificadores();
|
|
254
256
|
this.consumir(pitugues_2.default.IGUAL, 'Esperado o símbolo igual(=) após identificador.');
|
|
255
|
-
const inicializadores = this.consumirInicializadores();
|
|
257
|
+
const inicializadores = await this.consumirInicializadores();
|
|
256
258
|
const qtdIdentificadores = identificadores.length;
|
|
257
259
|
const qtdValores = inicializadores.length;
|
|
258
260
|
const ehDesempacotamento = qtdIdentificadores > 1 && qtdValores === 1;
|
|
@@ -387,27 +389,38 @@ class AvaliadorSintaticoPitugues {
|
|
|
387
389
|
}
|
|
388
390
|
return false;
|
|
389
391
|
}
|
|
390
|
-
primario() {
|
|
392
|
+
async primario() {
|
|
391
393
|
const simboloAtual = this.simbolos[this.atual];
|
|
392
394
|
switch (simboloAtual.tipo) {
|
|
393
395
|
case pitugues_2.default.CHAVE_ESQUERDA:
|
|
394
396
|
this.avancarEDevolverAnterior();
|
|
395
397
|
const chaves = [];
|
|
396
398
|
const valoresDicionario = [];
|
|
399
|
+
const esSpread = [];
|
|
397
400
|
if (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.CHAVE_DIREITA)) {
|
|
398
|
-
return new construtos_1.Dicionario(this.hashArquivo, simboloAtual.linha, [], []);
|
|
401
|
+
return new construtos_1.Dicionario(this.hashArquivo, simboloAtual.linha, [], [], []);
|
|
399
402
|
}
|
|
400
403
|
while (!this.verificarSeSimboloAtualEIgualA(pitugues_2.default.CHAVE_DIREITA)) {
|
|
401
|
-
|
|
402
|
-
this.
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
404
|
+
// Verificar se é spread (**expressao)
|
|
405
|
+
if (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.EXPONENCIACAO)) {
|
|
406
|
+
const expressaoDicionario = await this.atribuir();
|
|
407
|
+
chaves.push(null);
|
|
408
|
+
valoresDicionario.push(expressaoDicionario);
|
|
409
|
+
esSpread.push(true);
|
|
410
|
+
}
|
|
411
|
+
else {
|
|
412
|
+
const chave = await this.atribuir();
|
|
413
|
+
this.consumir(pitugues_2.default.DOIS_PONTOS, "Esperado ':' entre chave e valor.");
|
|
414
|
+
const valor = await this.atribuir();
|
|
415
|
+
chaves.push(chave);
|
|
416
|
+
valoresDicionario.push(valor);
|
|
417
|
+
esSpread.push(false);
|
|
418
|
+
}
|
|
406
419
|
if (this.simboloAtual().tipo !== pitugues_2.default.CHAVE_DIREITA) {
|
|
407
420
|
this.consumir(pitugues_2.default.VIRGULA, 'Esperado vírgula antes da próxima expressão.');
|
|
408
421
|
}
|
|
409
422
|
}
|
|
410
|
-
return new construtos_1.Dicionario(this.hashArquivo, simboloAtual.linha, chaves, valoresDicionario);
|
|
423
|
+
return new construtos_1.Dicionario(this.hashArquivo, simboloAtual.linha, chaves, valoresDicionario, esSpread);
|
|
411
424
|
case pitugues_2.default.COLCHETE_ESQUERDO:
|
|
412
425
|
this.avancarEDevolverAnterior();
|
|
413
426
|
if (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.COLCHETE_DIREITO)) {
|
|
@@ -419,7 +432,7 @@ class AvaliadorSintaticoPitugues {
|
|
|
419
432
|
}
|
|
420
433
|
const valoresVetor = [];
|
|
421
434
|
while (!this.verificarSeSimboloAtualEIgualA(pitugues_2.default.COLCHETE_DIREITO)) {
|
|
422
|
-
const valor = this.atribuir();
|
|
435
|
+
const valor = await this.atribuir();
|
|
423
436
|
valoresVetor.push(valor);
|
|
424
437
|
if (this.simbolos[this.atual].tipo !== pitugues_2.default.COLCHETE_DIREITO) {
|
|
425
438
|
this.consumir(pitugues_2.default.VIRGULA, 'Esperado vírgula antes da próxima expressão.');
|
|
@@ -437,7 +450,7 @@ class AvaliadorSintaticoPitugues {
|
|
|
437
450
|
case pitugues_2.default.FUNCAO:
|
|
438
451
|
case pitugues_2.default.FUNÇÃO:
|
|
439
452
|
const simboloFuncao = this.avancarEDevolverAnterior();
|
|
440
|
-
const corpoDaFuncao = this.corpoDaFuncao(simboloFuncao.lexema);
|
|
453
|
+
const corpoDaFuncao = await this.corpoDaFuncao(simboloFuncao.lexema);
|
|
441
454
|
this.pilhaEscopos.definirInformacoesVariavel(simboloFuncao.lexema, new informacao_elemento_sintatico_1.InformacaoElementoSintatico(simboloFuncao.lexema, 'função'));
|
|
442
455
|
return corpoDaFuncao;
|
|
443
456
|
case pitugues_2.default.IMPORTAR:
|
|
@@ -449,7 +462,7 @@ class AvaliadorSintaticoPitugues {
|
|
|
449
462
|
const simboloIsto = this.avancarEDevolverAnterior();
|
|
450
463
|
return new construtos_1.Isto(this.hashArquivo, simboloAtual.linha, simboloIsto);
|
|
451
464
|
case pitugues_2.default.LEIA:
|
|
452
|
-
return this.expressaoLeia();
|
|
465
|
+
return await this.expressaoLeia();
|
|
453
466
|
case pitugues_2.default.NUMERO:
|
|
454
467
|
case pitugues_2.default.TEXTO:
|
|
455
468
|
const simboloLiteral = this.avancarEDevolverAnterior();
|
|
@@ -503,7 +516,7 @@ class AvaliadorSintaticoPitugues {
|
|
|
503
516
|
if (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.PARENTESE_DIREITO)) {
|
|
504
517
|
return new construtos_1.TuplaN(this.hashArquivo, simboloAtual.linha, []);
|
|
505
518
|
}
|
|
506
|
-
const expressao = this.tupla();
|
|
519
|
+
const expressao = await this.tupla();
|
|
507
520
|
// Se a expressão já é uma tupla (com vírgulas), retorna ela
|
|
508
521
|
if (expressao instanceof construtos_1.TuplaN) {
|
|
509
522
|
this.consumir(pitugues_2.default.PARENTESE_DIREITO, "Esperado ')' após itens da tupla.");
|
|
@@ -517,14 +530,14 @@ class AvaliadorSintaticoPitugues {
|
|
|
517
530
|
}
|
|
518
531
|
throw this.erro(this.simboloAtual(), 'Esperado expressão.');
|
|
519
532
|
}
|
|
520
|
-
finalizarChamada(entidadeChamada) {
|
|
533
|
+
async finalizarChamada(entidadeChamada) {
|
|
521
534
|
const argumentos = [];
|
|
522
535
|
if (!this.verificarTipoSimboloAtual(pitugues_2.default.PARENTESE_DIREITO)) {
|
|
523
536
|
do {
|
|
524
537
|
if (argumentos.length >= 255) {
|
|
525
538
|
throw this.erro(this.simboloAtual(), 'Não pode haver mais de 255 argumentos.');
|
|
526
539
|
}
|
|
527
|
-
argumentos.push(this.expressao());
|
|
540
|
+
argumentos.push(await this.expressao());
|
|
528
541
|
} while (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.VIRGULA));
|
|
529
542
|
}
|
|
530
543
|
this.consumir(pitugues_2.default.PARENTESE_DIREITO, "Esperado ')' após os argumentos.");
|
|
@@ -532,11 +545,11 @@ class AvaliadorSintaticoPitugues {
|
|
|
532
545
|
chamada.tipo = entidadeChamada.tipo;
|
|
533
546
|
return chamada;
|
|
534
547
|
}
|
|
535
|
-
chamar() {
|
|
536
|
-
let expressao = this.primario();
|
|
548
|
+
async chamar() {
|
|
549
|
+
let expressao = await this.primario();
|
|
537
550
|
while (true) {
|
|
538
551
|
if (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.PARENTESE_ESQUERDO)) {
|
|
539
|
-
expressao = this.finalizarChamada(expressao);
|
|
552
|
+
expressao = await this.finalizarChamada(expressao);
|
|
540
553
|
}
|
|
541
554
|
else if (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.PONTO)) {
|
|
542
555
|
const nome = this.consumir(pitugues_2.default.IDENTIFICADOR, "Esperado nome do método após '.'.");
|
|
@@ -547,14 +560,14 @@ class AvaliadorSintaticoPitugues {
|
|
|
547
560
|
let indiceInicio = null;
|
|
548
561
|
let indiceFim = null;
|
|
549
562
|
if (!this.verificarTipoSimboloAtual(pitugues_2.default.DOIS_PONTOS)) {
|
|
550
|
-
indiceInicio = this.expressao();
|
|
563
|
+
indiceInicio = await this.expressao();
|
|
551
564
|
}
|
|
552
565
|
if (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.DOIS_PONTOS)) {
|
|
553
566
|
ehFatiamento = true;
|
|
554
567
|
// Se o próximo não é ':', nem ']', então é o índice fim
|
|
555
568
|
if (!this.verificarTipoSimboloAtual(pitugues_2.default.DOIS_PONTOS) &&
|
|
556
569
|
!this.verificarTipoSimboloAtual(pitugues_2.default.COLCHETE_DIREITO)) {
|
|
557
|
-
indiceFim = this.expressao();
|
|
570
|
+
indiceFim = await this.expressao();
|
|
558
571
|
}
|
|
559
572
|
}
|
|
560
573
|
const simboloFechamento = this.consumir(pitugues_2.default.COLCHETE_DIREITO, "Esperado ']' após escrita do indice.");
|
|
@@ -571,88 +584,88 @@ class AvaliadorSintaticoPitugues {
|
|
|
571
584
|
}
|
|
572
585
|
return expressao;
|
|
573
586
|
}
|
|
574
|
-
unario() {
|
|
587
|
+
async unario() {
|
|
575
588
|
if (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.NEGACAO, pitugues_2.default.SUBTRACAO, pitugues_2.default.BIT_NOT)) {
|
|
576
589
|
const operador = this.simboloAnterior();
|
|
577
|
-
const direito = this.unario();
|
|
590
|
+
const direito = await this.unario();
|
|
578
591
|
return new construtos_1.Unario(this.hashArquivo, operador, direito);
|
|
579
592
|
}
|
|
580
|
-
return this.chamar();
|
|
593
|
+
return await this.chamar();
|
|
581
594
|
}
|
|
582
|
-
exponenciacao() {
|
|
583
|
-
let expressao = this.unario();
|
|
595
|
+
async exponenciacao() {
|
|
596
|
+
let expressao = await this.unario();
|
|
584
597
|
while (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.EXPONENCIACAO)) {
|
|
585
598
|
const operador = this.simboloAnterior();
|
|
586
|
-
const direito = this.exponenciacao();
|
|
599
|
+
const direito = await this.exponenciacao();
|
|
587
600
|
expressao = new construtos_1.Binario(this.hashArquivo, expressao, operador, direito);
|
|
588
601
|
}
|
|
589
602
|
return expressao;
|
|
590
603
|
}
|
|
591
|
-
multiplicar() {
|
|
592
|
-
let expressao = this.exponenciacao();
|
|
604
|
+
async multiplicar() {
|
|
605
|
+
let expressao = await this.exponenciacao();
|
|
593
606
|
while (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.DIVISAO, pitugues_2.default.DIVISAO_INTEIRA, pitugues_2.default.MULTIPLICACAO, pitugues_2.default.MODULO)) {
|
|
594
607
|
const operador = this.simboloAnterior();
|
|
595
|
-
const direito = this.exponenciacao();
|
|
608
|
+
const direito = await this.exponenciacao();
|
|
596
609
|
expressao = new construtos_1.Binario(this.hashArquivo, expressao, operador, direito);
|
|
597
610
|
}
|
|
598
611
|
return expressao;
|
|
599
612
|
}
|
|
600
|
-
adicaoOuSubtracao() {
|
|
601
|
-
let expressao = this.multiplicar();
|
|
613
|
+
async adicaoOuSubtracao() {
|
|
614
|
+
let expressao = await this.multiplicar();
|
|
602
615
|
while (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.SUBTRACAO, pitugues_2.default.ADICAO)) {
|
|
603
616
|
const operador = this.simboloAnterior();
|
|
604
|
-
const direito = this.multiplicar();
|
|
617
|
+
const direito = await this.multiplicar();
|
|
605
618
|
expressao = new construtos_1.Binario(this.hashArquivo, expressao, operador, direito);
|
|
606
619
|
}
|
|
607
620
|
return expressao;
|
|
608
621
|
}
|
|
609
|
-
bitShift() {
|
|
610
|
-
let expressao = this.adicaoOuSubtracao();
|
|
622
|
+
async bitShift() {
|
|
623
|
+
let expressao = await this.adicaoOuSubtracao();
|
|
611
624
|
while (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.MENOR_MENOR, pitugues_2.default.MAIOR_MAIOR)) {
|
|
612
625
|
const operador = this.simboloAnterior();
|
|
613
|
-
const direito = this.adicaoOuSubtracao();
|
|
626
|
+
const direito = await this.adicaoOuSubtracao();
|
|
614
627
|
expressao = new construtos_1.Binario(this.hashArquivo, expressao, operador, direito);
|
|
615
628
|
}
|
|
616
629
|
return expressao;
|
|
617
630
|
}
|
|
618
|
-
bitE() {
|
|
619
|
-
let expressao = this.bitShift();
|
|
631
|
+
async bitE() {
|
|
632
|
+
let expressao = await this.bitShift();
|
|
620
633
|
while (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.BIT_AND)) {
|
|
621
634
|
const operador = this.simboloAnterior();
|
|
622
|
-
const direito = this.bitShift();
|
|
635
|
+
const direito = await this.bitShift();
|
|
623
636
|
expressao = new construtos_1.Binario(this.hashArquivo, expressao, operador, direito);
|
|
624
637
|
}
|
|
625
638
|
return expressao;
|
|
626
639
|
}
|
|
627
|
-
bitOu() {
|
|
628
|
-
let expressao = this.bitE();
|
|
640
|
+
async bitOu() {
|
|
641
|
+
let expressao = await this.bitE();
|
|
629
642
|
while (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.BIT_OR, pitugues_2.default.BIT_XOR)) {
|
|
630
643
|
const operador = this.simboloAnterior();
|
|
631
|
-
const direito = this.bitE();
|
|
644
|
+
const direito = await this.bitE();
|
|
632
645
|
expressao = new construtos_1.Binario(this.hashArquivo, expressao, operador, direito);
|
|
633
646
|
}
|
|
634
647
|
return expressao;
|
|
635
648
|
}
|
|
636
|
-
comparar() {
|
|
637
|
-
let expressao = this.bitOu();
|
|
649
|
+
async comparar() {
|
|
650
|
+
let expressao = await this.bitOu();
|
|
638
651
|
while (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.MAIOR, pitugues_2.default.MAIOR_IGUAL, pitugues_2.default.MENOR, pitugues_2.default.MENOR_IGUAL)) {
|
|
639
652
|
const operador = this.simboloAnterior();
|
|
640
|
-
const direito = this.bitOu();
|
|
653
|
+
const direito = await this.bitOu();
|
|
641
654
|
expressao = new construtos_1.Binario(this.hashArquivo, expressao, operador, direito);
|
|
642
655
|
}
|
|
643
656
|
return expressao;
|
|
644
657
|
}
|
|
645
|
-
comparacaoIgualdade() {
|
|
646
|
-
let expressao = this.comparar();
|
|
658
|
+
async comparacaoIgualdade() {
|
|
659
|
+
let expressao = await this.comparar();
|
|
647
660
|
while (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.DIFERENTE, pitugues_2.default.IGUAL_IGUAL)) {
|
|
648
661
|
const operador = this.simboloAnterior();
|
|
649
|
-
const direito = this.comparar();
|
|
662
|
+
const direito = await this.comparar();
|
|
650
663
|
expressao = new construtos_1.Binario(this.hashArquivo, expressao, operador, direito);
|
|
651
664
|
}
|
|
652
665
|
return expressao;
|
|
653
666
|
}
|
|
654
|
-
em() {
|
|
655
|
-
let expressao = this.comparacaoIgualdade();
|
|
667
|
+
async em() {
|
|
668
|
+
let expressao = await this.comparacaoIgualdade();
|
|
656
669
|
while (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.EM, pitugues_2.default.CONTEM, pitugues_2.default.NAO)) {
|
|
657
670
|
let operador = this.simboloAnterior();
|
|
658
671
|
let negado = false;
|
|
@@ -660,46 +673,46 @@ class AvaliadorSintaticoPitugues {
|
|
|
660
673
|
operador = this.consumir(pitugues_2.default.CONTEM, `Esperado palavra reservada 'contém' ou 'contem' após palavra reservada ${operador.lexema}.`);
|
|
661
674
|
negado = true;
|
|
662
675
|
}
|
|
663
|
-
const direito = this.comparacaoIgualdade();
|
|
676
|
+
const direito = await this.comparacaoIgualdade();
|
|
664
677
|
expressao = new construtos_1.Logico(this.hashArquivo, expressao, operador, direito);
|
|
665
678
|
expressao.negado = negado;
|
|
666
679
|
}
|
|
667
680
|
return expressao;
|
|
668
681
|
}
|
|
669
|
-
e() {
|
|
670
|
-
let expressao = this.em();
|
|
682
|
+
async e() {
|
|
683
|
+
let expressao = await this.em();
|
|
671
684
|
while (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.E)) {
|
|
672
685
|
const operador = this.simboloAnterior();
|
|
673
|
-
const direito = this.em();
|
|
686
|
+
const direito = await this.em();
|
|
674
687
|
expressao = new construtos_1.Logico(this.hashArquivo, expressao, operador, direito);
|
|
675
688
|
}
|
|
676
689
|
return expressao;
|
|
677
690
|
}
|
|
678
|
-
ou() {
|
|
679
|
-
let expressao = this.e();
|
|
691
|
+
async ou() {
|
|
692
|
+
let expressao = await this.e();
|
|
680
693
|
while (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.OU)) {
|
|
681
694
|
const operador = this.simboloAnterior();
|
|
682
|
-
const direito = this.e();
|
|
695
|
+
const direito = await this.e();
|
|
683
696
|
expressao = new construtos_1.Logico(this.hashArquivo, expressao, operador, direito);
|
|
684
697
|
}
|
|
685
698
|
return expressao;
|
|
686
699
|
}
|
|
687
|
-
seTernario() {
|
|
688
|
-
let expressaoEntao = this.ou();
|
|
700
|
+
async seTernario() {
|
|
701
|
+
let expressaoEntao = await this.ou();
|
|
689
702
|
if (this.simbolos[this.atual] && this.simbolos[this.atual].tipo === pitugues_2.default.SE && expressaoEntao.linha === this.simbolos[this.atual].linha) {
|
|
690
703
|
while (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.SE)) {
|
|
691
704
|
const operador = this.simbolos[this.atual - 1];
|
|
692
|
-
const expressaoOuCondicao = this.seTernario();
|
|
705
|
+
const expressaoOuCondicao = await this.seTernario();
|
|
693
706
|
this.consumir(pitugues_2.default.SENAO, `Esperado 'senão' ou 'senao' após caminho positivo em se ternário. Atual:
|
|
694
707
|
${this.simbolos[this.atual].lexema}.`);
|
|
695
|
-
const expressaoSenao = this.seTernario();
|
|
708
|
+
const expressaoSenao = await this.seTernario();
|
|
696
709
|
expressaoEntao = new construtos_1.SeTernario(this.hashArquivo, expressaoOuCondicao, expressaoEntao, operador, expressaoSenao);
|
|
697
710
|
}
|
|
698
711
|
}
|
|
699
712
|
return expressaoEntao;
|
|
700
713
|
}
|
|
701
|
-
tupla() {
|
|
702
|
-
let expressao = this.seTernario();
|
|
714
|
+
async tupla() {
|
|
715
|
+
let expressao = await this.seTernario();
|
|
703
716
|
// Se não há vírgula, retorna a expressão simples
|
|
704
717
|
if (!this.verificarSeSimboloAtualEIgualA(pitugues_2.default.VIRGULA)) {
|
|
705
718
|
return expressao;
|
|
@@ -710,49 +723,80 @@ class AvaliadorSintaticoPitugues {
|
|
|
710
723
|
if (this.verificarTipoSimboloAtual(pitugues_2.default.PARENTESE_DIREITO)) {
|
|
711
724
|
break;
|
|
712
725
|
}
|
|
713
|
-
elementos.push(this.seTernario());
|
|
726
|
+
elementos.push(await this.seTernario());
|
|
714
727
|
} while (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.VIRGULA));
|
|
715
728
|
return new construtos_1.TuplaN(this.hashArquivo, expressao.linha, elementos);
|
|
716
729
|
}
|
|
717
|
-
atribuir() {
|
|
718
|
-
const expressao = this.seTernario();
|
|
719
|
-
if (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.IGUAL)
|
|
720
|
-
this.
|
|
721
|
-
const
|
|
722
|
-
|
|
730
|
+
async atribuir() {
|
|
731
|
+
const expressao = await this.seTernario();
|
|
732
|
+
if (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.IGUAL, pitugues_2.default.MAIS_IGUAL, pitugues_2.default.MENOS_IGUAL, pitugues_2.default.MULTIPLICACAO_IGUAL, pitugues_2.default.DIVISAO_IGUAL)) {
|
|
733
|
+
const operadorAtribuicao = this.simboloAnterior();
|
|
734
|
+
const valor = await this.atribuir();
|
|
735
|
+
// Se for apenas '=', é uma atribuição padrão
|
|
736
|
+
if (operadorAtribuicao.tipo === pitugues_2.default.IGUAL) {
|
|
737
|
+
if (expressao instanceof construtos_1.Variavel) {
|
|
738
|
+
return new construtos_1.Atribuir(this.hashArquivo, expressao, valor);
|
|
739
|
+
}
|
|
740
|
+
if (expressao instanceof construtos_1.AcessoMetodoOuPropriedade) {
|
|
741
|
+
return new construtos_1.DefinirValor(this.hashArquivo, 0, expressao.objeto, expressao.simbolo, valor);
|
|
742
|
+
}
|
|
743
|
+
if (expressao instanceof construtos_1.AcessoIndiceVariavel) {
|
|
744
|
+
return new construtos_1.AtribuicaoPorIndice(this.hashArquivo, 0, expressao.entidadeChamada, expressao.indice, valor);
|
|
745
|
+
}
|
|
746
|
+
throw this.erro(operadorAtribuicao, 'Tarefa de atribuição inválida');
|
|
747
|
+
}
|
|
748
|
+
// Se for +=, -=, *=, /=
|
|
749
|
+
// Transforma 'a += 1' em 'a = a + 1'
|
|
750
|
+
let tipoOperadorMatematico;
|
|
751
|
+
switch (operadorAtribuicao.tipo) {
|
|
752
|
+
case pitugues_2.default.MAIS_IGUAL:
|
|
753
|
+
tipoOperadorMatematico = pitugues_2.default.ADICAO;
|
|
754
|
+
break;
|
|
755
|
+
case pitugues_2.default.MENOS_IGUAL:
|
|
756
|
+
tipoOperadorMatematico = pitugues_2.default.SUBTRACAO;
|
|
757
|
+
break;
|
|
758
|
+
case pitugues_2.default.MULTIPLICACAO_IGUAL:
|
|
759
|
+
tipoOperadorMatematico = pitugues_2.default.MULTIPLICACAO;
|
|
760
|
+
break;
|
|
761
|
+
case pitugues_2.default.DIVISAO_IGUAL:
|
|
762
|
+
tipoOperadorMatematico = pitugues_2.default.DIVISAO;
|
|
763
|
+
break;
|
|
764
|
+
}
|
|
765
|
+
const simboloOperador = new lexador_1.Simbolo(tipoOperadorMatematico, operadorAtribuicao.lexema.charAt(0), null, operadorAtribuicao.linha, operadorAtribuicao.hashArquivo);
|
|
766
|
+
const operacaoBinaria = new construtos_1.Binario(this.hashArquivo, expressao, simboloOperador, valor);
|
|
723
767
|
if (expressao instanceof construtos_1.Variavel) {
|
|
724
|
-
return new construtos_1.Atribuir(this.hashArquivo, expressao,
|
|
768
|
+
return new construtos_1.Atribuir(this.hashArquivo, expressao, operacaoBinaria);
|
|
725
769
|
}
|
|
726
770
|
if (expressao instanceof construtos_1.AcessoMetodoOuPropriedade) {
|
|
727
|
-
return new construtos_1.DefinirValor(this.hashArquivo, 0, expressao.objeto, expressao.simbolo,
|
|
771
|
+
return new construtos_1.DefinirValor(this.hashArquivo, 0, expressao.objeto, expressao.simbolo, operacaoBinaria);
|
|
728
772
|
}
|
|
729
773
|
if (expressao instanceof construtos_1.AcessoIndiceVariavel) {
|
|
730
|
-
return new construtos_1.AtribuicaoPorIndice(this.hashArquivo, 0, expressao.entidadeChamada, expressao.indice,
|
|
774
|
+
return new construtos_1.AtribuicaoPorIndice(this.hashArquivo, 0, expressao.entidadeChamada, expressao.indice, operacaoBinaria);
|
|
731
775
|
}
|
|
732
|
-
throw this.erro(
|
|
776
|
+
throw this.erro(operadorAtribuicao, 'Tarefa de atribuição inválida');
|
|
733
777
|
}
|
|
734
778
|
return expressao;
|
|
735
779
|
}
|
|
736
780
|
// TODO: Depreciar.
|
|
737
|
-
expressao() {
|
|
738
|
-
return this.atribuir();
|
|
781
|
+
async expressao() {
|
|
782
|
+
return await this.atribuir();
|
|
739
783
|
}
|
|
740
|
-
declaracaoEscreva(simboloEscreva) {
|
|
784
|
+
async declaracaoEscreva(simboloEscreva) {
|
|
741
785
|
this.consumir(pitugues_2.default.PARENTESE_ESQUERDO, "Esperado '(' antes dos valores em escreva.");
|
|
742
786
|
const argumentos = [];
|
|
743
787
|
do {
|
|
744
|
-
argumentos.push(this.expressao());
|
|
788
|
+
argumentos.push(await this.expressao());
|
|
745
789
|
} while (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.VIRGULA));
|
|
746
790
|
this.consumir(pitugues_2.default.PARENTESE_DIREITO, "Esperado ')' após os valores em escreva.");
|
|
747
791
|
const declaracaoEscreva = new declaracoes_1.Escreva(Number(simboloEscreva.linha), simboloEscreva.hashArquivo, argumentos);
|
|
748
792
|
declaracaoEscreva.simboloEscreva = simboloEscreva;
|
|
749
793
|
return declaracaoEscreva;
|
|
750
794
|
}
|
|
751
|
-
declaracaoExpressao() {
|
|
752
|
-
const expressao = this.expressao();
|
|
795
|
+
async declaracaoExpressao() {
|
|
796
|
+
const expressao = await this.expressao();
|
|
753
797
|
return new declaracoes_1.Expressao(expressao);
|
|
754
798
|
}
|
|
755
|
-
blocoEscopo() {
|
|
799
|
+
async blocoEscopo() {
|
|
756
800
|
this.pilhaEscopos.empilhar(new informacao_escopo_1.InformacaoEscopo());
|
|
757
801
|
let declaracoes = [];
|
|
758
802
|
let simboloAtual = this.simboloAtual();
|
|
@@ -762,7 +806,13 @@ class AvaliadorSintaticoPitugues {
|
|
|
762
806
|
// Exemplo: `se verdadeiro: escreva('Alguma coisa')`.
|
|
763
807
|
// Neste caso, linha do símbolo atual é igual à linha do símbolo anterior.
|
|
764
808
|
if (simboloAtual.linha === simboloAnterior.linha) {
|
|
765
|
-
|
|
809
|
+
const declaracoesBloco = await this.resolverDeclaracaoForaDeBloco();
|
|
810
|
+
if (Array.isArray(declaracoesBloco)) {
|
|
811
|
+
declaracoes = declaracoes.concat(declaracoesBloco);
|
|
812
|
+
}
|
|
813
|
+
else {
|
|
814
|
+
declaracoes.push(declaracoesBloco);
|
|
815
|
+
}
|
|
766
816
|
}
|
|
767
817
|
else {
|
|
768
818
|
// Situação 2: símbolo atual fica na próxima linha.
|
|
@@ -784,7 +834,7 @@ class AvaliadorSintaticoPitugues {
|
|
|
784
834
|
// Significa que o código acabou, então o bloco também acabou.
|
|
785
835
|
const espacosIndentacaoBloco = espacosIndentacaoLinhaAtual;
|
|
786
836
|
while (espacosIndentacaoLinhaAtual === espacosIndentacaoBloco) {
|
|
787
|
-
const retornoDeclaracao = this.resolverDeclaracaoForaDeBloco();
|
|
837
|
+
const retornoDeclaracao = await this.resolverDeclaracaoForaDeBloco();
|
|
788
838
|
if (Array.isArray(retornoDeclaracao)) {
|
|
789
839
|
declaracoes = declaracoes.concat(retornoDeclaracao);
|
|
790
840
|
}
|
|
@@ -800,32 +850,32 @@ class AvaliadorSintaticoPitugues {
|
|
|
800
850
|
this.pilhaEscopos.removerUltimo();
|
|
801
851
|
return declaracoes;
|
|
802
852
|
}
|
|
803
|
-
declaracaoEnquanto() {
|
|
853
|
+
async declaracaoEnquanto() {
|
|
804
854
|
try {
|
|
805
855
|
this.blocos += 1;
|
|
806
|
-
const condicao = this.expressao();
|
|
807
|
-
const bloco = this.resolverDeclaracao();
|
|
856
|
+
const condicao = await this.expressao();
|
|
857
|
+
const bloco = await this.resolverDeclaracao();
|
|
808
858
|
return new declaracoes_1.Enquanto(condicao, bloco);
|
|
809
859
|
}
|
|
810
860
|
finally {
|
|
811
861
|
this.blocos -= 1;
|
|
812
862
|
}
|
|
813
863
|
}
|
|
814
|
-
declaracaoEscolha() {
|
|
864
|
+
async declaracaoEscolha() {
|
|
815
865
|
try {
|
|
816
866
|
this.blocos += 1;
|
|
817
|
-
const condicao = this.expressao();
|
|
867
|
+
const condicao = await this.expressao();
|
|
818
868
|
this.consumir(pitugues_2.default.DOIS_PONTOS, "Esperado ':' após 'escolha'.");
|
|
819
869
|
const caminhos = [];
|
|
820
870
|
let caminhoPadrao = null;
|
|
821
871
|
while (!this.estaNoFinal() &&
|
|
822
872
|
[pitugues_2.default.CASO, pitugues_2.default.PADRAO].includes(this.simbolos[this.atual].tipo)) {
|
|
823
873
|
if (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.CASO)) {
|
|
824
|
-
const caminhoCondicoes = [this.expressao()];
|
|
874
|
+
const caminhoCondicoes = [await this.expressao()];
|
|
825
875
|
this.consumir(pitugues_2.default.DOIS_PONTOS, "Esperado ':' após o 'caso'.");
|
|
826
876
|
while (this.verificarTipoSimboloAtual(pitugues_2.default.CASO)) {
|
|
827
877
|
this.consumir(pitugues_2.default.CASO, null);
|
|
828
|
-
caminhoCondicoes.push(this.expressao());
|
|
878
|
+
caminhoCondicoes.push(await this.expressao());
|
|
829
879
|
this.consumir(pitugues_2.default.DOIS_PONTOS, "Esperado ':' após declaração do 'caso'.");
|
|
830
880
|
}
|
|
831
881
|
// Como dois-pontos é um símbolo usado para conferir se há um início de bloco,
|
|
@@ -833,7 +883,7 @@ class AvaliadorSintaticoPitugues {
|
|
|
833
883
|
// foi consumido na verificação.
|
|
834
884
|
// Outro problema é que, aparentemente, o Interpretador não espera um Bloco, e sim
|
|
835
885
|
// um vetor de Declaracao, o qual obtemos com `this.blocoEscopo()`.
|
|
836
|
-
const declaracoes = this.blocoEscopo();
|
|
886
|
+
const declaracoes = await this.blocoEscopo();
|
|
837
887
|
caminhos.push({
|
|
838
888
|
condicoes: caminhoCondicoes,
|
|
839
889
|
declaracoes,
|
|
@@ -851,7 +901,7 @@ class AvaliadorSintaticoPitugues {
|
|
|
851
901
|
// foi consumido na verificação.
|
|
852
902
|
// Outro problema é que, aparentemente, o Interpretador não espera um Bloco, e sim
|
|
853
903
|
// um vetor de Declaracao, o qual obtemos com `this.blocoEscopo()`.
|
|
854
|
-
const declaracoes = this.blocoEscopo();
|
|
904
|
+
const declaracoes = await this.blocoEscopo();
|
|
855
905
|
caminhoPadrao = {
|
|
856
906
|
declaracoes,
|
|
857
907
|
};
|
|
@@ -863,7 +913,25 @@ class AvaliadorSintaticoPitugues {
|
|
|
863
913
|
this.blocos -= 1;
|
|
864
914
|
}
|
|
865
915
|
}
|
|
866
|
-
|
|
916
|
+
async declaracaoParaCada(simboloPara) {
|
|
917
|
+
const nomeVariavelIteracao = this.consumir(pitugues_2.default.IDENTIFICADOR, "Esperado identificador de variável de iteração para instrução 'para cada'.");
|
|
918
|
+
if (!this.verificarSeSimboloAtualEIgualA(pitugues_2.default.DE, pitugues_2.default.EM)) {
|
|
919
|
+
throw this.erro(this.simbolos[this.atual], "Esperado palavras reservadas 'em' ou 'de' após variável de iteração em instrução 'para cada'.");
|
|
920
|
+
}
|
|
921
|
+
const vetor = await this.expressao();
|
|
922
|
+
if (!vetor.hasOwnProperty('tipo')) {
|
|
923
|
+
throw this.erro(simboloPara, `Variável ou constante em 'para cada' não parece possuir um tipo iterável.`);
|
|
924
|
+
}
|
|
925
|
+
const tipoVetor = vetor.tipo;
|
|
926
|
+
if (!tipoVetor.endsWith('[]') && !['qualquer', 'vetor'].includes(tipoVetor)) {
|
|
927
|
+
throw this.erro(simboloPara, `Variável ou constante em 'para cada' não é iterável. Tipo resolvido: ${tipoVetor}.`);
|
|
928
|
+
}
|
|
929
|
+
this.pilhaEscopos.definirInformacoesVariavel(nomeVariavelIteracao.lexema, new informacao_elemento_sintatico_1.InformacaoElementoSintatico(nomeVariavelIteracao.lexema, tipoVetor.slice(0, -2)));
|
|
930
|
+
// TODO: Talvez não seja uma ideia melhor chamar o método de `Bloco` aqui?
|
|
931
|
+
const corpo = await this.resolverDeclaracao();
|
|
932
|
+
return new declaracoes_1.ParaCada(this.hashArquivo, Number(simboloPara.linha), new construtos_1.Variavel(this.hashArquivo, nomeVariavelIteracao), vetor, corpo);
|
|
933
|
+
}
|
|
934
|
+
async declaracaoPara() {
|
|
867
935
|
try {
|
|
868
936
|
const simboloPara = this.simboloAnterior();
|
|
869
937
|
this.blocos += 1;
|
|
@@ -872,7 +940,7 @@ class AvaliadorSintaticoPitugues {
|
|
|
872
940
|
if (!this.verificarSeSimboloAtualEIgualA(pitugues_2.default.DE, pitugues_2.default.EM)) {
|
|
873
941
|
throw this.erro(this.simbolos[this.atual], "Esperado palavras reservadas 'em' ou 'de' após variável de iteração em instrução 'para cada'.");
|
|
874
942
|
}
|
|
875
|
-
const vetor = this.expressao();
|
|
943
|
+
const vetor = await this.expressao();
|
|
876
944
|
if (!vetor.hasOwnProperty('tipo')) {
|
|
877
945
|
throw this.erro(simboloPara, `Variável ou constante em 'para cada' não parece possuir um tipo iterável.`);
|
|
878
946
|
}
|
|
@@ -882,7 +950,7 @@ class AvaliadorSintaticoPitugues {
|
|
|
882
950
|
}
|
|
883
951
|
this.pilhaEscopos.definirInformacoesVariavel(nomeVariavelIteracao.lexema, new informacao_elemento_sintatico_1.InformacaoElementoSintatico(nomeVariavelIteracao.lexema, tipoVetor.slice(0, -2)));
|
|
884
952
|
// TODO: Talvez não seja uma ideia melhor chamar o método de `Bloco` aqui?
|
|
885
|
-
const corpo = this.resolverDeclaracao();
|
|
953
|
+
const corpo = await this.resolverDeclaracao();
|
|
886
954
|
return new declaracoes_1.ParaCada(this.hashArquivo, Number(simboloPara.linha), new construtos_1.Variavel(this.hashArquivo, nomeVariavelIteracao), vetor, corpo);
|
|
887
955
|
}
|
|
888
956
|
catch (erro) {
|
|
@@ -892,12 +960,12 @@ class AvaliadorSintaticoPitugues {
|
|
|
892
960
|
this.blocos -= 1;
|
|
893
961
|
}
|
|
894
962
|
}
|
|
895
|
-
declaracaoSe() {
|
|
896
|
-
const condicao = this.expressao();
|
|
897
|
-
const caminhoEntao = this.resolverDeclaracao();
|
|
963
|
+
async declaracaoSe() {
|
|
964
|
+
const condicao = await this.expressao();
|
|
965
|
+
const caminhoEntao = await this.resolverDeclaracao();
|
|
898
966
|
let caminhoSenao = null;
|
|
899
967
|
if (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.SENAO, pitugues_2.default.SENÃO)) {
|
|
900
|
-
caminhoSenao = this.resolverDeclaracao();
|
|
968
|
+
caminhoSenao = await this.resolverDeclaracao();
|
|
901
969
|
}
|
|
902
970
|
return new declaracoes_1.Se(condicao, caminhoEntao, [], caminhoSenao);
|
|
903
971
|
}
|
|
@@ -917,25 +985,25 @@ class AvaliadorSintaticoPitugues {
|
|
|
917
985
|
}
|
|
918
986
|
return new declaracoes_1.Continua(this.simboloAtual());
|
|
919
987
|
}
|
|
920
|
-
declaracaoRetorna() {
|
|
988
|
+
async declaracaoRetorna() {
|
|
921
989
|
const palavraChave = this.simboloAnterior();
|
|
922
990
|
let valor = null;
|
|
923
991
|
if (!this.verificarTipoSimboloAtual(pitugues_2.default.PONTO_E_VIRGULA)) {
|
|
924
|
-
valor = this.expressao();
|
|
992
|
+
valor = await this.expressao();
|
|
925
993
|
}
|
|
926
994
|
return new declaracoes_1.Retorna(palavraChave, valor);
|
|
927
995
|
}
|
|
928
|
-
declaracaoImportar() {
|
|
996
|
+
async declaracaoImportar() {
|
|
929
997
|
this.avancarEDevolverAnterior();
|
|
930
998
|
this.consumir(pitugues_2.default.PARENTESE_ESQUERDO, "Esperado '(' após declaração.");
|
|
931
|
-
const caminho = this.expressao();
|
|
999
|
+
const caminho = await this.expressao();
|
|
932
1000
|
this.consumir(pitugues_2.default.PARENTESE_DIREITO, "Esperado ')' após declaração.");
|
|
933
1001
|
return new construtos_1.ImportarComoConstruto(caminho);
|
|
934
1002
|
}
|
|
935
|
-
declaracaoTente() {
|
|
1003
|
+
async declaracaoTente() {
|
|
936
1004
|
const simboloTente = this.simboloAnterior();
|
|
937
1005
|
this.consumir(pitugues_2.default.DOIS_PONTOS, "Esperado ':' após a declaração 'tente'.");
|
|
938
|
-
const blocoTente = this.blocoEscopo();
|
|
1006
|
+
const blocoTente = await this.blocoEscopo();
|
|
939
1007
|
let blocoPegue = null;
|
|
940
1008
|
if (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.PEGUE)) {
|
|
941
1009
|
if (this.verificarTipoSimboloAtual(pitugues_2.default.COMO)) {
|
|
@@ -945,7 +1013,7 @@ class AvaliadorSintaticoPitugues {
|
|
|
945
1013
|
// `pegue` recebe um `FuncaoConstruto`.
|
|
946
1014
|
this.consumir(pitugues_2.default.DOIS_PONTOS, `Esperado ':' antes do escopo do bloco 'pegue'.`);
|
|
947
1015
|
this.pilhaEscopos.definirInformacoesVariavel(variavelExcecao.lexema, new informacao_elemento_sintatico_1.InformacaoElementoSintatico(variavelExcecao.lexema, 'qualquer'));
|
|
948
|
-
const corpo = this.blocoEscopo();
|
|
1016
|
+
const corpo = await this.blocoEscopo();
|
|
949
1017
|
blocoPegue = new construtos_1.FuncaoConstruto(this.hashArquivo, simboloTente.linha, [{
|
|
950
1018
|
abrangencia: "padrao",
|
|
951
1019
|
nome: variavelExcecao,
|
|
@@ -956,49 +1024,49 @@ class AvaliadorSintaticoPitugues {
|
|
|
956
1024
|
// Caso 2: sem parâmetro de erro.
|
|
957
1025
|
// `pegue` recebe um bloco.
|
|
958
1026
|
this.consumir(pitugues_2.default.DOIS_PONTOS, "Esperado ':' após a declaração 'pegue'.");
|
|
959
|
-
blocoPegue = this.blocoEscopo();
|
|
1027
|
+
blocoPegue = await this.blocoEscopo();
|
|
960
1028
|
}
|
|
961
1029
|
}
|
|
962
1030
|
let blocoSenao = null;
|
|
963
1031
|
if (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.SENAO, pitugues_2.default.SENÃO)) {
|
|
964
1032
|
this.consumir(pitugues_2.default.DOIS_PONTOS, "Esperado ':' após a declaração 'senão'.");
|
|
965
|
-
blocoSenao = this.blocoEscopo();
|
|
1033
|
+
blocoSenao = await this.blocoEscopo();
|
|
966
1034
|
}
|
|
967
1035
|
let blocoFinalmente = null;
|
|
968
1036
|
if (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.FINALMENTE)) {
|
|
969
1037
|
this.consumir(pitugues_2.default.DOIS_PONTOS, "Esperado ':' após a declaração 'pegue'.");
|
|
970
|
-
blocoFinalmente = this.blocoEscopo();
|
|
1038
|
+
blocoFinalmente = await this.blocoEscopo();
|
|
971
1039
|
}
|
|
972
1040
|
return new declaracoes_1.Tente(simboloTente.hashArquivo, Number(simboloTente.linha), blocoTente, blocoPegue, blocoSenao, blocoFinalmente);
|
|
973
1041
|
}
|
|
974
|
-
declaracaoFazer() {
|
|
1042
|
+
async declaracaoFazer() {
|
|
975
1043
|
const simboloFazer = this.simboloAnterior();
|
|
976
1044
|
try {
|
|
977
1045
|
this.blocos += 1;
|
|
978
|
-
const declaracaoOuBlocoFazer = this.resolverDeclaracao();
|
|
1046
|
+
const declaracaoOuBlocoFazer = await this.resolverDeclaracao();
|
|
979
1047
|
this.consumir(pitugues_2.default.ENQUANTO, "Esperado declaração do 'enquanto' após o escopo da declaração 'fazer'.");
|
|
980
|
-
const condicaoEnquanto = this.expressao();
|
|
1048
|
+
const condicaoEnquanto = await this.expressao();
|
|
981
1049
|
return new declaracoes_1.Fazer(simboloFazer.hashArquivo, Number(simboloFazer.linha), declaracaoOuBlocoFazer, condicaoEnquanto);
|
|
982
1050
|
}
|
|
983
1051
|
finally {
|
|
984
1052
|
this.blocos -= 1;
|
|
985
1053
|
}
|
|
986
1054
|
}
|
|
987
|
-
funcao(tipo, construtor) {
|
|
1055
|
+
async funcao(tipo, construtor) {
|
|
988
1056
|
const simbolo = !construtor
|
|
989
1057
|
? this.consumir(pitugues_2.default.IDENTIFICADOR, `Esperado nome ${tipo}.`)
|
|
990
1058
|
: new lexador_1.Simbolo(pitugues_2.default.CONSTRUTOR, 'construtor', null, -1, -1);
|
|
991
1059
|
// Se houver chamadas recursivas à função, precisamos definir um tipo
|
|
992
1060
|
// para ela. Vai ser atualizado após avaliação do corpo da função.
|
|
993
1061
|
this.pilhaEscopos.definirInformacoesVariavel(simbolo.lexema, new informacao_elemento_sintatico_1.InformacaoElementoSintatico(simbolo.lexema, 'qualquer'));
|
|
994
|
-
const corpoDaFuncao = this.corpoDaFuncao(tipo);
|
|
1062
|
+
const corpoDaFuncao = await this.corpoDaFuncao(tipo);
|
|
995
1063
|
const tipoDaFuncao = `função<${corpoDaFuncao.tipo}>`;
|
|
996
1064
|
this.pilhaEscopos.definirInformacoesVariavel(simbolo.lexema, new informacao_elemento_sintatico_1.InformacaoElementoSintatico(simbolo.lexema, tipoDaFuncao));
|
|
997
1065
|
const funcaoDeclaracao = new declaracoes_1.FuncaoDeclaracao(simbolo, corpoDaFuncao, tipoDaFuncao);
|
|
998
1066
|
this.pilhaEscopos.registrarReferenciaFuncao(simbolo.lexema, funcaoDeclaracao);
|
|
999
1067
|
return funcaoDeclaracao;
|
|
1000
1068
|
}
|
|
1001
|
-
logicaComumParametros() {
|
|
1069
|
+
async logicaComumParametros() {
|
|
1002
1070
|
const parametros = [];
|
|
1003
1071
|
do {
|
|
1004
1072
|
if (parametros.length >= 255) {
|
|
@@ -1019,7 +1087,7 @@ class AvaliadorSintaticoPitugues {
|
|
|
1019
1087
|
this.avancarEDevolverAnterior();
|
|
1020
1088
|
}
|
|
1021
1089
|
if (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.IGUAL)) {
|
|
1022
|
-
parametro.valorPadrao = this.primario();
|
|
1090
|
+
parametro.valorPadrao = await this.primario();
|
|
1023
1091
|
}
|
|
1024
1092
|
this.pilhaEscopos.definirInformacoesVariavel(parametro.nome.lexema, new informacao_elemento_sintatico_1.InformacaoElementoSintatico(parametro.nome.lexema, parametro.tipoDado || 'qualquer'));
|
|
1025
1093
|
parametros.push(parametro);
|
|
@@ -1032,7 +1100,7 @@ class AvaliadorSintaticoPitugues {
|
|
|
1032
1100
|
* Resolve uma lista de compreensão.
|
|
1033
1101
|
* @returns {ListaCompreensao} A lista de compreensão resolvida.
|
|
1034
1102
|
*/
|
|
1035
|
-
resolverCompreensaoDeLista() {
|
|
1103
|
+
async resolverCompreensaoDeLista() {
|
|
1036
1104
|
// TODO: Se expressão não começar com um identificador, por exemplo `3 * x`, como faríamos para
|
|
1037
1105
|
// aceitar o `x` na avaliação da expressão?
|
|
1038
1106
|
if (this.simbolos[this.atual].tipo === pitugues_2.default.IDENTIFICADOR) {
|
|
@@ -1042,7 +1110,7 @@ class AvaliadorSintaticoPitugues {
|
|
|
1042
1110
|
);
|
|
1043
1111
|
}
|
|
1044
1112
|
// TODO: Reavaliar a precedência do se ternário.
|
|
1045
|
-
const retornoExpressao = this.ou();
|
|
1113
|
+
const retornoExpressao = await this.ou();
|
|
1046
1114
|
this.consumir(pitugues_2.default.PARA, "Esperado instrução 'para' após identificado.");
|
|
1047
1115
|
this.consumir(pitugues_2.default.CADA, "Esperado instrução 'cada' após 'para'.");
|
|
1048
1116
|
const simboloVariavelIteracao = this.consumir(pitugues_2.default.IDENTIFICADOR, "Esperado identificador de variável após 'para cada'.");
|
|
@@ -1058,9 +1126,9 @@ class AvaliadorSintaticoPitugues {
|
|
|
1058
1126
|
}
|
|
1059
1127
|
const localizacaoVetor = this.simboloAnterior();
|
|
1060
1128
|
// TODO: Reavaliar a precedência do se ternário.
|
|
1061
|
-
const vetor = this.ou();
|
|
1129
|
+
const vetor = await this.ou();
|
|
1062
1130
|
this.consumir(pitugues_2.default.SE, "Esperado condição 'se' após vetor.");
|
|
1063
|
-
const condicao = this.expressao();
|
|
1131
|
+
const condicao = await this.expressao();
|
|
1064
1132
|
this.consumir(pitugues_2.default.COLCHETE_DIREITO, 'Espero fechamento de colchetes após condição.');
|
|
1065
1133
|
const tipoVetor = vetor.tipo;
|
|
1066
1134
|
if (!tipoVetor.endsWith('[]') && !['qualquer', 'vetor'].includes(tipoVetor)) {
|
|
@@ -1109,13 +1177,13 @@ class AvaliadorSintaticoPitugues {
|
|
|
1109
1177
|
return new declaracoes_1.TextoDocumentacao(this.hashArquivo, Number(simboloTexto.linha), simboloTexto.lexema);
|
|
1110
1178
|
}
|
|
1111
1179
|
}
|
|
1112
|
-
corpoDaFuncao(tipo) {
|
|
1180
|
+
async corpoDaFuncao(tipo) {
|
|
1113
1181
|
// O parêntese esquerdo é considerado o símbolo inicial para
|
|
1114
1182
|
// fins de localização.
|
|
1115
1183
|
const parenteseEsquerdo = this.consumir(pitugues_2.default.PARENTESE_ESQUERDO, `Esperado '(' após o nome ${tipo}.`);
|
|
1116
1184
|
let parametros = [];
|
|
1117
1185
|
if (!this.verificarTipoSimboloAtual(pitugues_2.default.PARENTESE_DIREITO)) {
|
|
1118
|
-
parametros = this.logicaComumParametros();
|
|
1186
|
+
parametros = await this.logicaComumParametros();
|
|
1119
1187
|
}
|
|
1120
1188
|
this.consumir(pitugues_2.default.PARENTESE_DIREITO, "Esperado ')' após parâmetros.");
|
|
1121
1189
|
let tipoRetorno = 'qualquer';
|
|
@@ -1127,11 +1195,11 @@ class AvaliadorSintaticoPitugues {
|
|
|
1127
1195
|
}
|
|
1128
1196
|
this.consumir(pitugues_2.default.DOIS_PONTOS, `Esperado ':' antes do escopo do ${tipo}.`);
|
|
1129
1197
|
const documentacao = this.declaracaoTextoDeDocumentacao();
|
|
1130
|
-
const corpo = this.blocoEscopo();
|
|
1198
|
+
const corpo = await this.blocoEscopo();
|
|
1131
1199
|
tipoRetorno = (0, comum_1.logicaDescobertaRetornoFuncao)(this, corpo, tipoRetorno, definicaoExplicitaDeTipo, parenteseEsquerdo);
|
|
1132
1200
|
return new construtos_1.FuncaoConstruto(this.hashArquivo, 0, parametros, corpo, tipoRetorno, definicaoExplicitaDeTipo, documentacao);
|
|
1133
1201
|
}
|
|
1134
|
-
declaracaoDeClasse() {
|
|
1202
|
+
async declaracaoDeClasse() {
|
|
1135
1203
|
const simbolo = this.consumir(pitugues_2.default.IDENTIFICADOR, 'Esperado nome da classe.');
|
|
1136
1204
|
let superClasse = null;
|
|
1137
1205
|
if (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.PARENTESE_ESQUERDO)) {
|
|
@@ -1156,7 +1224,7 @@ class AvaliadorSintaticoPitugues {
|
|
|
1156
1224
|
propriedades.push(propriedade);
|
|
1157
1225
|
}
|
|
1158
1226
|
else {
|
|
1159
|
-
metodos.push(this.funcao('método', this.simbolos[this.atual - 1].tipo === pitugues_2.default.CONSTRUTOR));
|
|
1227
|
+
metodos.push(await this.funcao('método', this.simbolos[this.atual - 1].tipo === pitugues_2.default.CONSTRUTOR));
|
|
1160
1228
|
}
|
|
1161
1229
|
}
|
|
1162
1230
|
this.superclasseAtual = undefined;
|
|
@@ -1205,24 +1273,24 @@ class AvaliadorSintaticoPitugues {
|
|
|
1205
1273
|
* ou uma expressão.
|
|
1206
1274
|
* @returns Objeto do tipo `Declaracao`.
|
|
1207
1275
|
*/
|
|
1208
|
-
resolverDeclaracaoForaDeBloco() {
|
|
1276
|
+
async resolverDeclaracaoForaDeBloco() {
|
|
1209
1277
|
try {
|
|
1210
1278
|
if ((this.verificarTipoSimboloAtual(pitugues_2.default.FUNCAO) ||
|
|
1211
1279
|
this.verificarTipoSimboloAtual(pitugues_2.default.FUNÇÃO)) &&
|
|
1212
1280
|
this.verificarTipoProximoSimbolo(pitugues_2.default.IDENTIFICADOR)) {
|
|
1213
1281
|
this.avancarEDevolverAnterior();
|
|
1214
|
-
return this.funcao('funcao');
|
|
1282
|
+
return await this.funcao('funcao');
|
|
1215
1283
|
}
|
|
1216
1284
|
if (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.CLASSE))
|
|
1217
|
-
return this.declaracaoDeClasse();
|
|
1218
|
-
return this.resolverDeclaracao();
|
|
1285
|
+
return await this.declaracaoDeClasse();
|
|
1286
|
+
return await this.resolverDeclaracao();
|
|
1219
1287
|
}
|
|
1220
1288
|
catch (erro) {
|
|
1221
1289
|
this.sincronizar();
|
|
1222
1290
|
return null;
|
|
1223
1291
|
}
|
|
1224
1292
|
}
|
|
1225
|
-
resolverDeclaracao() {
|
|
1293
|
+
async resolverDeclaracao() {
|
|
1226
1294
|
// Detecção de declaração implícita ou múltipla atribuição (pode começar com * ou identificador)
|
|
1227
1295
|
const simboloAtual = this.simbolos[this.atual];
|
|
1228
1296
|
// Bloqueio explícito do uso de "var"
|
|
@@ -1254,7 +1322,7 @@ class AvaliadorSintaticoPitugues {
|
|
|
1254
1322
|
case pitugues_2.default.DOIS_PONTOS:
|
|
1255
1323
|
this.avancarEDevolverAnterior();
|
|
1256
1324
|
const simboloInicioBloco = this.simboloAnterior();
|
|
1257
|
-
return new declaracoes_1.Bloco(simboloInicioBloco.hashArquivo, Number(simboloInicioBloco.linha), this.blocoEscopo());
|
|
1325
|
+
return new declaracoes_1.Bloco(simboloInicioBloco.hashArquivo, Number(simboloInicioBloco.linha), await this.blocoEscopo());
|
|
1258
1326
|
case pitugues_2.default.ENQUANTO:
|
|
1259
1327
|
this.avancarEDevolverAnterior();
|
|
1260
1328
|
return this.declaracaoEnquanto();
|
|
@@ -1283,7 +1351,7 @@ class AvaliadorSintaticoPitugues {
|
|
|
1283
1351
|
return this.declaracaoSe();
|
|
1284
1352
|
case pitugues_2.default.RETORNA:
|
|
1285
1353
|
this.avancarEDevolverAnterior();
|
|
1286
|
-
return this.declaracaoRetorna();
|
|
1354
|
+
return await this.declaracaoRetorna();
|
|
1287
1355
|
case pitugues_2.default.TENTE:
|
|
1288
1356
|
this.avancarEDevolverAnterior();
|
|
1289
1357
|
return this.declaracaoTente();
|
|
@@ -1385,7 +1453,7 @@ class AvaliadorSintaticoPitugues {
|
|
|
1385
1453
|
new informacao_elemento_sintatico_1.InformacaoElementoSintatico('vetor', 'qualquer[]'),
|
|
1386
1454
|
]));
|
|
1387
1455
|
}
|
|
1388
|
-
analisar(retornoLexador, hashArquivo) {
|
|
1456
|
+
async analisar(retornoLexador, hashArquivo) {
|
|
1389
1457
|
const inicioAnalise = (0, browser_process_hrtime_1.default)();
|
|
1390
1458
|
this.erros = [];
|
|
1391
1459
|
this.atual = 0;
|
|
@@ -1399,7 +1467,7 @@ class AvaliadorSintaticoPitugues {
|
|
|
1399
1467
|
this.verificarPontosEVirgulasInvalidos();
|
|
1400
1468
|
let declaracoes = [];
|
|
1401
1469
|
while (!this.estaNoFinal()) {
|
|
1402
|
-
const retornoDeclaracao = this.resolverDeclaracaoForaDeBloco();
|
|
1470
|
+
const retornoDeclaracao = await this.resolverDeclaracaoForaDeBloco();
|
|
1403
1471
|
if (retornoDeclaracao === null) {
|
|
1404
1472
|
continue;
|
|
1405
1473
|
}
|