@designliquido/delegua 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/CONTRIBUTING.md +0 -0
- package/.github/workflows/principal.yml +20 -0
- package/.release-it.json +8 -0
- package/.vscode/launch.json +2 -2
- package/README.md +5 -6
- package/bin/delegua +1 -1
- package/bin/delegua.cmd +1 -0
- package/indice.js +14 -0
- package/package.json +46 -37
- package/src/ambiente.js +53 -0
- package/src/{egua.js → delegua.js} +20 -20
- package/src/erro.js +18 -0
- package/src/estruturas/callable.js +5 -0
- package/src/estruturas/classe.js +43 -0
- package/src/estruturas/funcao.js +62 -0
- package/src/estruturas/funcaoPadrao.js +18 -0
- package/src/estruturas/instancia.js +27 -0
- package/src/estruturas/modulo.js +9 -0
- package/src/expr.js +52 -52
- package/src/interpretador.js +802 -0
- package/src/lexer.js +90 -89
- package/src/lib/globalLib.js +63 -63
- package/src/lib/importStdlib.js +18 -27
- package/src/parser.js +219 -223
- package/src/resolver.js +93 -93
- package/src/stmt.js +34 -34
- package/src/{tokenTypes.js → tiposDeSimbolos.js} +21 -21
- package/src/web.js +41 -41
- package/testes/testes.egua +363 -364
- package/index.html +0 -43
- package/index.js +0 -14
- package/src/environment.js +0 -53
- package/src/errors.js +0 -17
- package/src/interpreter.js +0 -798
- package/src/lib/__tests__/eguamat.test.js +0 -101
- package/src/lib/eguamat.js +0 -725
- package/src/lib/tempo.js +0 -50
- package/src/structures/callable.js +0 -5
- package/src/structures/class.js +0 -43
- package/src/structures/function.js +0 -62
- package/src/structures/instance.js +0 -27
- package/src/structures/module.js +0 -9
- package/src/structures/standardFn.js +0 -18
package/src/web.js
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
1
|
const Lexer = require("./lexer.js");
|
|
2
2
|
const Parser = require("./parser.js");
|
|
3
3
|
const Resolver = require("./resolver.js");
|
|
4
|
-
const
|
|
4
|
+
const Interpretador = require("./interpretador.js");
|
|
5
5
|
const tokenTypes = require("./tokenTypes.js");
|
|
6
6
|
|
|
7
|
-
module.exports.
|
|
8
|
-
constructor(
|
|
9
|
-
this.
|
|
7
|
+
module.exports.Delegua = class Delegua {
|
|
8
|
+
constructor(nomeArquivo) {
|
|
9
|
+
this.nomeArquivo = nomeArquivo;
|
|
10
10
|
|
|
11
|
-
this.
|
|
12
|
-
this.
|
|
11
|
+
this.teveErro = false;
|
|
12
|
+
this.teveErroEmTempoDeExecucao = false;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
runBlock(
|
|
16
|
-
const
|
|
15
|
+
runBlock(codigo) {
|
|
16
|
+
const interpretador = new Interpretador(this, process.cwd());
|
|
17
17
|
|
|
18
|
-
const lexer = new Lexer(
|
|
19
|
-
const
|
|
18
|
+
const lexer = new Lexer(codigo, this);
|
|
19
|
+
const simbolos = lexer.scan();
|
|
20
20
|
|
|
21
|
-
if (this.
|
|
21
|
+
if (this.teveErro === true) return;
|
|
22
22
|
|
|
23
|
-
const
|
|
24
|
-
const
|
|
23
|
+
const analisar = new Parser(simbolos, this);
|
|
24
|
+
const declaracoes = analisar.analisar();
|
|
25
25
|
|
|
26
|
-
if (this.
|
|
26
|
+
if (this.teveErro === true) return;
|
|
27
27
|
|
|
28
|
-
const resolver = new Resolver(
|
|
29
|
-
resolver.resolve(
|
|
28
|
+
const resolver = new Resolver(interpretador, this);
|
|
29
|
+
resolver.resolve(declaracoes);
|
|
30
30
|
|
|
31
|
-
if (this.
|
|
31
|
+
if (this.teveErro === true) return;
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
interpretador.interpretar(declaracoes);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
if (this.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
else console.error(`[Linha: ${
|
|
42
|
-
this.
|
|
36
|
+
reportar(linha, onde, mensagem) {
|
|
37
|
+
if (this.nomeArquivo)
|
|
38
|
+
console.error(
|
|
39
|
+
`[Arquivo: ${this.nomeArquivo}] [Linha: ${linha}] Erro${onde}: ${mensagem}`
|
|
40
|
+
);
|
|
41
|
+
else console.error(`[Linha: ${linha}] Erro${onde}: ${mensagem}`);
|
|
42
|
+
this.teveErro = true;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
if (
|
|
47
|
-
|
|
45
|
+
erro(simbolo, mensagemDeErro) {
|
|
46
|
+
if (simbolo.tipo === tokenTypes.EOF) {
|
|
47
|
+
this.reportar(simbolo.line, " no final", mensagemDeErro);
|
|
48
48
|
} else {
|
|
49
|
-
|
|
49
|
+
this.reportar(simbolo.line, ` no '${simbolo.lexeme}'`, mensagemDeErro);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
lexerError(
|
|
54
|
-
this.
|
|
53
|
+
lexerError(linha, caractere, mensagem) {
|
|
54
|
+
this.reportar(linha, ` no '${caractere}'`, mensagem);
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
57
|
+
erroEmTempoDeExecucao(erro) {
|
|
58
|
+
const linha = erro.simbolo.linha;
|
|
59
|
+
if (erro.simbolo && linha) {
|
|
60
|
+
if (this.nomeArquivo)
|
|
61
|
+
console.error(
|
|
62
|
+
`Erro: [Arquivo: ${this.nomeArquivo}] [Linha: ${erro.simbolo.linha}] ${erro.mensagem}`
|
|
63
|
+
);
|
|
64
|
+
else console.error(`Erro: [Linha: ${erro.simbolo.linha}] ${erro.mensagem}`);
|
|
65
65
|
} else {
|
|
66
|
-
|
|
66
|
+
console.error(`Erro: ${erro.mensagem}`);
|
|
67
67
|
}
|
|
68
|
-
this.
|
|
68
|
+
this.teveErroEmTempoDeExecucao = true;
|
|
69
69
|
}
|
|
70
70
|
};
|