@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.
Files changed (43) hide show
  1. package/.github/CONTRIBUTING.md +0 -0
  2. package/.github/workflows/principal.yml +20 -0
  3. package/.release-it.json +8 -0
  4. package/.vscode/launch.json +2 -2
  5. package/README.md +5 -6
  6. package/bin/delegua +1 -1
  7. package/bin/delegua.cmd +1 -0
  8. package/indice.js +14 -0
  9. package/package.json +46 -37
  10. package/src/ambiente.js +53 -0
  11. package/src/{egua.js → delegua.js} +20 -20
  12. package/src/erro.js +18 -0
  13. package/src/estruturas/callable.js +5 -0
  14. package/src/estruturas/classe.js +43 -0
  15. package/src/estruturas/funcao.js +62 -0
  16. package/src/estruturas/funcaoPadrao.js +18 -0
  17. package/src/estruturas/instancia.js +27 -0
  18. package/src/estruturas/modulo.js +9 -0
  19. package/src/expr.js +52 -52
  20. package/src/interpretador.js +802 -0
  21. package/src/lexer.js +90 -89
  22. package/src/lib/globalLib.js +63 -63
  23. package/src/lib/importStdlib.js +18 -27
  24. package/src/parser.js +219 -223
  25. package/src/resolver.js +93 -93
  26. package/src/stmt.js +34 -34
  27. package/src/{tokenTypes.js → tiposDeSimbolos.js} +21 -21
  28. package/src/web.js +41 -41
  29. package/testes/testes.egua +363 -364
  30. package/index.html +0 -43
  31. package/index.js +0 -14
  32. package/src/environment.js +0 -53
  33. package/src/errors.js +0 -17
  34. package/src/interpreter.js +0 -798
  35. package/src/lib/__tests__/eguamat.test.js +0 -101
  36. package/src/lib/eguamat.js +0 -725
  37. package/src/lib/tempo.js +0 -50
  38. package/src/structures/callable.js +0 -5
  39. package/src/structures/class.js +0 -43
  40. package/src/structures/function.js +0 -62
  41. package/src/structures/instance.js +0 -27
  42. package/src/structures/module.js +0 -9
  43. 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 Interpreter = require("./interpreter.js");
4
+ const Interpretador = require("./interpretador.js");
5
5
  const tokenTypes = require("./tokenTypes.js");
6
6
 
7
- module.exports.Egua = class Egua {
8
- constructor(filename) {
9
- this.filename = filename;
7
+ module.exports.Delegua = class Delegua {
8
+ constructor(nomeArquivo) {
9
+ this.nomeArquivo = nomeArquivo;
10
10
 
11
- this.hadError = false;
12
- this.hadRuntimeError = false;
11
+ this.teveErro = false;
12
+ this.teveErroEmTempoDeExecucao = false;
13
13
  }
14
14
 
15
- runBlock(code) {
16
- const interpreter = new Interpreter(this, process.cwd());
15
+ runBlock(codigo) {
16
+ const interpretador = new Interpretador(this, process.cwd());
17
17
 
18
- const lexer = new Lexer(code, this);
19
- const tokens = lexer.scan();
18
+ const lexer = new Lexer(codigo, this);
19
+ const simbolos = lexer.scan();
20
20
 
21
- if (this.hadError === true) return;
21
+ if (this.teveErro === true) return;
22
22
 
23
- const parser = new Parser(tokens, this);
24
- const statements = parser.parse();
23
+ const analisar = new Parser(simbolos, this);
24
+ const declaracoes = analisar.analisar();
25
25
 
26
- if (this.hadError === true) return;
26
+ if (this.teveErro === true) return;
27
27
 
28
- const resolver = new Resolver(interpreter, this);
29
- resolver.resolve(statements);
28
+ const resolver = new Resolver(interpretador, this);
29
+ resolver.resolve(declaracoes);
30
30
 
31
- if (this.hadError === true) return;
31
+ if (this.teveErro === true) return;
32
32
 
33
- interpreter.interpret(statements);
33
+ interpretador.interpretar(declaracoes);
34
34
  }
35
35
 
36
- report(line, where, message) {
37
- if (this.filename)
38
- console.error(
39
- `[Arquivo: ${this.filename}] [Linha: ${line}] Erro${where}: ${message}`
40
- );
41
- else console.error(`[Linha: ${line}] Erro${where}: ${message}`);
42
- this.hadError = true;
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
- error(token, errorMessage) {
46
- if (token.type === tokenTypes.EOF) {
47
- this.report(token.line, " no fim", errorMessage);
45
+ erro(simbolo, mensagemDeErro) {
46
+ if (simbolo.tipo === tokenTypes.EOF) {
47
+ this.reportar(simbolo.line, " no final", mensagemDeErro);
48
48
  } else {
49
- this.report(token.line, ` no '${token.lexeme}'`, errorMessage);
49
+ this.reportar(simbolo.line, ` no '${simbolo.lexeme}'`, mensagemDeErro);
50
50
  }
51
51
  }
52
52
 
53
- lexerError(line, char, msg) {
54
- this.report(line, ` no '${char}'`, msg);
53
+ lexerError(linha, caractere, mensagem) {
54
+ this.reportar(linha, ` no '${caractere}'`, mensagem);
55
55
  }
56
56
 
57
- runtimeError(error) {
58
- let line = error.token.line;
59
- if (error.token && line) {
60
- if (this.filename)
61
- console.error(
62
- `Erro: [Arquivo: ${this.filename}] [Linha: ${error.token.line}] ${error.message}`
63
- );
64
- else console.error(`Erro: [Linha: ${error.token.line}] ${error.message}`);
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
- console.error(error);
66
+ console.error(`Erro: ${erro.mensagem}`);
67
67
  }
68
- this.hadRuntimeError = true;
68
+ this.teveErroEmTempoDeExecucao = true;
69
69
  }
70
70
  };