@designliquido/delegua 0.0.2 → 0.1.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.
Files changed (81) hide show
  1. package/.github/CONTRIBUTING.md +37 -0
  2. package/.github/workflows/principal.yml +3 -1
  3. package/.release-it.json +2 -1
  4. package/.vscode/launch.json +43 -8
  5. package/README.md +9 -1
  6. package/bin/delegua +2 -2
  7. package/bin/delegua.cmd +1 -1
  8. package/index.ts +29 -0
  9. package/package.json +9 -4
  10. package/src/ambiente.ts +56 -0
  11. package/src/avaliador-sintatico/dialetos/egua-classico.ts +983 -0
  12. package/src/avaliador-sintatico/dialetos/index.ts +1 -0
  13. package/src/avaliador-sintatico/index.ts +983 -0
  14. package/src/avaliador-sintatico/parser-error.ts +1 -0
  15. package/src/{lib/globalLib.js → bibliotecas/bibliotecaGlobal.ts} +34 -34
  16. package/src/{lib/importStdlib.js → bibliotecas/importarBiblioteca.ts} +9 -9
  17. package/src/construtos/assign-subscript.ts +19 -0
  18. package/src/construtos/atribuir.ts +17 -0
  19. package/src/construtos/binario.ts +19 -0
  20. package/src/construtos/call.ts +19 -0
  21. package/src/construtos/conjunto.ts +19 -0
  22. package/src/construtos/dicionario.ts +17 -0
  23. package/src/construtos/expr.ts +3 -0
  24. package/src/construtos/funcao.ts +17 -0
  25. package/src/construtos/get.ts +17 -0
  26. package/src/construtos/grouping.ts +15 -0
  27. package/src/construtos/index.ts +18 -0
  28. package/src/construtos/isto.ts +15 -0
  29. package/src/construtos/literal.ts +15 -0
  30. package/src/construtos/logical.ts +19 -0
  31. package/src/construtos/subscript.ts +19 -0
  32. package/src/construtos/super.ts +17 -0
  33. package/src/construtos/unario.ts +17 -0
  34. package/src/construtos/variavel.ts +15 -0
  35. package/src/construtos/vetor.ts +15 -0
  36. package/src/{stmt.js → declaracoes/index.ts} +79 -51
  37. package/src/delegua.ts +156 -0
  38. package/src/estruturas/callable.ts +11 -0
  39. package/src/estruturas/{classe.js → classe.ts} +11 -7
  40. package/src/estruturas/{funcaoPadrao.js → funcao-padrao.ts} +8 -4
  41. package/src/estruturas/funcao.ts +70 -0
  42. package/src/estruturas/index.ts +6 -0
  43. package/src/estruturas/{instancia.js → instancia.ts} +12 -9
  44. package/src/estruturas/modulo.ts +11 -0
  45. package/src/excecoes/break-exception.ts +1 -0
  46. package/src/excecoes/continue-exception.ts +1 -0
  47. package/src/excecoes/erro-em-tempo-de-execucao.ts +11 -0
  48. package/src/excecoes/index.ts +4 -0
  49. package/src/excecoes/return-exception.ts +10 -0
  50. package/src/interfaces/avaliador-sintatico-interface.ts +58 -0
  51. package/src/interfaces/index.ts +6 -0
  52. package/src/interfaces/interpretador-interface.ts +52 -0
  53. package/src/interfaces/lexador-interface.ts +24 -0
  54. package/src/interfaces/pilha-interface.ts +7 -0
  55. package/src/interfaces/resolvedor-interface.ts +49 -0
  56. package/src/interfaces/simbolo-interface.ts +6 -0
  57. package/src/interpretador/dialetos/egua-classico.ts +825 -0
  58. package/src/interpretador/dialetos/index.ts +1 -0
  59. package/src/interpretador/index.ts +825 -0
  60. package/src/lexador/dialetos/egua-classico.ts +333 -0
  61. package/src/lexador/dialetos/index.ts +1 -0
  62. package/src/{lexer.js → lexador/index.ts} +38 -21
  63. package/src/resolvedor/Pilha.ts +29 -0
  64. package/src/resolvedor/ResolverError.ts +8 -0
  65. package/src/resolvedor/dialetos/egua-classico.ts +412 -0
  66. package/src/resolvedor/dialetos/index.ts +1 -0
  67. package/src/{resolver.js → resolvedor/index.ts} +101 -114
  68. package/src/{tiposDeSimbolos.js → tiposDeSimbolos.ts} +21 -22
  69. package/src/web.ts +75 -0
  70. package/tsconfig.json +11 -0
  71. package/indice.js +0 -14
  72. package/src/ambiente.js +0 -53
  73. package/src/delegua.js +0 -102
  74. package/src/erro.js +0 -18
  75. package/src/estruturas/callable.js +0 -5
  76. package/src/estruturas/funcao.js +0 -62
  77. package/src/estruturas/modulo.js +0 -9
  78. package/src/expr.js +0 -228
  79. package/src/interpretador.js +0 -802
  80. package/src/parser.js +0 -822
  81. package/src/web.js +0 -70
package/src/web.js DELETED
@@ -1,70 +0,0 @@
1
- const Lexer = require("./lexer.js");
2
- const Parser = require("./parser.js");
3
- const Resolver = require("./resolver.js");
4
- const Interpretador = require("./interpretador.js");
5
- const tokenTypes = require("./tokenTypes.js");
6
-
7
- module.exports.Delegua = class Delegua {
8
- constructor(nomeArquivo) {
9
- this.nomeArquivo = nomeArquivo;
10
-
11
- this.teveErro = false;
12
- this.teveErroEmTempoDeExecucao = false;
13
- }
14
-
15
- runBlock(codigo) {
16
- const interpretador = new Interpretador(this, process.cwd());
17
-
18
- const lexer = new Lexer(codigo, this);
19
- const simbolos = lexer.scan();
20
-
21
- if (this.teveErro === true) return;
22
-
23
- const analisar = new Parser(simbolos, this);
24
- const declaracoes = analisar.analisar();
25
-
26
- if (this.teveErro === true) return;
27
-
28
- const resolver = new Resolver(interpretador, this);
29
- resolver.resolve(declaracoes);
30
-
31
- if (this.teveErro === true) return;
32
-
33
- interpretador.interpretar(declaracoes);
34
- }
35
-
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
- }
44
-
45
- erro(simbolo, mensagemDeErro) {
46
- if (simbolo.tipo === tokenTypes.EOF) {
47
- this.reportar(simbolo.line, " no final", mensagemDeErro);
48
- } else {
49
- this.reportar(simbolo.line, ` no '${simbolo.lexeme}'`, mensagemDeErro);
50
- }
51
- }
52
-
53
- lexerError(linha, caractere, mensagem) {
54
- this.reportar(linha, ` no '${caractere}'`, mensagem);
55
- }
56
-
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
- } else {
66
- console.error(`Erro: ${erro.mensagem}`);
67
- }
68
- this.teveErroEmTempoDeExecucao = true;
69
- }
70
- };