@designliquido/delegua 0.13.2 → 0.14.1
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/README.md +3 -54
- package/bin/package.json +2 -12
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-guarani.d.ts +20 -0
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-guarani.js +150 -0
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-guarani.js.map +1 -0
- package/fontes/avaliador-sintatico/dialetos/index.d.ts +4 -0
- package/fontes/avaliador-sintatico/dialetos/index.js +4 -0
- package/fontes/avaliador-sintatico/dialetos/index.js.map +1 -1
- package/fontes/depuracao/index.d.ts +0 -1
- package/fontes/depuracao/index.js +0 -1
- package/fontes/depuracao/index.js.map +1 -1
- package/fontes/interfaces/index.d.ts +0 -2
- package/fontes/interfaces/index.js +0 -2
- package/fontes/interfaces/index.js.map +1 -1
- package/fontes/interpretador/dialetos/egua-classico/interpretador-egua-classico.d.ts +2 -4
- package/fontes/interpretador/dialetos/egua-classico/interpretador-egua-classico.js +34 -43
- package/fontes/interpretador/dialetos/egua-classico/interpretador-egua-classico.js.map +1 -1
- package/fontes/interpretador/dialetos/visualg/interpretador-visualg-com-depuracao.d.ts +1 -2
- package/fontes/interpretador/dialetos/visualg/interpretador-visualg-com-depuracao.js +2 -2
- package/fontes/interpretador/dialetos/visualg/interpretador-visualg-com-depuracao.js.map +1 -1
- package/fontes/interpretador/dialetos/visualg/interpretador-visualg.d.ts +3 -4
- package/fontes/interpretador/dialetos/visualg/interpretador-visualg.js +3 -3
- package/fontes/interpretador/dialetos/visualg/interpretador-visualg.js.map +1 -1
- package/fontes/interpretador/index.d.ts +0 -1
- package/fontes/interpretador/index.js +0 -1
- package/fontes/interpretador/index.js.map +1 -1
- package/fontes/interpretador/interpretador-base.d.ts +2 -4
- package/fontes/interpretador/interpretador-base.js +1 -2
- package/fontes/interpretador/interpretador-base.js.map +1 -1
- package/fontes/interpretador/interpretador-com-depuracao.d.ts +4 -4
- package/fontes/interpretador/interpretador-com-depuracao.js +4 -4
- package/fontes/interpretador/interpretador-com-depuracao.js.map +1 -1
- package/fontes/lexador/dialetos/index.d.ts +5 -0
- package/fontes/lexador/dialetos/index.js +5 -0
- package/fontes/lexador/dialetos/index.js.map +1 -1
- package/fontes/lexador/dialetos/lexador-guarani.d.ts +9 -0
- package/fontes/lexador/dialetos/lexador-guarani.js +114 -0
- package/fontes/lexador/dialetos/lexador-guarani.js.map +1 -0
- package/fontes/lexador/dialetos/palavras-reservadas/guarani.d.ts +4 -0
- package/fontes/lexador/dialetos/palavras-reservadas/guarani.js +10 -0
- package/fontes/lexador/dialetos/palavras-reservadas/guarani.js.map +1 -0
- package/fontes/lexador/dialetos/palavras-reservadas/rantiaquin.d.ts +2 -0
- package/fontes/{importador/retorno-importador.js → lexador/dialetos/palavras-reservadas/rantiaquin.js} +2 -1
- package/fontes/lexador/dialetos/palavras-reservadas/rantiaquin.js.map +1 -0
- package/fontes/tipos-de-simbolos/guarani.d.ts +14 -0
- package/fontes/tipos-de-simbolos/guarani.js +16 -0
- package/fontes/tipos-de-simbolos/guarani.js.map +1 -0
- package/fontes/tipos-de-simbolos/rantiaquin.d.ts +2 -0
- package/fontes/{interfaces/delegua-interface.js → tipos-de-simbolos/rantiaquin.js} +2 -1
- package/fontes/tipos-de-simbolos/rantiaquin.js.map +1 -0
- package/index.d.ts +0 -2
- package/index.js +0 -2
- package/index.js.map +1 -1
- package/package.json +2 -12
- package/execucao.d.ts +0 -1
- package/execucao.js +0 -43
- package/execucao.js.map +0 -1
- package/fontes/bibliotecas/importar-biblioteca.d.ts +0 -2
- package/fontes/bibliotecas/importar-biblioteca.js +0 -132
- package/fontes/bibliotecas/importar-biblioteca.js.map +0 -1
- package/fontes/delegua.d.ts +0 -86
- package/fontes/delegua.js +0 -372
- package/fontes/delegua.js.map +0 -1
- package/fontes/depuracao/remota/servidor-depuracao.d.ts +0 -41
- package/fontes/depuracao/remota/servidor-depuracao.js +0 -301
- package/fontes/depuracao/remota/servidor-depuracao.js.map +0 -1
- package/fontes/importador/importador.d.ts +0 -27
- package/fontes/importador/importador.js +0 -91
- package/fontes/importador/importador.js.map +0 -1
- package/fontes/importador/index.d.ts +0 -2
- package/fontes/importador/index.js +0 -19
- package/fontes/importador/index.js.map +0 -1
- package/fontes/importador/retorno-importador.d.ts +0 -9
- package/fontes/importador/retorno-importador.js.map +0 -1
- package/fontes/interfaces/delegua-interface.d.ts +0 -23
- package/fontes/interfaces/delegua-interface.js.map +0 -1
- package/fontes/interfaces/importador-interface.d.ts +0 -8
- package/fontes/interfaces/importador-interface.js +0 -3
- package/fontes/interfaces/importador-interface.js.map +0 -1
- package/fontes/interpretador/interpretador.d.ts +0 -17
- package/fontes/interpretador/interpretador.js +0 -80
- package/fontes/interpretador/interpretador.js.map +0 -1
package/README.md
CHANGED
|
@@ -55,6 +55,7 @@ Delégua tem retrocompatibilidade com a linguagem Égua e compreende sua extens
|
|
|
55
55
|
- **Linguagem Científica.** Apoiamos e encorajamos o desenvolvimento e aprimoramento da ciência e da educação.
|
|
56
56
|
- **Multidialetos.** Execute algoritmos em [Portugol VisuAlg](http://visualg3.com.br) e [Portugol Studio](http://lite.acad.univali.br/portugol/).
|
|
57
57
|
- **Depurável.** Usando um editor com suporte à depuração como o [Visual Studio Code](https://code.visualstudio.com), você pode inspecionar o seu programa, suas variáveis e executar linha por linha
|
|
58
|
+
- **Portável.** Escreva sua aplicação e coloque Delégua dentro dela. Funciona em qualquer sistema operacional e qualquer navegador de internet.
|
|
58
59
|
|
|
59
60
|
## Aplicações
|
|
60
61
|
|
|
@@ -62,64 +63,12 @@ Delégua tem retrocompatibilidade com a linguagem Égua e compreende sua extens
|
|
|
62
63
|
|
|
63
64
|
## Instalação
|
|
64
65
|
|
|
65
|
-
Delégua executa em qualquer dispositivo que interprete JavaScript, ou seja, computadores, celulares e tablets. Você não precisa instalar nada se não quiser
|
|
66
|
+
Delégua executa em qualquer dispositivo que interprete JavaScript, ou seja, computadores, celulares e tablets. Você não precisa instalar nada se não quiser. Utilize uma das seguintes opções:
|
|
66
67
|
|
|
67
68
|
- [Dentro do Visual Studio Code, instale a extensão da Design Líquido](https://marketplace.visualstudio.com/items?itemName=designliquido.designliquido-vscode). [Aprenda como executar e depurar seu programa aqui](https://www.youtube.com/watch?v=TQxLekzvBv8);
|
|
68
69
|
- [Utilize nosso editor online](https://designliquido.github.io/delegua-web/).
|
|
69
70
|
|
|
70
|
-
|
|
71
|
-
[você deve ter antes o Node.js instalado em seu ambiente](https://dicasdejavascript.com.br/instalacao-do-nodejs-e-npm-no-windows-passo-a-passo).
|
|
72
|
-
|
|
73
|
-
Com o Node.js instalado, execute o seguinte comando em um _prompt_ de comando (Terminal, PowerShell ou `cmd` no Windows, Terminal ou `sh` em Mac e Linux):
|
|
74
|
-
|
|
75
|
-
```
|
|
76
|
-
npm install -g delegua
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
### Usando como LAIR (Leia-Avalie-Imprima-Repita) em console
|
|
80
|
-
|
|
81
|
-
Feita a instalação no seu ambiente, execute o seguinte comando:
|
|
82
|
-
|
|
83
|
-
```
|
|
84
|
-
delegua
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
Você terá um interpretador Delégua que avalia expressões linha a linha.
|
|
88
|
-
|
|
89
|
-
Um exemplo de uso é como uma calculadora:
|
|
90
|
-
|
|
91
|
-
```js
|
|
92
|
-
delegua> 2 + 2
|
|
93
|
-
4
|
|
94
|
-
|
|
95
|
-
delegua> 2 * 3
|
|
96
|
-
6
|
|
97
|
-
|
|
98
|
-
delegua> 2 ** 10
|
|
99
|
-
1024
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
Para finalizar a execução do interpretador LAIR Delégua, use o atalho <key>Ctrl</key> + <key>C</key> (todos os sistemas operacionais).
|
|
103
|
-
|
|
104
|
-
### Executando arquivos
|
|
105
|
-
|
|
106
|
-
É possível usar o interpretador com outros dialetos, como Égua.
|
|
107
|
-
|
|
108
|
-
```
|
|
109
|
-
delegua --dialeto egua
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
[Veja aqui todos os dialetos suportados](https://github.com/DesignLiquido/delegua/wiki/Dialetos).
|
|
113
|
-
|
|
114
|
-
Se não quiser instalar as bibliotecas que acompanham Delégua, apenas o núcleo da linguagem pode ser instalado:
|
|
115
|
-
|
|
116
|
-
```
|
|
117
|
-
npm install -g @designliquido/delegua
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
## Tradução para outras linguagens
|
|
121
|
-
|
|
122
|
-
Delégua traduz para JavaScript e vice-versa. [Mais informações aqui](https://github.com/DesignLiquido/delegua/wiki/Tradu%C3%A7%C3%A3o-para-outras-linguagens).
|
|
71
|
+
Para instalar no seu computador, veja o projeto [`@designliquido/delegua-node`](https://github.com/DesignLiquido/delegua-node).
|
|
123
72
|
|
|
124
73
|
## Documentação
|
|
125
74
|
|
package/bin/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@designliquido/delegua",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "Linguagem de programação simples e moderna usando português estruturado, com suporte a múltiplos dialetos",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -9,11 +9,6 @@
|
|
|
9
9
|
"lair": "ts-node execucao.ts",
|
|
10
10
|
"publicar-docs": "yarn gerar-documentacao-tecnica && copyfiles -V ./recursos/**/* ./docs && gh-pages -d docs",
|
|
11
11
|
"publicar-npm": "npm publish ./dist --access public",
|
|
12
|
-
"testes:egua": "./bin/delegua-ts exemplos/dialetos/egua-classico/testes.egua",
|
|
13
|
-
"testes:delegua:bhaskara": "./bin/delegua-ts exemplos/dialetos/egua-classico/bhaskara.egua",
|
|
14
|
-
"testes:delegua:fibonacci": "./bin/delegua-ts exemplos/dialetos/egua-classico/fibonacci.egua",
|
|
15
|
-
"testes:egua-classico": "./bin/delegua-ts --dialeto egua exemplos/dialetos/egua-classico/testes.egua",
|
|
16
|
-
"testes:servidor-depuracao": "ts-node ./fontes/depuracao/servidor-depuracao.ts",
|
|
17
12
|
"testes-unitarios": "jest --coverage",
|
|
18
13
|
"testes-unitarios:insignias": "jest-coverage-badges --output './recursos/imagens'",
|
|
19
14
|
"observar-testes-unitarios": "jest --watchAll",
|
|
@@ -25,9 +20,6 @@
|
|
|
25
20
|
"type": "git",
|
|
26
21
|
"url": "git+https://github.com/DesignLiquido/delegua.git"
|
|
27
22
|
},
|
|
28
|
-
"bin": {
|
|
29
|
-
"delegua": "./bin/delegua"
|
|
30
|
-
},
|
|
31
23
|
"keywords": [
|
|
32
24
|
"egua",
|
|
33
25
|
"eguap",
|
|
@@ -67,8 +59,8 @@
|
|
|
67
59
|
"@designliquido/delegua-matematica": "^0.2.0",
|
|
68
60
|
"@designliquido/delegua-tempo": "^0.0.1",
|
|
69
61
|
"@types/esprima": "^4.0.3",
|
|
62
|
+
"@types/estree": "^1.0.0",
|
|
70
63
|
"@types/jest": "^29.4.0",
|
|
71
|
-
"@types/node": "^18.11.13",
|
|
72
64
|
"@typescript-eslint/eslint-plugin": "^5.46.1",
|
|
73
65
|
"@typescript-eslint/parser": "^5.46.1",
|
|
74
66
|
"copyfiles": "^2.4.1",
|
|
@@ -88,8 +80,6 @@
|
|
|
88
80
|
},
|
|
89
81
|
"dependencies": {
|
|
90
82
|
"browser-process-hrtime": "^1.0.0",
|
|
91
|
-
"chalk": "4.1.2",
|
|
92
|
-
"commander": "^9.4.1",
|
|
93
83
|
"esprima": "^4.0.1"
|
|
94
84
|
}
|
|
95
85
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Construto, FuncaoConstruto } from "../../construtos";
|
|
2
|
+
import { Escreva, Declaracao, Se, Enquanto, Para, Escolha, Fazer } from "../../declaracoes";
|
|
3
|
+
import { RetornoLexador, RetornoAvaliadorSintatico } from "../../interfaces/retornos";
|
|
4
|
+
import { AvaliadorSintaticoBase } from "../avaliador-sintatico-base";
|
|
5
|
+
export declare class AvaliadorSintaticoGuarani extends AvaliadorSintaticoBase {
|
|
6
|
+
primario(): Construto;
|
|
7
|
+
chamar(): Construto;
|
|
8
|
+
atribuir(): Construto;
|
|
9
|
+
declaracaoEscreva(): Escreva;
|
|
10
|
+
blocoEscopo(): Declaracao[];
|
|
11
|
+
declaracaoSe(): Se;
|
|
12
|
+
declaracaoEnquanto(): Enquanto;
|
|
13
|
+
declaracaoPara(): Para;
|
|
14
|
+
declaracaoEscolha(): Escolha;
|
|
15
|
+
declaracaoFazer(): Fazer;
|
|
16
|
+
corpoDaFuncao(tipo: string): FuncaoConstruto;
|
|
17
|
+
expressao(): Construto;
|
|
18
|
+
declaracao(): Declaracao | Declaracao[] | Construto | Construto[] | any;
|
|
19
|
+
analisar(retornoLexador: RetornoLexador, hashArquivo?: number): RetornoAvaliadorSintatico;
|
|
20
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AvaliadorSintaticoGuarani = void 0;
|
|
7
|
+
const construtos_1 = require("../../construtos");
|
|
8
|
+
const declaracoes_1 = require("../../declaracoes");
|
|
9
|
+
const avaliador_sintatico_base_1 = require("../avaliador-sintatico-base");
|
|
10
|
+
const guarani_1 = __importDefault(require("../../tipos-de-simbolos/guarani"));
|
|
11
|
+
class AvaliadorSintaticoGuarani extends avaliador_sintatico_base_1.AvaliadorSintaticoBase {
|
|
12
|
+
primario() {
|
|
13
|
+
const simboloAtual = this.simbolos[this.atual];
|
|
14
|
+
if (this.verificarSeSimboloAtualEIgualA(guarani_1.default.NUMERO, guarani_1.default.TEXTO)) {
|
|
15
|
+
const simboloAnterior = this.simbolos[this.atual - 1];
|
|
16
|
+
return new construtos_1.Literal(this.hashArquivo, Number(simboloAnterior.linha), simboloAnterior.literal);
|
|
17
|
+
}
|
|
18
|
+
throw this.erro(this.simbolos[this.atual], 'Esperado expressão.');
|
|
19
|
+
}
|
|
20
|
+
chamar() {
|
|
21
|
+
let expressao = this.primario();
|
|
22
|
+
/* while (true) {
|
|
23
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos.PARENTESE_ESQUERDO)) {
|
|
24
|
+
expressao = this.finalizarChamada(expressao);
|
|
25
|
+
} else if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos.PONTO)) {
|
|
26
|
+
const nome = this.consumir(tiposDeSimbolos.IDENTIFICADOR, "Esperado nome do método após '.'.");
|
|
27
|
+
expressao = new AcessoMetodo(this.hashArquivo, expressao, nome);
|
|
28
|
+
} else if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos.COLCHETE_ESQUERDO)) {
|
|
29
|
+
const indice = this.expressao();
|
|
30
|
+
const simboloFechamento = this.consumir(
|
|
31
|
+
tiposDeSimbolos.COLCHETE_DIREITO,
|
|
32
|
+
"Esperado ']' após escrita do indice."
|
|
33
|
+
);
|
|
34
|
+
expressao = new AcessoIndiceVariavel(this.hashArquivo, expressao, indice, simboloFechamento);
|
|
35
|
+
} else {
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
} */
|
|
39
|
+
return expressao;
|
|
40
|
+
}
|
|
41
|
+
atribuir() {
|
|
42
|
+
const expressao = this.ou();
|
|
43
|
+
/* if (
|
|
44
|
+
expressao instanceof Binario &&
|
|
45
|
+
[
|
|
46
|
+
tiposDeSimbolos.MAIS_IGUAL,
|
|
47
|
+
tiposDeSimbolos.MENOS_IGUAL,
|
|
48
|
+
tiposDeSimbolos.MULTIPLICACAO_IGUAL,
|
|
49
|
+
tiposDeSimbolos.DIVISAO_IGUAL,
|
|
50
|
+
tiposDeSimbolos.DIVISAO_INTEIRA_IGUAL,
|
|
51
|
+
tiposDeSimbolos.MODULO_IGUAL,
|
|
52
|
+
].includes(expressao.operador.tipo)
|
|
53
|
+
) {
|
|
54
|
+
return new Atribuir(this.hashArquivo, (expressao.esquerda as Variavel).simbolo, expressao);
|
|
55
|
+
} else if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos.IGUAL)) {
|
|
56
|
+
const igual = this.simbolos[this.atual - 1];
|
|
57
|
+
const valor = this.atribuir();
|
|
58
|
+
|
|
59
|
+
if (expressao instanceof Variavel) {
|
|
60
|
+
const simbolo = expressao.simbolo;
|
|
61
|
+
return new Atribuir(this.hashArquivo, simbolo, valor);
|
|
62
|
+
} else if (expressao instanceof AcessoMetodo) {
|
|
63
|
+
const get = expressao;
|
|
64
|
+
// return new Conjunto(this.hashArquivo, 0, get.objeto, get.simbolo, valor);
|
|
65
|
+
return new DefinirValor(this.hashArquivo, 0, get.objeto, get.simbolo, valor);
|
|
66
|
+
} else if (expressao instanceof AcessoIndiceVariavel) {
|
|
67
|
+
return new AtribuicaoSobrescrita(
|
|
68
|
+
this.hashArquivo,
|
|
69
|
+
0,
|
|
70
|
+
expressao.entidadeChamada,
|
|
71
|
+
expressao.indice,
|
|
72
|
+
valor
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
this.erro(igual, 'Tarefa de atribuição inválida');
|
|
76
|
+
} */
|
|
77
|
+
return expressao;
|
|
78
|
+
}
|
|
79
|
+
declaracaoEscreva() {
|
|
80
|
+
const simboloAtual = this.consumir(guarani_1.default.HAI, '');
|
|
81
|
+
this.consumir(guarani_1.default.PARENTESE_ESQUERDO, "Oñeha'arõ '(' valores mboyve jehaipyrépe.");
|
|
82
|
+
const argumentos = [];
|
|
83
|
+
do {
|
|
84
|
+
argumentos.push(this.expressao());
|
|
85
|
+
} while (this.verificarSeSimboloAtualEIgualA(guarani_1.default.VIRGULA));
|
|
86
|
+
this.consumir(guarani_1.default.PARENTESE_DIREITO, "Oñeha'arõ ')' valores rire jehaipyrépe.");
|
|
87
|
+
return new declaracoes_1.Escreva(Number(simboloAtual.linha), simboloAtual.hashArquivo, argumentos);
|
|
88
|
+
}
|
|
89
|
+
blocoEscopo() {
|
|
90
|
+
throw new Error("Método não implementado.");
|
|
91
|
+
}
|
|
92
|
+
declaracaoSe() {
|
|
93
|
+
throw new Error("Método não implementado.");
|
|
94
|
+
}
|
|
95
|
+
declaracaoEnquanto() {
|
|
96
|
+
throw new Error("Método não implementado.");
|
|
97
|
+
}
|
|
98
|
+
declaracaoPara() {
|
|
99
|
+
throw new Error("Método não implementado.");
|
|
100
|
+
}
|
|
101
|
+
declaracaoEscolha() {
|
|
102
|
+
throw new Error("Método não implementado.");
|
|
103
|
+
}
|
|
104
|
+
declaracaoFazer() {
|
|
105
|
+
throw new Error("Método não implementado.");
|
|
106
|
+
}
|
|
107
|
+
corpoDaFuncao(tipo) {
|
|
108
|
+
// O parêntese esquerdo é considerado o símbolo inicial para
|
|
109
|
+
// fins de pragma.
|
|
110
|
+
const parenteseEsquerdo = this.consumir(guarani_1.default.PARENTESE_ESQUERDO, `Esperado '(' após o nome ${tipo}.`);
|
|
111
|
+
let parametros = [];
|
|
112
|
+
if (!this.verificarTipoSimboloAtual(guarani_1.default.PARENTESE_DIREITO)) {
|
|
113
|
+
parametros = this.logicaComumParametros();
|
|
114
|
+
}
|
|
115
|
+
this.consumir(guarani_1.default.PARENTESE_DIREITO, "Esperado ')' após parâmetros.");
|
|
116
|
+
this.consumir(guarani_1.default.CHAVE_ESQUERDA, `Esperado '{' antes do escopo do ${tipo}.`);
|
|
117
|
+
const corpo = this.blocoEscopo();
|
|
118
|
+
return new construtos_1.FuncaoConstruto(this.hashArquivo, Number(parenteseEsquerdo.linha), parametros, corpo);
|
|
119
|
+
}
|
|
120
|
+
expressao() {
|
|
121
|
+
// if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos.LEIA)) return this.declaracaoLeia();
|
|
122
|
+
return this.atribuir();
|
|
123
|
+
}
|
|
124
|
+
declaracao() {
|
|
125
|
+
const simboloAtual = this.simbolos[this.atual];
|
|
126
|
+
switch (simboloAtual.tipo) {
|
|
127
|
+
case guarani_1.default.HAI:
|
|
128
|
+
return this.declaracaoEscreva();
|
|
129
|
+
default:
|
|
130
|
+
return this.expressao();
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
analisar(retornoLexador, hashArquivo) {
|
|
134
|
+
this.erros = [];
|
|
135
|
+
this.atual = 0;
|
|
136
|
+
this.blocos = 0;
|
|
137
|
+
this.hashArquivo = hashArquivo || 0;
|
|
138
|
+
this.simbolos = (retornoLexador === null || retornoLexador === void 0 ? void 0 : retornoLexador.simbolos) || [];
|
|
139
|
+
const declaracoes = [];
|
|
140
|
+
while (!this.estaNoFinal()) {
|
|
141
|
+
declaracoes.push(this.declaracao());
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
declaracoes: declaracoes,
|
|
145
|
+
erros: this.erros,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
exports.AvaliadorSintaticoGuarani = AvaliadorSintaticoGuarani;
|
|
150
|
+
//# sourceMappingURL=avaliador-sintatico-guarani.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"avaliador-sintatico-guarani.js","sourceRoot":"","sources":["../../../../fontes/avaliador-sintatico/dialetos/avaliador-sintatico-guarani.ts"],"names":[],"mappings":";;;;;;AAAA,iDAA6K;AAC7K,mDAA4F;AAE5F,0EAAqE;AAErE,8EAA8D;AAG9D,MAAa,yBAA0B,SAAQ,iDAAsB;IACjE,QAAQ;QACJ,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC/C,IAAI,IAAI,CAAC,8BAA8B,CAAC,iBAAe,CAAC,MAAM,EAAE,iBAAe,CAAC,KAAK,CAAC,EAAE;YACpF,MAAM,eAAe,GAAqB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAA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YAAY,CAAC,IAAI,EAAE;YACvB,KAAK,iBAAe,CAAC,GAAG;gBACpB,OAAO,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACpC;gBACI,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC;SAC/B;IACL,CAAC;IAED,QAAQ,CAAC,cAA8B,EAAE,WAAoB;QACzD,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QACf,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAEhB,IAAI,CAAC,WAAW,GAAG,WAAW,IAAI,CAAC,CAAC;QACpC,IAAI,CAAC,QAAQ,GAAG,CAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,QAAQ,KAAI,EAAE,CAAC;QAE/C,MAAM,WAAW,GAAiB,EAAE,CAAC;QACrC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE;YACxB,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAgB,CAAC,CAAC;SACrD;QAED,OAAO;YACH,WAAW,EAAE,WAAW;YACxB,KAAK,EAAE,IAAI,CAAC,KAAK;SACS,CAAC;IACnC,CAAC;CACJ;AA1KD,8DA0KC"}
|
|
@@ -14,5 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./avaliador-sintatico-birl"), exports);
|
|
17
18
|
__exportStar(require("./avaliador-sintatico-egua-classico"), exports);
|
|
19
|
+
__exportStar(require("./avaliador-sintatico-eguap"), exports);
|
|
20
|
+
__exportStar(require("./avaliador-sintatico-portugol-studio"), exports);
|
|
21
|
+
__exportStar(require("./avaliador-sintatico-visualg"), exports);
|
|
18
22
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../fontes/avaliador-sintatico/dialetos/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sEAAoD"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../fontes/avaliador-sintatico/dialetos/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6DAA2C;AAC3C,sEAAoD;AACpD,8DAA4C;AAC5C,wEAAsD;AACtD,gEAA8C"}
|
|
@@ -21,5 +21,4 @@ exports.cyrb53 = void 0;
|
|
|
21
21
|
var cyrb53_1 = require("./cyrb53");
|
|
22
22
|
Object.defineProperty(exports, "cyrb53", { enumerable: true, get: function () { return __importDefault(cyrb53_1).default; } });
|
|
23
23
|
__exportStar(require("./ponto-parada"), exports);
|
|
24
|
-
__exportStar(require("./remota/servidor-depuracao"), exports);
|
|
25
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../fontes/depuracao/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,mCAA6C;AAApC,iHAAA,OAAO,OAAU;AAC1B,iDAA+B
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../fontes/depuracao/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,mCAA6C;AAApC,iHAAA,OAAO,OAAU;AAC1B,iDAA+B"}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
export * from './avaliador-sintatico-interface';
|
|
2
|
-
export * from './delegua-interface';
|
|
3
|
-
export * from './importador-interface';
|
|
4
2
|
export * from './interpretador-com-depuracao-interface';
|
|
5
3
|
export * from './interpretador-interface';
|
|
6
4
|
export * from './lexador-interface';
|
|
@@ -15,8 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./avaliador-sintatico-interface"), exports);
|
|
18
|
-
__exportStar(require("./delegua-interface"), exports);
|
|
19
|
-
__exportStar(require("./importador-interface"), exports);
|
|
20
18
|
__exportStar(require("./interpretador-com-depuracao-interface"), exports);
|
|
21
19
|
__exportStar(require("./interpretador-interface"), exports);
|
|
22
20
|
__exportStar(require("./lexador-interface"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../fontes/interfaces/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kEAAgD;AAChD,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../fontes/interfaces/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kEAAgD;AAChD,0EAAwD;AACxD,4DAA0C;AAC1C,sDAAoC;AACpC,wDAAsC;AACtC,oDAAkC;AAClC,yDAAuC;AACvC,wEAAsD;AACtD,sDAAoC;AACpC,uDAAqC;AACrC,uDAAqC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { EspacoVariaveis } from '../../../espaco-variaveis';
|
|
2
|
-
import { Delegua } from '../../../delegua';
|
|
3
2
|
import { DeleguaFuncao } from '../../../estruturas/delegua-funcao';
|
|
4
3
|
import { InterpretadorInterface, SimboloInterface, ResolvedorInterface, VariavelInterface } from '../../../interfaces';
|
|
5
4
|
import { Classe, Declaracao, Enquanto, Escolha, Escreva, EscrevaMesmaLinha, Expressao, Fazer, FuncaoDeclaracao, Importar, Leia, Para, Se, Tente, Var } from '../../../declaracoes';
|
|
@@ -13,7 +12,6 @@ import { ContinuarQuebra, RetornoQuebra, SustarQuebra } from '../../../quebras';
|
|
|
13
12
|
* e de fato executa a lógica de programação descrita no código.
|
|
14
13
|
*/
|
|
15
14
|
export declare class InterpretadorEguaClassico implements InterpretadorInterface {
|
|
16
|
-
Delegua: Delegua;
|
|
17
15
|
resolvedor: ResolvedorInterface;
|
|
18
16
|
diretorioBase: any;
|
|
19
17
|
funcaoDeRetorno: Function;
|
|
@@ -21,7 +19,7 @@ export declare class InterpretadorEguaClassico implements InterpretadorInterface
|
|
|
21
19
|
erros: ErroInterpretador[];
|
|
22
20
|
pilhaEscoposExecucao: PilhaEscoposExecucao;
|
|
23
21
|
interfaceEntradaSaida: any;
|
|
24
|
-
constructor(
|
|
22
|
+
constructor(diretorioBase: string);
|
|
25
23
|
visitarExpressaoFormatacaoEscrita(declaracao: FormatacaoEscrita): void;
|
|
26
24
|
visitarExpressaoEscrevaMesmaLinha(declaracao: EscrevaMesmaLinha): void;
|
|
27
25
|
visitarExpressaoLeia(expressao: Leia): Promise<any>;
|
|
@@ -46,7 +44,7 @@ export declare class InterpretadorEguaClassico implements InterpretadorInterface
|
|
|
46
44
|
visitarDeclaracaoEscolha(declaracao: Escolha): Promise<void>;
|
|
47
45
|
visitarDeclaracaoTente(declaracao: Tente): Promise<any>;
|
|
48
46
|
visitarDeclaracaoEnquanto(declaracao: Enquanto): Promise<any>;
|
|
49
|
-
visitarDeclaracaoImportar(declaracao: Importar): Promise<
|
|
47
|
+
visitarDeclaracaoImportar(declaracao: Importar): Promise<void>;
|
|
50
48
|
visitarDeclaracaoEscreva(declaracao: Escreva): Promise<any>;
|
|
51
49
|
/**
|
|
52
50
|
* Empilha declarações na pilha de escopos de execução, cria um novo ambiente e
|
|
@@ -1,36 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
4
|
};
|
|
28
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
6
|
exports.InterpretadorEguaClassico = void 0;
|
|
30
|
-
const caminho = __importStar(require("path"));
|
|
31
|
-
const sistemaArquivos = __importStar(require("fs"));
|
|
32
7
|
const espaco_variaveis_1 = require("../../../espaco-variaveis");
|
|
33
|
-
const delegua_1 = require("../../../delegua");
|
|
34
8
|
const chamavel_1 = require("../../../estruturas/chamavel");
|
|
35
9
|
const funcao_padrao_1 = require("../../../estruturas/funcao-padrao");
|
|
36
10
|
const delegua_classe_1 = require("../../../estruturas/delegua-classe");
|
|
@@ -43,16 +17,14 @@ const quebras_1 = require("../../../quebras");
|
|
|
43
17
|
const inferenciador_1 = require("../../inferenciador");
|
|
44
18
|
const egua_classico_1 = __importDefault(require("../../../tipos-de-simbolos/egua-classico"));
|
|
45
19
|
const biblioteca_global_1 = __importDefault(require("../../../bibliotecas/dialetos/egua-classico/biblioteca-global"));
|
|
46
|
-
const egua_classico_2 = require("../../../bibliotecas/dialetos/egua-classico");
|
|
47
20
|
const resolvedor_1 = require("./resolvedor/resolvedor");
|
|
48
21
|
/**
|
|
49
22
|
* O Interpretador visita todos os elementos complexos gerados pelo analisador sintático (Parser)
|
|
50
23
|
* e de fato executa a lógica de programação descrita no código.
|
|
51
24
|
*/
|
|
52
25
|
class InterpretadorEguaClassico {
|
|
53
|
-
constructor(
|
|
26
|
+
constructor(diretorioBase) {
|
|
54
27
|
this.interfaceEntradaSaida = null;
|
|
55
|
-
this.Delegua = Delegua;
|
|
56
28
|
this.resolvedor = new resolvedor_1.ResolvedorEguaClassico();
|
|
57
29
|
this.diretorioBase = diretorioBase;
|
|
58
30
|
this.funcaoDeRetorno = console.log;
|
|
@@ -413,35 +385,54 @@ class InterpretadorEguaClassico {
|
|
|
413
385
|
}
|
|
414
386
|
return null;
|
|
415
387
|
}
|
|
388
|
+
// TODO: Implementar em `delegua-node`.
|
|
416
389
|
async visitarDeclaracaoImportar(declaracao) {
|
|
417
|
-
|
|
390
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(declaracao.simboloFechamento, 'Importação não suportada em núcleo da linguagem puro. Favor executar a aplicação usando o pacote NPM `delegua-node`.', declaracao.linha);
|
|
391
|
+
/* const caminhoRelativo = await this.avaliar(declaracao.caminho);
|
|
418
392
|
const caminhoTotal = caminho.join(this.diretorioBase, caminhoRelativo);
|
|
419
393
|
// const nomeArquivo = caminho.basename(caminhoTotal);
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
394
|
+
|
|
395
|
+
let dados: any = carregarModuloPorNome(caminhoRelativo);
|
|
396
|
+
if (dados) return dados;
|
|
397
|
+
|
|
423
398
|
try {
|
|
424
399
|
if (!sistemaArquivos.existsSync(caminhoTotal)) {
|
|
425
|
-
throw new
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
400
|
+
throw new ErroEmTempoDeExecucao(
|
|
401
|
+
declaracao.simboloFechamento,
|
|
402
|
+
'Não foi possível encontrar arquivo importado.',
|
|
403
|
+
declaracao.linha
|
|
404
|
+
);
|
|
405
|
+
}
|
|
406
|
+
} catch (erro) {
|
|
407
|
+
throw new ErroEmTempoDeExecucao(
|
|
408
|
+
declaracao.simboloFechamento,
|
|
409
|
+
'Não foi possível ler o arquivo.',
|
|
410
|
+
declaracao.linha
|
|
411
|
+
);
|
|
412
|
+
}
|
|
413
|
+
|
|
431
414
|
dados = sistemaArquivos.readFileSync(caminhoTotal).toString();
|
|
432
|
-
|
|
415
|
+
|
|
416
|
+
const delegua = new Delegua(this.Delegua.dialeto, false);
|
|
417
|
+
|
|
433
418
|
delegua.executar(dados);
|
|
419
|
+
|
|
434
420
|
const exportar = this.pilhaEscoposExecucao.obterTodasDeleguaFuncao();
|
|
435
|
-
|
|
421
|
+
|
|
422
|
+
const eDicionario = (objeto: any) => objeto.constructor === Object;
|
|
423
|
+
|
|
436
424
|
if (eDicionario(exportar)) {
|
|
437
|
-
const novoModulo = new
|
|
425
|
+
const novoModulo = new DeleguaModulo();
|
|
426
|
+
|
|
438
427
|
const chaves = Object.keys(exportar);
|
|
439
428
|
for (let i = 0; i < chaves.length; i++) {
|
|
440
429
|
novoModulo[chaves[i]] = exportar[chaves[i]];
|
|
441
430
|
}
|
|
431
|
+
|
|
442
432
|
return novoModulo;
|
|
443
433
|
}
|
|
444
|
-
|
|
434
|
+
|
|
435
|
+
return exportar; */
|
|
445
436
|
}
|
|
446
437
|
async visitarDeclaracaoEscreva(declaracao) {
|
|
447
438
|
try {
|