@designliquido/delegua 0.1.0 → 0.1.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.
Files changed (194) hide show
  1. package/bin/delegua +2 -2
  2. package/bin/delegua.cmd +1 -1
  3. package/bin/package.json +51 -0
  4. package/index.js +27 -0
  5. package/index.js.map +1 -0
  6. package/package.json +2 -2
  7. package/src/ambiente.js +49 -0
  8. package/src/ambiente.js.map +1 -0
  9. package/src/avaliador-sintatico/dialetos/egua-classico.js +635 -0
  10. package/src/avaliador-sintatico/dialetos/egua-classico.js.map +1 -0
  11. package/src/avaliador-sintatico/dialetos/index.js +14 -0
  12. package/src/avaliador-sintatico/dialetos/index.js.map +1 -0
  13. package/src/avaliador-sintatico/index.js +635 -0
  14. package/src/avaliador-sintatico/index.js.map +1 -0
  15. package/src/avaliador-sintatico/parser-error.js +27 -0
  16. package/src/avaliador-sintatico/parser-error.js.map +1 -0
  17. package/src/bibliotecas/bibliotecaGlobal.js +97 -0
  18. package/src/bibliotecas/bibliotecaGlobal.js.map +1 -0
  19. package/src/bibliotecas/importarBiblioteca.js +32 -0
  20. package/src/bibliotecas/importarBiblioteca.js.map +1 -0
  21. package/src/construtos/assign-subscript.js +35 -0
  22. package/src/construtos/assign-subscript.js.map +1 -0
  23. package/src/construtos/atribuir.js +34 -0
  24. package/src/construtos/atribuir.js.map +1 -0
  25. package/src/construtos/binario.js +35 -0
  26. package/src/construtos/binario.js.map +1 -0
  27. package/src/construtos/call.js +35 -0
  28. package/src/construtos/call.js.map +1 -0
  29. package/src/construtos/conjunto.js +35 -0
  30. package/src/construtos/conjunto.js.map +1 -0
  31. package/src/construtos/dicionario.js +34 -0
  32. package/src/construtos/dicionario.js.map +1 -0
  33. package/src/construtos/expr.js +11 -0
  34. package/src/construtos/expr.js.map +1 -0
  35. package/src/construtos/funcao.js +34 -0
  36. package/src/construtos/funcao.js.map +1 -0
  37. package/src/construtos/get.js +34 -0
  38. package/src/construtos/get.js.map +1 -0
  39. package/src/construtos/grouping.js +33 -0
  40. package/src/construtos/grouping.js.map +1 -0
  41. package/src/construtos/index.js +31 -0
  42. package/src/construtos/index.js.map +1 -0
  43. package/src/construtos/isto.js +33 -0
  44. package/src/construtos/isto.js.map +1 -0
  45. package/src/construtos/literal.js +33 -0
  46. package/src/construtos/literal.js.map +1 -0
  47. package/src/construtos/logical.js +35 -0
  48. package/src/construtos/logical.js.map +1 -0
  49. package/src/construtos/subscript.js +35 -0
  50. package/src/construtos/subscript.js.map +1 -0
  51. package/src/construtos/super.js +34 -0
  52. package/src/construtos/super.js.map +1 -0
  53. package/src/construtos/unario.js +34 -0
  54. package/src/construtos/unario.js.map +1 -0
  55. package/src/construtos/variavel.js +33 -0
  56. package/src/construtos/variavel.js.map +1 -0
  57. package/src/construtos/vetor.js +33 -0
  58. package/src/construtos/vetor.js.map +1 -0
  59. package/src/declaracoes/index.js +249 -0
  60. package/src/declaracoes/index.js.map +1 -0
  61. package/src/delegua.js +132 -0
  62. package/src/delegua.js.map +1 -0
  63. package/src/estruturas/callable.js +16 -0
  64. package/src/estruturas/callable.js.map +1 -0
  65. package/src/estruturas/classe.js +57 -0
  66. package/src/estruturas/classe.js.map +1 -0
  67. package/src/estruturas/funcao-padrao.js +38 -0
  68. package/src/estruturas/funcao-padrao.js.map +1 -0
  69. package/src/estruturas/funcao.js +81 -0
  70. package/src/estruturas/funcao.js.map +1 -0
  71. package/src/estruturas/index.js +19 -0
  72. package/src/estruturas/index.js.map +1 -0
  73. package/src/estruturas/instancia.js +28 -0
  74. package/src/estruturas/instancia.js.map +1 -0
  75. package/src/estruturas/modulo.js +15 -0
  76. package/src/estruturas/modulo.js.map +1 -0
  77. package/src/excecoes/break-exception.js +27 -0
  78. package/src/excecoes/break-exception.js.map +1 -0
  79. package/src/excecoes/continue-exception.js +27 -0
  80. package/src/excecoes/continue-exception.js.map +1 -0
  81. package/src/excecoes/erro-em-tempo-de-execucao.js +31 -0
  82. package/src/excecoes/erro-em-tempo-de-execucao.js.map +1 -0
  83. package/src/excecoes/index.js +17 -0
  84. package/src/excecoes/index.js.map +1 -0
  85. package/src/excecoes/return-exception.js +30 -0
  86. package/src/excecoes/return-exception.js.map +1 -0
  87. package/src/interfaces/avaliador-sintatico-interface.js +3 -0
  88. package/src/interfaces/avaliador-sintatico-interface.js.map +1 -0
  89. package/src/interfaces/index.js +19 -0
  90. package/src/interfaces/index.js.map +1 -0
  91. package/src/interfaces/interpretador-interface.js +3 -0
  92. package/src/interfaces/interpretador-interface.js.map +1 -0
  93. package/src/interfaces/lexador-interface.js +3 -0
  94. package/src/interfaces/lexador-interface.js.map +1 -0
  95. package/src/interfaces/pilha-interface.js +3 -0
  96. package/src/interfaces/pilha-interface.js.map +1 -0
  97. package/src/interfaces/resolvedor-interface.js +3 -0
  98. package/src/interfaces/resolvedor-interface.js.map +1 -0
  99. package/src/interfaces/simbolo-interface.js +3 -0
  100. package/src/interfaces/simbolo-interface.js.map +1 -0
  101. package/src/interpretador/dialetos/egua-classico.js +665 -0
  102. package/src/interpretador/dialetos/egua-classico.js.map +1 -0
  103. package/src/interpretador/dialetos/index.js +14 -0
  104. package/src/interpretador/dialetos/index.js.map +1 -0
  105. package/src/interpretador/index.js +665 -0
  106. package/src/interpretador/index.js.map +1 -0
  107. package/src/lexador/dialetos/egua-classico.js +287 -0
  108. package/src/lexador/dialetos/egua-classico.js.map +1 -0
  109. package/src/lexador/dialetos/index.js +14 -0
  110. package/src/lexador/dialetos/index.js.map +1 -0
  111. package/src/lexador/index.js +287 -0
  112. package/src/lexador/index.js.map +1 -0
  113. package/src/resolvedor/Pilha.js +27 -0
  114. package/src/resolvedor/Pilha.js.map +1 -0
  115. package/src/resolvedor/ResolverError.js +29 -0
  116. package/src/resolvedor/ResolverError.js.map +1 -0
  117. package/src/resolvedor/{index.ts → dialetos/egua-classico.js} +147 -228
  118. package/src/resolvedor/dialetos/egua-classico.js.map +1 -0
  119. package/src/resolvedor/dialetos/index.js +14 -0
  120. package/src/resolvedor/dialetos/index.js.map +1 -0
  121. package/src/resolvedor/{dialetos/egua-classico.ts → index.js} +147 -228
  122. package/src/resolvedor/index.js.map +1 -0
  123. package/src/{tiposDeSimbolos.ts → tiposDeSimbolos.js} +5 -2
  124. package/src/tiposDeSimbolos.js.map +1 -0
  125. package/src/web.js +66 -0
  126. package/src/web.js.map +1 -0
  127. package/.github/CONTRIBUTING.md +0 -37
  128. package/.github/workflows/principal.yml +0 -22
  129. package/.release-it.json +0 -9
  130. package/.vscode/launch.json +0 -64
  131. package/.vscode/settings.json +0 -3
  132. package/LICENSE +0 -21
  133. package/README.md +0 -66
  134. package/babel.config.js +0 -1
  135. package/index.ts +0 -29
  136. package/src/ambiente.ts +0 -56
  137. package/src/avaliador-sintatico/dialetos/egua-classico.ts +0 -983
  138. package/src/avaliador-sintatico/dialetos/index.ts +0 -1
  139. package/src/avaliador-sintatico/index.ts +0 -983
  140. package/src/avaliador-sintatico/parser-error.ts +0 -1
  141. package/src/bibliotecas/bibliotecaGlobal.ts +0 -171
  142. package/src/bibliotecas/importarBiblioteca.ts +0 -32
  143. package/src/construtos/assign-subscript.ts +0 -19
  144. package/src/construtos/atribuir.ts +0 -17
  145. package/src/construtos/binario.ts +0 -19
  146. package/src/construtos/call.ts +0 -19
  147. package/src/construtos/conjunto.ts +0 -19
  148. package/src/construtos/dicionario.ts +0 -17
  149. package/src/construtos/expr.ts +0 -3
  150. package/src/construtos/funcao.ts +0 -17
  151. package/src/construtos/get.ts +0 -17
  152. package/src/construtos/grouping.ts +0 -15
  153. package/src/construtos/index.ts +0 -18
  154. package/src/construtos/isto.ts +0 -15
  155. package/src/construtos/literal.ts +0 -15
  156. package/src/construtos/logical.ts +0 -19
  157. package/src/construtos/subscript.ts +0 -19
  158. package/src/construtos/super.ts +0 -17
  159. package/src/construtos/unario.ts +0 -17
  160. package/src/construtos/variavel.ts +0 -15
  161. package/src/construtos/vetor.ts +0 -15
  162. package/src/declaracoes/index.ts +0 -243
  163. package/src/delegua.ts +0 -156
  164. package/src/estruturas/callable.ts +0 -11
  165. package/src/estruturas/classe.ts +0 -47
  166. package/src/estruturas/funcao-padrao.ts +0 -22
  167. package/src/estruturas/funcao.ts +0 -70
  168. package/src/estruturas/index.ts +0 -6
  169. package/src/estruturas/instancia.ts +0 -30
  170. package/src/estruturas/modulo.ts +0 -11
  171. package/src/excecoes/break-exception.ts +0 -1
  172. package/src/excecoes/continue-exception.ts +0 -1
  173. package/src/excecoes/erro-em-tempo-de-execucao.ts +0 -11
  174. package/src/excecoes/index.ts +0 -4
  175. package/src/excecoes/return-exception.ts +0 -10
  176. package/src/interfaces/avaliador-sintatico-interface.ts +0 -58
  177. package/src/interfaces/index.ts +0 -6
  178. package/src/interfaces/interpretador-interface.ts +0 -52
  179. package/src/interfaces/lexador-interface.ts +0 -24
  180. package/src/interfaces/pilha-interface.ts +0 -7
  181. package/src/interfaces/resolvedor-interface.ts +0 -49
  182. package/src/interfaces/simbolo-interface.ts +0 -6
  183. package/src/interpretador/dialetos/egua-classico.ts +0 -825
  184. package/src/interpretador/dialetos/index.ts +0 -1
  185. package/src/interpretador/index.ts +0 -825
  186. package/src/lexador/dialetos/egua-classico.ts +0 -333
  187. package/src/lexador/dialetos/index.ts +0 -1
  188. package/src/lexador/index.ts +0 -333
  189. package/src/resolvedor/Pilha.ts +0 -29
  190. package/src/resolvedor/ResolverError.ts +0 -8
  191. package/src/resolvedor/dialetos/index.ts +0 -1
  192. package/src/web.ts +0 -75
  193. package/testes/testes.egua +0 -630
  194. package/tsconfig.json +0 -11
@@ -1,243 +0,0 @@
1
- export class Stmt {
2
- aceitar(visitor) { }
3
- }
4
-
5
- export class Expressao extends Stmt {
6
- expressao: any;
7
-
8
- constructor(expressao) {
9
- super();
10
- this.expressao = expressao;
11
- }
12
-
13
- aceitar(visitor: any) {
14
- return visitor.visitExpressionStmt(this)
15
- }
16
- }
17
-
18
- export class Funcao extends Stmt {
19
- nome: string;
20
- funcao: any;
21
-
22
- constructor(nome: any, funcao: any) {
23
- super();
24
- this.nome = nome;
25
- this.funcao = funcao;
26
- }
27
-
28
- aceitar(visitor: any) {
29
- return visitor.visitFunctionStmt(this);
30
- }
31
- }
32
-
33
- export class Retorna extends Stmt {
34
- palavraChave: string;
35
- valor: any;
36
-
37
- constructor(palavraChave, valor) {
38
- super();
39
- this.palavraChave = palavraChave;
40
- this.valor = valor;
41
- }
42
-
43
- aceitar(visitor) {
44
- return visitor.visitReturnStmt(this);
45
- }
46
- }
47
-
48
- export class Classe extends Stmt {
49
- nome: string;
50
- superClasse: any;
51
- metodos: any;
52
-
53
- constructor(nome: any, superClasse: any, metodos: any) {
54
- super();
55
- this.nome = nome;
56
- this.superClasse = superClasse;
57
- this.metodos = metodos;
58
- }
59
-
60
- aceitar(visitor: any) {
61
- return visitor.visitClassStmt(this);
62
- }
63
- }
64
-
65
- export class Block extends Stmt {
66
- declaracoes: any;
67
-
68
- constructor(declaracoes) {
69
- super();
70
- this.declaracoes = declaracoes;
71
- }
72
-
73
- aceitar(visitor) {
74
- return visitor.visitBlockStmt(this);
75
- }
76
- }
77
-
78
- export class Escreva extends Stmt {
79
- expressao: any;
80
-
81
- constructor(expressao) {
82
- super();
83
- this.expressao = expressao;
84
- }
85
-
86
- aceitar(visitor) {
87
- return visitor.visitPrintStmt(this);
88
- }
89
- }
90
-
91
- export class Importar extends Stmt {
92
- caminho: string;
93
- closeBracket: any;
94
-
95
- constructor(caminho, closeBracket) {
96
- super();
97
- this.caminho = caminho;
98
- this.closeBracket = closeBracket;
99
- }
100
-
101
- aceitar(visitor) {
102
- return visitor.visitImportStmt(this);
103
- }
104
- }
105
-
106
- export class Fazer extends Stmt {
107
- doBranch: any;
108
- whileCondition: any;
109
-
110
- constructor(doBranch, whileCondition) {
111
- super();
112
- this.doBranch = doBranch;
113
- this.whileCondition = whileCondition;
114
- }
115
-
116
- aceitar(visitor) {
117
- return visitor.visitDoStmt(this);
118
- }
119
- }
120
-
121
- export class Enquanto extends Stmt {
122
- condicao: any;
123
- corpo: any;
124
-
125
- constructor(condicao, corpo) {
126
- super();
127
- this.condicao = condicao;
128
- this.corpo = corpo;
129
- }
130
-
131
- aceitar(visitor) {
132
- return visitor.visitWhileStmt(this);
133
- }
134
- }
135
-
136
- export class Para extends Stmt {
137
- inicializador: any;
138
- condicao: any;
139
- incrementar: any;
140
- corpo: any;
141
-
142
- constructor(inicializador, condicao, incrementar, corpo) {
143
- super();
144
- this.inicializador = inicializador;
145
- this.condicao = condicao;
146
- this.incrementar = incrementar;
147
- this.corpo = corpo;
148
- }
149
-
150
- aceitar(visitor) {
151
- return visitor.visitForStmt(this);
152
- }
153
- }
154
-
155
- export class Tente extends Stmt {
156
- tryBranch: any;
157
- catchBranch: any;
158
- elseBranch: any;
159
- finallyBranch: any;
160
-
161
- constructor(tryBranch: any, catchBranch: any, elseBranch: any, finallyBranch: any) {
162
- super();
163
- this.tryBranch = tryBranch;
164
- this.catchBranch = catchBranch;
165
- this.elseBranch = elseBranch;
166
- this.finallyBranch = finallyBranch;
167
- }
168
-
169
- aceitar(visitor: any) {
170
- return visitor.visitTryStmt(this);
171
- }
172
- }
173
-
174
- export class Se extends Stmt {
175
- condicao: any;
176
- thenBranch: any;
177
- elifBranches: any;
178
- elseBranch: any;
179
-
180
- constructor(condicao, thenBranch, elifBranches, elseBranch) {
181
- super();
182
- this.condicao = condicao;
183
- this.thenBranch = thenBranch;
184
- this.elifBranches = elifBranches;
185
- this.elseBranch = elseBranch;
186
- }
187
-
188
- aceitar(visitor) {
189
- return visitor.visitIfStmt(this);
190
- }
191
- }
192
-
193
- export class Escolha extends Stmt {
194
- condicao: any;
195
- branches: any;
196
- defaultBranch: any;
197
-
198
- constructor(condicao, branches, defaultBranch) {
199
- super();
200
- this.condicao = condicao;
201
- this.branches = branches;
202
- this.defaultBranch = defaultBranch;
203
- }
204
-
205
- aceitar(visitor) {
206
- return visitor.visitSwitchStmt(this);
207
- }
208
- }
209
-
210
- export class Pausa extends Stmt {
211
- constructor() {
212
- super();
213
- }
214
-
215
- aceitar(visitor) {
216
- return visitor.visitBreakStmt(this);
217
- }
218
- }
219
-
220
- export class Continua extends Stmt {
221
- constructor() {
222
- super();
223
- }
224
-
225
- aceitar(visitor) {
226
- return visitor.visitContinueStmt(this);
227
- }
228
- }
229
-
230
- export class Var extends Stmt {
231
- nome: any;
232
- inicializador: any;
233
-
234
- constructor(nome: any, inicializador: any) {
235
- super();
236
- this.nome = nome;
237
- this.inicializador = inicializador;
238
- }
239
-
240
- aceitar(visitor: any) {
241
- return visitor.visitVarStmt(this);
242
- }
243
- }
package/src/delegua.ts DELETED
@@ -1,156 +0,0 @@
1
- import * as fs from "fs";
2
- import * as caminho from "path";
3
- import * as readline from "readline";
4
-
5
- import { Lexer } from "./lexador";
6
- import { Parser } from "./avaliador-sintatico";
7
- import { Resolver } from "./resolvedor";
8
- import { Interpretador } from "./interpretador";
9
- import tiposDeSimbolos from "./tiposDeSimbolos";
10
-
11
- import { ReturnException } from "./excecoes";
12
- import { AvaliadorSintaticoInterface, InterpretadorInterface, LexadorInterface } from "./interfaces";
13
- import { ResolvedorInterface } from "./interfaces/resolvedor-interface";
14
- import { InterpretadorEguaClassico } from "./interpretador/dialetos/egua-classico";
15
- import { ResolverEguaClassico } from "./resolvedor/dialetos/egua-classico";
16
- import { ParserEguaClassico } from "./avaliador-sintatico/dialetos/egua-classico";
17
- import { LexerEguaClassico } from "./lexador/dialetos/egua-classico";
18
-
19
- export class Delegua {
20
- nomeArquivo: any;
21
- teveErro: any;
22
- teveErroEmTempoDeExecucao: any;
23
- dialeto: string;
24
-
25
- interpretador: InterpretadorInterface;
26
- lexador: LexadorInterface;
27
- avaliadorSintatico: AvaliadorSintaticoInterface;
28
- resolvedor: ResolvedorInterface;
29
-
30
- constructor(dialeto: string = 'delegua', nomeArquivo?: string) {
31
- this.nomeArquivo = nomeArquivo;
32
-
33
- this.teveErro = false;
34
- this.teveErroEmTempoDeExecucao = false;
35
-
36
- switch (dialeto) {
37
- case 'egua':
38
- this.interpretador = new InterpretadorEguaClassico(this, process.cwd());
39
- this.lexador = new LexerEguaClassico(this);
40
- this.avaliadorSintatico = new ParserEguaClassico(this);
41
- this.resolvedor = new ResolverEguaClassico(this, this.interpretador);
42
- console.log('Usando dialeto: Égua');
43
- break;
44
- case 'eguac':
45
- this.interpretador = new Interpretador(this, process.cwd());
46
- this.lexador = new Lexer(this);
47
- this.avaliadorSintatico = new Parser(this);
48
- this.resolvedor = new Resolver(this, this.interpretador);
49
- console.log('Usando dialeto: ÉguaC');
50
- break;
51
- case 'eguap':
52
- this.interpretador = new Interpretador(this, process.cwd());
53
- this.lexador = new Lexer(this);
54
- this.avaliadorSintatico = new Parser(this);
55
- this.resolvedor = new Resolver(this, this.interpretador);
56
- console.log('Usando dialeto: ÉguaP');
57
- break;
58
- default:
59
- this.interpretador = new Interpretador(this, process.cwd());
60
- this.lexador = new Lexer(this);
61
- this.avaliadorSintatico = new Parser(this);
62
- this.resolvedor = new Resolver(this, this.interpretador);
63
- console.log('Usando dialeto: padrão');
64
- break;
65
- }
66
- }
67
-
68
- versao() {
69
- return JSON.parse(fs.readFileSync('./package.json', { encoding: 'utf8' })).version || ''
70
- }
71
-
72
- iniciarDelegua() {
73
- const interpretador = new Interpretador(this, process.cwd());
74
- console.log(`Console da Linguagem Delégua v${this.versao()}`);
75
- const leiaLinha = readline.createInterface({
76
- input: process.stdin,
77
- output: process.stdout,
78
- prompt: "\ndelegua> "
79
- });
80
-
81
- leiaLinha.prompt();
82
-
83
- leiaLinha.on("line", linha => {
84
- this.teveErro = false;
85
- this.teveErroEmTempoDeExecucao = false;
86
-
87
- this.run(linha, interpretador);
88
- leiaLinha.prompt();
89
- });
90
- }
91
-
92
- carregarArquivo(nomeArquivo: any) {
93
- this.nomeArquivo = caminho.basename(nomeArquivo);
94
- const interpretador = new Interpretador(this, process.cwd());
95
-
96
- const dadosDoArquivo = fs.readFileSync(nomeArquivo).toString();
97
- this.run(dadosDoArquivo, interpretador);
98
-
99
- if (this.teveErro) process.exit(65);
100
- if (this.teveErroEmTempoDeExecucao) process.exit(70);
101
- }
102
-
103
- run(codigo: any, interpretador: any) {
104
- const lexer = new Lexer(this);
105
- const simbolos = lexer.scan(codigo);
106
-
107
- if (this.teveErro === true) return;
108
-
109
- const analisar = new Parser(this);
110
- const declaracoes = analisar.analisar(simbolos);
111
-
112
- if (this.teveErro === true) return;
113
-
114
- const resolver = new Resolver(this, interpretador);
115
- resolver.resolver(declaracoes);
116
-
117
- if (this.teveErro === true) return;
118
-
119
- interpretador.interpretar(declaracoes);
120
- }
121
-
122
- reportar(linha: any, onde: any, mensagem: any) {
123
- if (this.nomeArquivo)
124
- console.error(
125
- `[Arquivo: ${this.nomeArquivo}] [Linha: ${linha}] Erro${onde}: ${mensagem}`
126
- );
127
- else console.error(`[Linha: ${linha}] Erro${onde}: ${mensagem}`);
128
- this.teveErro = true;
129
- }
130
-
131
- erro(simbolo: any, mensagemDeErro: any) {
132
- if (simbolo.tipo === tiposDeSimbolos.EOF) {
133
- this.reportar(simbolo.line, " no final", mensagemDeErro);
134
- } else {
135
- this.reportar(simbolo.line, ` no '${simbolo.lexema}'`, mensagemDeErro);
136
- }
137
- }
138
-
139
- lexerError(linha: any, caractere: any, mensagem: any) {
140
- this.reportar(linha, ` no '${caractere}'`, mensagem);
141
- }
142
-
143
- erroEmTempoDeExecucao(erro: any) {
144
- if (erro & erro.simbolo && erro.simbolo.linha) {
145
- if (this.nomeArquivo)
146
- console.error(
147
- `Erro: [Arquivo: ${this.nomeArquivo}] [Linha: ${erro.simbolo.linha}] ${erro.mensagem}`
148
- );
149
- else console.error(`Erro: [Linha: ${erro.simbolo.linha}] ${erro.mensagem}`);
150
- } else if (!(erro instanceof ReturnException)) { // TODO: Ao se livrar de ReturnException, remover isto.
151
- console.error(`Erro: ${erro.mensagem}`);
152
- }
153
-
154
- this.teveErroEmTempoDeExecucao = true;
155
- }
156
- };
@@ -1,11 +0,0 @@
1
- export class Callable {
2
- valorAridade: any;
3
-
4
- aridade() {
5
- return this.valorAridade;
6
- }
7
-
8
- chamar(interpretador?: any, argumentos?: any, simbolo?: any) {
9
- throw new Error("Este método não deveria ser chamado.");
10
- }
11
- }
@@ -1,47 +0,0 @@
1
- import { Callable } from "./callable";
2
- import { DeleguaInstancia } from "./instancia";
3
-
4
- export class DeleguaClasse extends Callable {
5
- nome: any;
6
- superClasse: any;
7
- metodos: any;
8
-
9
- constructor(nome?: any, superClasse?: any, metodos?: any) {
10
- super();
11
- this.nome = nome;
12
- this.superClasse = superClasse;
13
- this.metodos = metodos;
14
- }
15
-
16
- encontrarMetodo(nome: any) {
17
- if (this.metodos.hasOwnProperty(nome)) {
18
- return this.metodos[nome];
19
- }
20
-
21
- if (this.superClasse !== null) {
22
- return this.superClasse.encontrarMetodo(nome);
23
- }
24
-
25
- return undefined;
26
- }
27
-
28
- toString() {
29
- return `<classe ${this.nome}>`;
30
- }
31
-
32
- aridade() {
33
- let inicializador = this.encontrarMetodo("construtor");
34
- return inicializador ? inicializador.aridade() : 0;
35
- }
36
-
37
- chamar(interpretador: any, argumentos: any) {
38
- let instancia = new DeleguaInstancia(this);
39
-
40
- let inicializador = this.encontrarMetodo("construtor");
41
- if (inicializador) {
42
- inicializador.bind(instancia).call(interpretador, argumentos);
43
- }
44
-
45
- return instancia;
46
- }
47
- }
@@ -1,22 +0,0 @@
1
- import { Callable } from "./callable";
2
-
3
- export class FuncaoPadrao extends Callable {
4
- valorAridade: any;
5
- funcao: any;
6
- simbolo: any;
7
-
8
- constructor(valorAridade, funcao) {
9
- super();
10
- this.valorAridade = valorAridade;
11
- this.funcao = funcao;
12
- }
13
-
14
- chamar(interpretador: any, argumentos: any, simbolo: any) {
15
- this.simbolo = simbolo;
16
- return this.funcao.apply(this, argumentos);
17
- }
18
-
19
- toString() {
20
- return "<função>";
21
- }
22
- }
@@ -1,70 +0,0 @@
1
- import { Callable } from "./callable";
2
- import { Ambiente } from "../ambiente";
3
- import { ReturnException } from "../excecoes";
4
-
5
- export class DeleguaFuncao extends Callable {
6
- nome: any;
7
- declaracao: any;
8
- closure: any;
9
- eInicializador: any;
10
-
11
- constructor(nome: any, declaracao: any, closure: any, eInicializador = false) {
12
- super();
13
- this.nome = nome;
14
- this.declaracao = declaracao;
15
- this.closure = closure;
16
- this.eInicializador = eInicializador;
17
- }
18
-
19
- aridade() {
20
- return this.declaracao?.parametros?.length || 0;
21
- }
22
-
23
- toString() {
24
- if (this.nome === null) return "<função>";
25
- return `<função ${this.nome}>`;
26
- }
27
-
28
- chamar(interpretador: any, argumentos: any) {
29
- let ambiente = new Ambiente(this.closure);
30
- let parametros = this.declaracao.parametros;
31
-
32
- if (parametros && parametros.length) {
33
- for (let i = 0; i < parametros.length; i++) {
34
- const param = parametros[i];
35
-
36
- const nome = param["nome"].lexema;
37
- let valor = argumentos[i];
38
- if (argumentos[i] === null) {
39
- valor = param["padrao"] ? param["padrao"].valor : null;
40
- }
41
- ambiente.definirVariavel(nome, valor);
42
- }
43
- }
44
-
45
- try {
46
- interpretador.executeBlock(this.declaracao.funcao, ambiente);
47
- } catch (erro) {
48
- if (erro instanceof ReturnException) {
49
- if (this.eInicializador) return this.closure.obterVariavelEm(0, "isto");
50
- return erro.valor;
51
- } else {
52
- throw erro;
53
- }
54
- }
55
-
56
- if (this.eInicializador) return this.closure.obterVariavelEm(0, "isto");
57
- return null;
58
- }
59
-
60
- bind(instancia: any) {
61
- let ambiente = new Ambiente(this.closure);
62
- ambiente.definirVariavel("isto", instancia);
63
- return new DeleguaFuncao(
64
- this.nome,
65
- this.declaracao,
66
- ambiente,
67
- this.eInicializador
68
- );
69
- }
70
- }
@@ -1,6 +0,0 @@
1
- export * from "./callable";
2
- export * from "./classe";
3
- export * from "./funcao-padrao";
4
- export * from "./funcao";
5
- export * from "./instancia";
6
- export * from "./modulo";
@@ -1,30 +0,0 @@
1
- import { ErroEmTempoDeExecucao } from "../excecoes";
2
-
3
- export class DeleguaInstancia {
4
- criarClasse: any;
5
- campos: any;
6
-
7
- constructor(criarClasse) {
8
- this.criarClasse = criarClasse;
9
- this.campos = {};
10
- }
11
-
12
- get(nome: any) {
13
- if (this.campos.hasOwnProperty(nome.lexema)) {
14
- return this.campos[nome.lexema];
15
- }
16
-
17
- let metodo = this.criarClasse.encontrarMetodo(nome.lexema);
18
- if (metodo) return metodo.bind(this);
19
-
20
- throw new ErroEmTempoDeExecucao(nome, "Método indefinido não recuperado.");
21
- }
22
-
23
- set(nome: any, valor: any) {
24
- this.campos[nome.lexema] = valor;
25
- }
26
-
27
- toString() {
28
- return "<Objeto " + this.criarClasse.nome + ">";
29
- }
30
- }
@@ -1,11 +0,0 @@
1
- export class DeleguaModulo {
2
- nome: string;
3
-
4
- constructor(nome?: string) {
5
- if (nome) this.nome = nome;
6
- }
7
-
8
- toString() {
9
- return this.nome ? `<modulo ${this.nome}>` : "<modulo>";
10
- }
11
- }
@@ -1 +0,0 @@
1
- export class BreakException extends Error { }
@@ -1 +0,0 @@
1
- export class ContinueException extends Error { }
@@ -1,11 +0,0 @@
1
- export class ErroEmTempoDeExecucao extends Error {
2
- simbolo: any;
3
- mensagem: string;
4
-
5
- constructor(simbolo?: any, mensagem?: string) {
6
- super(mensagem);
7
- this.simbolo = simbolo;
8
- this.mensagem = mensagem;
9
- Object.setPrototypeOf(this, ErroEmTempoDeExecucao.prototype);
10
- }
11
- }
@@ -1,4 +0,0 @@
1
- export * from "./break-exception";
2
- export * from "./continue-exception";
3
- export * from "./erro-em-tempo-de-execucao";
4
- export * from "./return-exception";
@@ -1,10 +0,0 @@
1
-
2
- export class ReturnException extends Error {
3
- valor: any;
4
-
5
- constructor(valor: any) {
6
- super(valor);
7
- this.valor = valor;
8
- Object.setPrototypeOf(this, ReturnException.prototype);
9
- }
10
- }
@@ -1,58 +0,0 @@
1
- import { SimboloInterface } from "./simbolo-interface";
2
-
3
- export interface AvaliadorSintaticoInterface {
4
- simbolos: SimboloInterface[];
5
- Delegua: any;
6
-
7
- atual: number;
8
- ciclos: number;
9
-
10
- sincronizar(): void;
11
- erro(simbolo: any, mensagemDeErro: any): any;
12
- consumir(tipo: any, mensagemDeErro: any): any;
13
- verificar(tipo: any): boolean;
14
- verificarProximo(tipo: any): boolean;
15
- peek(): any;
16
- voltar(): any;
17
- seek(posicao: number): any;
18
- estaNoFinal(): boolean;
19
- avancar(): any;
20
- match(...argumentos: any[]): boolean;
21
- primario(): any;
22
- finalizarChamada(callee: any): any;
23
- chamar(): any;
24
- unario(): any;
25
- exponent(): any;
26
- multiplicar(): any;
27
- adicionar(): any;
28
- bitFill(): any;
29
- bitE(): any;
30
- bitOu(): any;
31
- comparar(): any;
32
- equality(): any;
33
- em(): any;
34
- e(): any;
35
- ou(): any;
36
- atribuir(): any;
37
- expressao(): any;
38
- declaracaoMostrar(): any;
39
- expressionStatement(): any;
40
- block(): any;
41
- declaracaoSe(): any;
42
- whileStatement(): any;
43
- forStatement(): any;
44
- breakStatement(): any;
45
- declaracaoContinue(): any;
46
- declaracaoRetorna(): any;
47
- declaracaoEscolha(): any;
48
- importStatement(): any;
49
- tryStatement(): any;
50
- doStatement(): any;
51
- statement(): any;
52
- declaracaoDeVariavel(): any;
53
- funcao(kind: any): any;
54
- corpoDaFuncao(kind: any): any;
55
- declaracaoDeClasse(): any;
56
- declaracao(): any;
57
- analisar(): any;
58
- }