@designliquido/delegua 0.1.6 → 0.1.10

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 (181) hide show
  1. package/README.md +2 -1
  2. package/bin/package.json +6 -4
  3. package/index.d.ts +1 -0
  4. package/package.json +5 -4
  5. package/src/ambiente.d.ts +11 -0
  6. package/src/avaliador-sintatico/dialetos/egua-classico.d.ts +60 -0
  7. package/src/avaliador-sintatico/dialetos/egua-classico.js +123 -123
  8. package/src/avaliador-sintatico/dialetos/egua-classico.js.map +1 -1
  9. package/src/avaliador-sintatico/dialetos/index.d.ts +1 -0
  10. package/src/avaliador-sintatico/erros-avaliador.d.ts +2 -0
  11. package/src/avaliador-sintatico/{parser-error.js → erros-avaliador.js} +1 -1
  12. package/src/avaliador-sintatico/erros-avaliador.js.map +1 -0
  13. package/src/avaliador-sintatico/index.d.ts +61 -0
  14. package/src/avaliador-sintatico/index.js +135 -137
  15. package/src/avaliador-sintatico/index.js.map +1 -1
  16. package/src/bibliotecas/bibliotecaGlobal.d.ts +1 -0
  17. package/src/bibliotecas/importarBiblioteca.d.ts +2 -0
  18. package/src/construtos/assign-subscript.d.ts +8 -0
  19. package/src/construtos/assign-subscript.js +2 -2
  20. package/src/construtos/assign-subscript.js.map +1 -1
  21. package/src/construtos/atribuir.d.ts +7 -0
  22. package/src/construtos/atribuir.js +2 -2
  23. package/src/construtos/atribuir.js.map +1 -1
  24. package/src/construtos/binario.d.ts +8 -0
  25. package/src/construtos/binario.js +2 -2
  26. package/src/construtos/binario.js.map +1 -1
  27. package/src/construtos/call.d.ts +8 -0
  28. package/src/construtos/call.js +2 -2
  29. package/src/construtos/call.js.map +1 -1
  30. package/src/construtos/conjunto.d.ts +8 -0
  31. package/src/construtos/conjunto.js +2 -2
  32. package/src/construtos/conjunto.js.map +1 -1
  33. package/src/construtos/dicionario.d.ts +7 -0
  34. package/src/construtos/dicionario.js +2 -2
  35. package/src/construtos/dicionario.js.map +1 -1
  36. package/src/construtos/expr.d.ts +3 -0
  37. package/src/construtos/expr.js +1 -1
  38. package/src/construtos/expr.js.map +1 -1
  39. package/src/construtos/funcao.d.ts +7 -0
  40. package/src/construtos/funcao.js +2 -2
  41. package/src/construtos/funcao.js.map +1 -1
  42. package/src/construtos/get.d.ts +7 -0
  43. package/src/construtos/get.js +2 -2
  44. package/src/construtos/get.js.map +1 -1
  45. package/src/construtos/grouping.d.ts +6 -0
  46. package/src/construtos/grouping.js +2 -2
  47. package/src/construtos/grouping.js.map +1 -1
  48. package/src/construtos/index.d.ts +18 -0
  49. package/src/construtos/isto.d.ts +6 -0
  50. package/src/construtos/isto.js +2 -2
  51. package/src/construtos/isto.js.map +1 -1
  52. package/src/construtos/literal.d.ts +6 -0
  53. package/src/construtos/literal.js +2 -2
  54. package/src/construtos/literal.js.map +1 -1
  55. package/src/construtos/logical.d.ts +8 -0
  56. package/src/construtos/logical.js +2 -2
  57. package/src/construtos/logical.js.map +1 -1
  58. package/src/construtos/subscript.d.ts +8 -0
  59. package/src/construtos/subscript.js +2 -2
  60. package/src/construtos/subscript.js.map +1 -1
  61. package/src/construtos/super.d.ts +7 -0
  62. package/src/construtos/super.js +2 -2
  63. package/src/construtos/super.js.map +1 -1
  64. package/src/construtos/unario.d.ts +7 -0
  65. package/src/construtos/unario.js +2 -2
  66. package/src/construtos/unario.js.map +1 -1
  67. package/src/construtos/variavel.d.ts +6 -0
  68. package/src/construtos/variavel.js +2 -2
  69. package/src/construtos/variavel.js.map +1 -1
  70. package/src/construtos/vetor.d.ts +6 -0
  71. package/src/construtos/vetor.js +2 -2
  72. package/src/construtos/vetor.js.map +1 -1
  73. package/src/declaracoes/bloco.d.ts +6 -0
  74. package/src/declaracoes/bloco.js +33 -0
  75. package/src/declaracoes/bloco.js.map +1 -0
  76. package/src/declaracoes/classe.d.ts +8 -0
  77. package/src/declaracoes/classe.js +35 -0
  78. package/src/declaracoes/classe.js.map +1 -0
  79. package/src/declaracoes/continua.d.ts +5 -0
  80. package/src/declaracoes/continua.js +31 -0
  81. package/src/declaracoes/continua.js.map +1 -0
  82. package/src/declaracoes/enquanto.d.ts +7 -0
  83. package/src/declaracoes/enquanto.js +34 -0
  84. package/src/declaracoes/enquanto.js.map +1 -0
  85. package/src/declaracoes/escolha.d.ts +8 -0
  86. package/src/declaracoes/escolha.js +35 -0
  87. package/src/declaracoes/escolha.js.map +1 -0
  88. package/src/declaracoes/escreva.d.ts +6 -0
  89. package/src/declaracoes/escreva.js +33 -0
  90. package/src/declaracoes/escreva.js.map +1 -0
  91. package/src/declaracoes/expressao.d.ts +6 -0
  92. package/src/declaracoes/expressao.js +33 -0
  93. package/src/declaracoes/expressao.js.map +1 -0
  94. package/src/declaracoes/fazer.d.ts +7 -0
  95. package/src/declaracoes/fazer.js +34 -0
  96. package/src/declaracoes/fazer.js.map +1 -0
  97. package/src/declaracoes/funcao.d.ts +7 -0
  98. package/src/declaracoes/funcao.js +34 -0
  99. package/src/declaracoes/funcao.js.map +1 -0
  100. package/src/declaracoes/importar.d.ts +7 -0
  101. package/src/declaracoes/importar.js +34 -0
  102. package/src/declaracoes/importar.js.map +1 -0
  103. package/src/declaracoes/index.d.ts +17 -0
  104. package/src/declaracoes/index.js +27 -246
  105. package/src/declaracoes/index.js.map +1 -1
  106. package/src/declaracoes/para.d.ts +9 -0
  107. package/src/declaracoes/para.js +36 -0
  108. package/src/declaracoes/para.js.map +1 -0
  109. package/src/declaracoes/pausa.d.ts +5 -0
  110. package/src/declaracoes/pausa.js +31 -0
  111. package/src/declaracoes/pausa.js.map +1 -0
  112. package/src/declaracoes/retorna.d.ts +7 -0
  113. package/src/declaracoes/retorna.js +34 -0
  114. package/src/declaracoes/retorna.js.map +1 -0
  115. package/src/declaracoes/se.d.ts +9 -0
  116. package/src/declaracoes/se.js +36 -0
  117. package/src/declaracoes/se.js.map +1 -0
  118. package/src/declaracoes/stmt.d.ts +3 -0
  119. package/src/declaracoes/stmt.js +11 -0
  120. package/src/declaracoes/stmt.js.map +1 -0
  121. package/src/declaracoes/tente.d.ts +9 -0
  122. package/src/declaracoes/tente.js +36 -0
  123. package/src/declaracoes/tente.js.map +1 -0
  124. package/src/declaracoes/var.d.ts +7 -0
  125. package/src/declaracoes/var.js +34 -0
  126. package/src/declaracoes/var.js.map +1 -0
  127. package/src/delegua.d.ts +21 -0
  128. package/src/delegua.js +18 -12
  129. package/src/delegua.js.map +1 -1
  130. package/src/estruturas/callable.d.ts +5 -0
  131. package/src/estruturas/classe.d.ts +11 -0
  132. package/src/estruturas/funcao-padrao.d.ts +9 -0
  133. package/src/estruturas/funcao.d.ts +12 -0
  134. package/src/estruturas/funcao.js +7 -7
  135. package/src/estruturas/funcao.js.map +1 -1
  136. package/src/estruturas/index.d.ts +6 -0
  137. package/src/estruturas/instancia.d.ts +8 -0
  138. package/src/estruturas/modulo.d.ts +5 -0
  139. package/src/excecoes/break-exception.d.ts +2 -0
  140. package/src/excecoes/continue-exception.d.ts +2 -0
  141. package/src/excecoes/erro-em-tempo-de-execucao.d.ts +5 -0
  142. package/src/excecoes/index.d.ts +4 -0
  143. package/src/excecoes/return-exception.d.ts +4 -0
  144. package/src/interfaces/avaliador-sintatico-interface.d.ts +55 -0
  145. package/src/interfaces/index.d.ts +6 -0
  146. package/src/interfaces/interpretador-interface.d.ts +51 -0
  147. package/src/interfaces/lexador-interface.d.ts +23 -0
  148. package/src/interfaces/pilha-interface.d.ts +7 -0
  149. package/src/interfaces/resolvedor-interface.d.ts +48 -0
  150. package/src/interfaces/simbolo-interface.d.ts +6 -0
  151. package/src/interpretador/dialetos/egua-classico.d.ts +58 -0
  152. package/src/interpretador/dialetos/egua-classico.js +64 -68
  153. package/src/interpretador/dialetos/egua-classico.js.map +1 -1
  154. package/src/interpretador/dialetos/index.d.ts +1 -0
  155. package/src/interpretador/index.d.ts +58 -0
  156. package/src/interpretador/index.js +74 -75
  157. package/src/interpretador/index.js.map +1 -1
  158. package/src/lexador/dialetos/egua-classico.d.ts +31 -0
  159. package/src/lexador/dialetos/egua-classico.js +10 -12
  160. package/src/lexador/dialetos/egua-classico.js.map +1 -1
  161. package/src/lexador/dialetos/index.d.ts +1 -0
  162. package/src/lexador/index.d.ts +31 -0
  163. package/src/lexador/index.js +28 -19
  164. package/src/lexador/index.js.map +1 -1
  165. package/src/resolvedor/Pilha.d.ts +9 -0
  166. package/src/resolvedor/Pilha.js +1 -1
  167. package/src/resolvedor/Pilha.js.map +1 -1
  168. package/src/resolvedor/ResolverError.d.ts +4 -0
  169. package/src/resolvedor/dialetos/egua-classico.d.ts +56 -0
  170. package/src/resolvedor/dialetos/egua-classico.js +39 -39
  171. package/src/resolvedor/dialetos/egua-classico.js.map +1 -1
  172. package/src/resolvedor/dialetos/index.d.ts +1 -0
  173. package/src/resolvedor/index.d.ts +56 -0
  174. package/src/resolvedor/index.js +45 -45
  175. package/src/resolvedor/index.js.map +1 -1
  176. package/src/tiposDeSimbolos.d.ts +68 -0
  177. package/src/tiposDeSimbolos.js +8 -7
  178. package/src/tiposDeSimbolos.js.map +1 -1
  179. package/src/avaliador-sintatico/parser-error.js.map +0 -1
  180. package/src/web.js +0 -66
  181. package/src/web.js.map +0 -1
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Parser = void 0;
4
4
  var tiposDeSimbolos_1 = require("../tiposDeSimbolos");
5
5
  var construtos_1 = require("../construtos");
6
+ var erros_avaliador_1 = require("./erros-avaliador");
6
7
  var declaracoes_1 = require("../declaracoes");
7
- var parser_error_1 = require("./parser-error");
8
8
  /**
9
9
  * O avaliador sintático (Parser) é responsável por transformar os símbolos do Lexador em estruturas de alto nível.
10
10
  * Essas estruturas de alto nível são as partes que executam lógica de programação de fato.
@@ -21,10 +21,10 @@ var Parser = /** @class */ (function () {
21
21
  while (!this.estaNoFinal()) {
22
22
  if (this.voltar().tipo === tiposDeSimbolos_1.default.PONTO_E_VIRGULA)
23
23
  return;
24
- switch (this.peek().tipo) {
24
+ switch (this.simboloAtual().tipo) {
25
25
  case tiposDeSimbolos_1.default.CLASSE:
26
26
  case tiposDeSimbolos_1.default.FUNCAO:
27
- case tiposDeSimbolos_1.default.VAR:
27
+ case tiposDeSimbolos_1.default.VARIAVEL:
28
28
  case tiposDeSimbolos_1.default.PARA:
29
29
  case tiposDeSimbolos_1.default.SE:
30
30
  case tiposDeSimbolos_1.default.ENQUANTO:
@@ -37,42 +37,45 @@ var Parser = /** @class */ (function () {
37
37
  };
38
38
  Parser.prototype.erro = function (simbolo, mensagemDeErro) {
39
39
  this.Delegua.erro(simbolo, mensagemDeErro);
40
- return new parser_error_1.ErroAvaliador();
40
+ return new erros_avaliador_1.ErroAvaliador();
41
41
  };
42
42
  Parser.prototype.consumir = function (tipo, mensagemDeErro) {
43
43
  if (this.verificar(tipo))
44
44
  return this.avancar();
45
- else
46
- throw this.erro(this.peek(), mensagemDeErro);
45
+ throw this.erro(this.simboloAtual(), mensagemDeErro);
47
46
  };
48
47
  Parser.prototype.verificar = function (tipo) {
49
48
  if (this.estaNoFinal())
50
49
  return false;
51
- return this.peek().tipo === tipo;
50
+ return this.simboloAtual().tipo === tipo;
52
51
  };
53
52
  Parser.prototype.verificarProximo = function (tipo) {
54
53
  if (this.estaNoFinal())
55
54
  return false;
56
55
  return this.simbolos[this.atual + 1].tipo === tipo;
57
56
  };
58
- Parser.prototype.peek = function () {
57
+ Parser.prototype.simboloAtual = function () {
59
58
  return this.simbolos[this.atual];
60
59
  };
61
60
  Parser.prototype.voltar = function () {
62
61
  return this.simbolos[this.atual - 1];
63
62
  };
64
- Parser.prototype.seek = function (posicao) {
63
+ Parser.prototype.procurar = function (posicao) {
65
64
  return this.simbolos[this.atual + posicao];
66
65
  };
67
66
  Parser.prototype.estaNoFinal = function () {
68
- return this.peek().tipo === tiposDeSimbolos_1.default.EOF;
67
+ var simboloAtual = this.simboloAtual();
68
+ if (simboloAtual && simboloAtual.tipo === tiposDeSimbolos_1.default.PONTO_E_VIRGULA) {
69
+ return true;
70
+ }
71
+ return this.atual === this.simbolos.length;
69
72
  };
70
73
  Parser.prototype.avancar = function () {
71
74
  if (!this.estaNoFinal())
72
75
  this.atual += 1;
73
76
  return this.voltar();
74
77
  };
75
- Parser.prototype.match = function () {
78
+ Parser.prototype.verificarSeSimboloAtualEIgualA = function () {
76
79
  var argumentos = [];
77
80
  for (var _i = 0; _i < arguments.length; _i++) {
78
81
  argumentos[_i] = arguments[_i];
@@ -87,78 +90,78 @@ var Parser = /** @class */ (function () {
87
90
  return false;
88
91
  };
89
92
  Parser.prototype.primario = function () {
90
- if (this.match(tiposDeSimbolos_1.default.SUPER)) {
93
+ if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.SUPER)) {
91
94
  var palavraChave = this.voltar();
92
- this.consumir(tiposDeSimbolos_1.default.DOT, "Esperado '.' após 'super'.");
95
+ this.consumir(tiposDeSimbolos_1.default.PONTO, "Esperado '.' após 'super'.");
93
96
  var metodo = this.consumir(tiposDeSimbolos_1.default.IDENTIFICADOR, "Esperado nome do método da SuperClasse.");
94
97
  return new construtos_1.Super(palavraChave, metodo);
95
98
  }
96
- if (this.match(tiposDeSimbolos_1.default.COLCHETE_ESQUERDO)) {
99
+ if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.COLCHETE_ESQUERDO)) {
97
100
  var valores = [];
98
- if (this.match(tiposDeSimbolos_1.default.COLCHETE_DIREITO)) {
101
+ if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.COLCHETE_DIREITO)) {
99
102
  return new construtos_1.Vetor([]);
100
103
  }
101
- while (!this.match(tiposDeSimbolos_1.default.COLCHETE_DIREITO)) {
104
+ while (!this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.COLCHETE_DIREITO)) {
102
105
  var valor = this.atribuir();
103
106
  valores.push(valor);
104
- if (this.peek().tipo !== tiposDeSimbolos_1.default.COLCHETE_DIREITO) {
105
- this.consumir(tiposDeSimbolos_1.default.COMMA, "Esperado vírgula antes da próxima expressão.");
107
+ if (this.simboloAtual().tipo !== tiposDeSimbolos_1.default.COLCHETE_DIREITO) {
108
+ this.consumir(tiposDeSimbolos_1.default.VIRGULA, "Esperado vírgula antes da próxima expressão.");
106
109
  }
107
110
  }
108
111
  return new construtos_1.Vetor(valores);
109
112
  }
110
- if (this.match(tiposDeSimbolos_1.default.CHAVE_ESQUERDA)) {
113
+ if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.CHAVE_ESQUERDA)) {
111
114
  var chaves = [];
112
115
  var valores = [];
113
- if (this.match(tiposDeSimbolos_1.default.CHAVE_DIREITA)) {
116
+ if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.CHAVE_DIREITA)) {
114
117
  return new construtos_1.Dicionario([], []);
115
118
  }
116
- while (!this.match(tiposDeSimbolos_1.default.CHAVE_DIREITA)) {
119
+ while (!this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.CHAVE_DIREITA)) {
117
120
  var chave = this.atribuir();
118
121
  this.consumir(tiposDeSimbolos_1.default.DOIS_PONTOS, "Esperado ':' entre chave e valor.");
119
122
  var valor = this.atribuir();
120
123
  chaves.push(chave);
121
124
  valores.push(valor);
122
- if (this.peek().tipo !== tiposDeSimbolos_1.default.CHAVE_DIREITA) {
123
- this.consumir(tiposDeSimbolos_1.default.COMMA, "Esperado vírgula antes da próxima expressão.");
125
+ if (this.simboloAtual().tipo !== tiposDeSimbolos_1.default.CHAVE_DIREITA) {
126
+ this.consumir(tiposDeSimbolos_1.default.VIRGULA, "Esperado vírgula antes da próxima expressão.");
124
127
  }
125
128
  }
126
129
  return new construtos_1.Dicionario(chaves, valores);
127
130
  }
128
- if (this.match(tiposDeSimbolos_1.default.FUNCAO))
131
+ if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.FUNCAO))
129
132
  return this.corpoDaFuncao("funcao");
130
- if (this.match(tiposDeSimbolos_1.default.FALSO))
133
+ if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.FALSO))
131
134
  return new construtos_1.Literal(false);
132
- if (this.match(tiposDeSimbolos_1.default.VERDADEIRO))
135
+ if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.VERDADEIRO))
133
136
  return new construtos_1.Literal(true);
134
- if (this.match(tiposDeSimbolos_1.default.NULO))
137
+ if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.NULO))
135
138
  return new construtos_1.Literal(null);
136
- if (this.match(tiposDeSimbolos_1.default.ISTO))
139
+ if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.ISTO))
137
140
  return new construtos_1.Isto(this.voltar());
138
- if (this.match(tiposDeSimbolos_1.default.NUMERO, tiposDeSimbolos_1.default.TEXTO)) {
141
+ if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.NUMERO, tiposDeSimbolos_1.default.TEXTO)) {
139
142
  return new construtos_1.Literal(this.voltar().literal);
140
143
  }
141
- if (this.match(tiposDeSimbolos_1.default.IDENTIFICADOR)) {
144
+ if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.IDENTIFICADOR)) {
142
145
  return new construtos_1.Variavel(this.voltar());
143
146
  }
144
- if (this.match(tiposDeSimbolos_1.default.PARENTESE_ESQUERDO)) {
147
+ if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.PARENTESE_ESQUERDO)) {
145
148
  var expr = this.expressao();
146
149
  this.consumir(tiposDeSimbolos_1.default.PARENTESE_DIREITO, "Esperado ')' após a expressão.");
147
150
  return new construtos_1.Grouping(expr);
148
151
  }
149
- if (this.match(tiposDeSimbolos_1.default.IMPORTAR))
150
- return this.importStatement();
151
- throw this.erro(this.peek(), "Esperado expressão.");
152
+ if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.IMPORTAR))
153
+ return this.declaracaoImportar();
154
+ throw this.erro(this.simboloAtual(), "Esperado expressão.");
152
155
  };
153
156
  Parser.prototype.finalizarChamada = function (callee) {
154
157
  var argumentos = [];
155
158
  if (!this.verificar(tiposDeSimbolos_1.default.PARENTESE_DIREITO)) {
156
159
  do {
157
160
  if (argumentos.length >= 255) {
158
- throw this.erro(this.peek(), "Não pode haver mais de 255 argumentos.");
161
+ throw this.erro(this.simboloAtual(), "Não pode haver mais de 255 argumentos.");
159
162
  }
160
163
  argumentos.push(this.expressao());
161
- } while (this.match(tiposDeSimbolos_1.default.COMMA));
164
+ } while (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.VIRGULA));
162
165
  }
163
166
  var parenteseDireito = this.consumir(tiposDeSimbolos_1.default.PARENTESE_DIREITO, "Esperado ')' após os argumentos.");
164
167
  return new construtos_1.Call(callee, parenteseDireito, argumentos);
@@ -166,14 +169,14 @@ var Parser = /** @class */ (function () {
166
169
  Parser.prototype.chamar = function () {
167
170
  var expr = this.primario();
168
171
  while (true) {
169
- if (this.match(tiposDeSimbolos_1.default.PARENTESE_ESQUERDO)) {
172
+ if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.PARENTESE_ESQUERDO)) {
170
173
  expr = this.finalizarChamada(expr);
171
174
  }
172
- else if (this.match(tiposDeSimbolos_1.default.DOT)) {
175
+ else if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.PONTO)) {
173
176
  var nome = this.consumir(tiposDeSimbolos_1.default.IDENTIFICADOR, "Esperado nome do método após '.'.");
174
177
  expr = new construtos_1.Get(expr, nome);
175
178
  }
176
- else if (this.match(tiposDeSimbolos_1.default.COLCHETE_ESQUERDO)) {
179
+ else if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.COLCHETE_ESQUERDO)) {
177
180
  var indice = this.expressao();
178
181
  var closeBracket = this.consumir(tiposDeSimbolos_1.default.COLCHETE_DIREITO, "Esperado ']' após escrita do indice.");
179
182
  expr = new construtos_1.Subscript(expr, indice, closeBracket);
@@ -185,16 +188,16 @@ var Parser = /** @class */ (function () {
185
188
  return expr;
186
189
  };
187
190
  Parser.prototype.unario = function () {
188
- if (this.match(tiposDeSimbolos_1.default.NEGACAO, tiposDeSimbolos_1.default.SUBTRACAO, tiposDeSimbolos_1.default.BIT_NOT)) {
191
+ if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.NEGACAO, tiposDeSimbolos_1.default.SUBTRACAO, tiposDeSimbolos_1.default.BIT_NOT)) {
189
192
  var operador = this.voltar();
190
193
  var direito = this.unario();
191
194
  return new construtos_1.Unario(operador, direito);
192
195
  }
193
196
  return this.chamar();
194
197
  };
195
- Parser.prototype.exponent = function () {
198
+ Parser.prototype.exponenciacao = function () {
196
199
  var expr = this.unario();
197
- while (this.match(tiposDeSimbolos_1.default.EXPONENCIACAO)) {
200
+ while (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.EXPONENCIACAO)) {
198
201
  var operador = this.voltar();
199
202
  var direito = this.unario();
200
203
  expr = new construtos_1.Binario(expr, operador, direito);
@@ -202,17 +205,17 @@ var Parser = /** @class */ (function () {
202
205
  return expr;
203
206
  };
204
207
  Parser.prototype.multiplicar = function () {
205
- var expr = this.exponent();
206
- while (this.match(tiposDeSimbolos_1.default.DIVISAO, tiposDeSimbolos_1.default.MULTIPLICACAO, tiposDeSimbolos_1.default.MODULO)) {
208
+ var expr = this.exponenciacao();
209
+ while (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.DIVISAO, tiposDeSimbolos_1.default.MULTIPLICACAO, tiposDeSimbolos_1.default.MODULO)) {
207
210
  var operador = this.voltar();
208
- var direito = this.exponent();
211
+ var direito = this.exponenciacao();
209
212
  expr = new construtos_1.Binario(expr, operador, direito);
210
213
  }
211
214
  return expr;
212
215
  };
213
216
  Parser.prototype.adicionar = function () {
214
217
  var expr = this.multiplicar();
215
- while (this.match(tiposDeSimbolos_1.default.SUBTRACAO, tiposDeSimbolos_1.default.ADICAO)) {
218
+ while (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.SUBTRACAO, tiposDeSimbolos_1.default.ADICAO)) {
216
219
  var operador = this.voltar();
217
220
  var direito = this.multiplicar();
218
221
  expr = new construtos_1.Binario(expr, operador, direito);
@@ -221,7 +224,7 @@ var Parser = /** @class */ (function () {
221
224
  };
222
225
  Parser.prototype.bitFill = function () {
223
226
  var expr = this.adicionar();
224
- while (this.match(tiposDeSimbolos_1.default.MENOR_MENOR, tiposDeSimbolos_1.default.MAIOR_MAIOR)) {
227
+ while (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.MENOR_MENOR, tiposDeSimbolos_1.default.MAIOR_MAIOR)) {
225
228
  var operador = this.voltar();
226
229
  var direito = this.adicionar();
227
230
  expr = new construtos_1.Binario(expr, operador, direito);
@@ -230,7 +233,7 @@ var Parser = /** @class */ (function () {
230
233
  };
231
234
  Parser.prototype.bitE = function () {
232
235
  var expr = this.bitFill();
233
- while (this.match(tiposDeSimbolos_1.default.BIT_AND)) {
236
+ while (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.BIT_AND)) {
234
237
  var operador = this.voltar();
235
238
  var direito = this.bitFill();
236
239
  expr = new construtos_1.Binario(expr, operador, direito);
@@ -239,7 +242,7 @@ var Parser = /** @class */ (function () {
239
242
  };
240
243
  Parser.prototype.bitOu = function () {
241
244
  var expr = this.bitE();
242
- while (this.match(tiposDeSimbolos_1.default.BIT_OR, tiposDeSimbolos_1.default.BIT_XOR)) {
245
+ while (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.BIT_OR, tiposDeSimbolos_1.default.BIT_XOR)) {
243
246
  var operador = this.voltar();
244
247
  var direito = this.bitE();
245
248
  expr = new construtos_1.Binario(expr, operador, direito);
@@ -248,16 +251,16 @@ var Parser = /** @class */ (function () {
248
251
  };
249
252
  Parser.prototype.comparar = function () {
250
253
  var expr = this.bitOu();
251
- while (this.match(tiposDeSimbolos_1.default.MAIOR, tiposDeSimbolos_1.default.MAIOR_IGUAL, tiposDeSimbolos_1.default.MENOR, tiposDeSimbolos_1.default.MENOR_IGUAL)) {
254
+ while (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.MAIOR, tiposDeSimbolos_1.default.MAIOR_IGUAL, tiposDeSimbolos_1.default.MENOR, tiposDeSimbolos_1.default.MENOR_IGUAL)) {
252
255
  var operador = this.voltar();
253
256
  var direito = this.bitOu();
254
257
  expr = new construtos_1.Binario(expr, operador, direito);
255
258
  }
256
259
  return expr;
257
260
  };
258
- Parser.prototype.equality = function () {
261
+ Parser.prototype.comparacaoIgualdade = function () {
259
262
  var expr = this.comparar();
260
- while (this.match(tiposDeSimbolos_1.default.DIFERENTE, tiposDeSimbolos_1.default.IGUAL_IGUAL)) {
263
+ while (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.DIFERENTE, tiposDeSimbolos_1.default.IGUAL_IGUAL)) {
261
264
  var operador = this.voltar();
262
265
  var direito = this.comparar();
263
266
  expr = new construtos_1.Binario(expr, operador, direito);
@@ -265,17 +268,17 @@ var Parser = /** @class */ (function () {
265
268
  return expr;
266
269
  };
267
270
  Parser.prototype.em = function () {
268
- var expr = this.equality();
269
- while (this.match(tiposDeSimbolos_1.default.EM)) {
271
+ var expr = this.comparacaoIgualdade();
272
+ while (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.EM)) {
270
273
  var operador = this.voltar();
271
- var direito = this.equality();
274
+ var direito = this.comparacaoIgualdade();
272
275
  expr = new construtos_1.Logical(expr, operador, direito);
273
276
  }
274
277
  return expr;
275
278
  };
276
279
  Parser.prototype.e = function () {
277
280
  var expr = this.em();
278
- while (this.match(tiposDeSimbolos_1.default.E)) {
281
+ while (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.E)) {
279
282
  var operador = this.voltar();
280
283
  var direito = this.em();
281
284
  expr = new construtos_1.Logical(expr, operador, direito);
@@ -284,7 +287,7 @@ var Parser = /** @class */ (function () {
284
287
  };
285
288
  Parser.prototype.ou = function () {
286
289
  var expr = this.e();
287
- while (this.match(tiposDeSimbolos_1.default.OU)) {
290
+ while (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.OU)) {
288
291
  var operador = this.voltar();
289
292
  var direito = this.e();
290
293
  expr = new construtos_1.Logical(expr, operador, direito);
@@ -293,8 +296,8 @@ var Parser = /** @class */ (function () {
293
296
  };
294
297
  Parser.prototype.atribuir = function () {
295
298
  var expr = this.ou();
296
- if (this.match(tiposDeSimbolos_1.default.IGUAL) ||
297
- this.match(tiposDeSimbolos_1.default.MAIS_IGUAL)) {
299
+ if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.IGUAL) ||
300
+ this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.MAIS_IGUAL)) {
298
301
  var igual = this.voltar();
299
302
  var valor = this.atribuir();
300
303
  if (expr instanceof construtos_1.Variavel) {
@@ -319,15 +322,13 @@ var Parser = /** @class */ (function () {
319
322
  this.consumir(tiposDeSimbolos_1.default.PARENTESE_ESQUERDO, "Esperado '(' antes dos valores em escreva.");
320
323
  var valor = this.expressao();
321
324
  this.consumir(tiposDeSimbolos_1.default.PARENTESE_DIREITO, "Esperado ')' após os valores em escreva.");
322
- this.consumir(tiposDeSimbolos_1.default.PONTO_E_VIRGULA, "Esperado ';' após o valor.");
323
325
  return new declaracoes_1.Escreva(valor);
324
326
  };
325
- Parser.prototype.expressionStatement = function () {
327
+ Parser.prototype.declaracaoExpressao = function () {
326
328
  var expr = this.expressao();
327
- this.consumir(tiposDeSimbolos_1.default.PONTO_E_VIRGULA, "Esperado ';' após expressão.");
328
329
  return new declaracoes_1.Expressao(expr);
329
330
  };
330
- Parser.prototype.block = function () {
331
+ Parser.prototype.blocoEscopo = function () {
331
332
  var declaracoes = [];
332
333
  while (!this.verificar(tiposDeSimbolos_1.default.CHAVE_DIREITA) &&
333
334
  !this.estaNoFinal()) {
@@ -340,80 +341,77 @@ var Parser = /** @class */ (function () {
340
341
  this.consumir(tiposDeSimbolos_1.default.PARENTESE_ESQUERDO, "Esperado '(' após 'se'.");
341
342
  var condicao = this.expressao();
342
343
  this.consumir(tiposDeSimbolos_1.default.PARENTESE_DIREITO, "Esperado ')' após condição do se.");
343
- var thenBranch = this.statement();
344
+ var thenBranch = this.resolverDeclaracao();
344
345
  var elifBranches = [];
345
- while (this.match(tiposDeSimbolos_1.default.SENAOSE)) {
346
+ while (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.SENAOSE)) {
346
347
  this.consumir(tiposDeSimbolos_1.default.PARENTESE_ESQUERDO, "Esperado '(' após 'senaose'.");
347
348
  var elifCondition = this.expressao();
348
349
  this.consumir(tiposDeSimbolos_1.default.PARENTESE_DIREITO, "Esperado ')' apóes codição do 'senaose.");
349
- var branch = this.statement();
350
+ var branch = this.resolverDeclaracao();
350
351
  elifBranches.push({
351
352
  condition: elifCondition,
352
353
  branch: branch,
353
354
  });
354
355
  }
355
356
  var elseBranch = null;
356
- if (this.match(tiposDeSimbolos_1.default.SENAO)) {
357
- elseBranch = this.statement();
357
+ if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.SENAO)) {
358
+ elseBranch = this.resolverDeclaracao();
358
359
  }
359
360
  return new declaracoes_1.Se(condicao, thenBranch, elifBranches, elseBranch);
360
361
  };
361
- Parser.prototype.whileStatement = function () {
362
+ Parser.prototype.declaracaoEnquanto = function () {
362
363
  try {
363
364
  this.ciclos += 1;
364
365
  this.consumir(tiposDeSimbolos_1.default.PARENTESE_ESQUERDO, "Esperado '(' após 'enquanto'.");
365
366
  var condicao = this.expressao();
366
367
  this.consumir(tiposDeSimbolos_1.default.PARENTESE_DIREITO, "Esperado ')' após condicional.");
367
- var corpo = this.statement();
368
+ var corpo = this.resolverDeclaracao();
368
369
  return new declaracoes_1.Enquanto(condicao, corpo);
369
370
  }
370
371
  finally {
371
372
  this.ciclos -= 1;
372
373
  }
373
374
  };
374
- Parser.prototype.forStatement = function () {
375
+ Parser.prototype.declaracaoPara = function () {
375
376
  try {
376
377
  this.ciclos += 1;
377
378
  this.consumir(tiposDeSimbolos_1.default.PARENTESE_ESQUERDO, "Esperado '(' após 'para'.");
378
379
  var inicializador = void 0;
379
- if (this.match(tiposDeSimbolos_1.default.PONTO_E_VIRGULA)) {
380
+ if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.PONTO_E_VIRGULA)) {
380
381
  inicializador = null;
381
382
  }
382
- else if (this.match(tiposDeSimbolos_1.default.VAR)) {
383
+ else if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.VARIAVEL)) {
383
384
  inicializador = this.declaracaoDeVariavel();
384
385
  }
385
386
  else {
386
- inicializador = this.expressionStatement();
387
+ inicializador = this.declaracaoExpressao();
387
388
  }
388
389
  var condicao = null;
389
390
  if (!this.verificar(tiposDeSimbolos_1.default.PONTO_E_VIRGULA)) {
390
391
  condicao = this.expressao();
391
392
  }
392
- this.consumir(tiposDeSimbolos_1.default.PONTO_E_VIRGULA, "Esperado ';' após valores da condicional");
393
393
  var incrementar = null;
394
394
  if (!this.verificar(tiposDeSimbolos_1.default.PARENTESE_DIREITO)) {
395
395
  incrementar = this.expressao();
396
396
  }
397
397
  this.consumir(tiposDeSimbolos_1.default.PARENTESE_DIREITO, "Esperado ')' após cláusulas");
398
- var corpo = this.statement();
398
+ var corpo = this.resolverDeclaracao();
399
399
  return new declaracoes_1.Para(inicializador, condicao, incrementar, corpo);
400
400
  }
401
401
  finally {
402
402
  this.ciclos -= 1;
403
403
  }
404
404
  };
405
- Parser.prototype.breakStatement = function () {
405
+ Parser.prototype.declaracaoInterromper = function () {
406
406
  if (this.ciclos < 1) {
407
407
  this.erro(this.voltar(), "'pausa' deve estar dentro de um loop.");
408
408
  }
409
- this.consumir(tiposDeSimbolos_1.default.PONTO_E_VIRGULA, "Esperado ';' após 'pausa'.");
410
409
  return new declaracoes_1.Pausa();
411
410
  };
412
- Parser.prototype.declaracaoContinue = function () {
411
+ Parser.prototype.declaracaoContinua = function () {
413
412
  if (this.ciclos < 1) {
414
413
  this.erro(this.voltar(), "'continua' precisa estar em um laço de repetição.");
415
414
  }
416
- this.consumir(tiposDeSimbolos_1.default.PONTO_E_VIRGULA, "Esperado ';' após 'continua'.");
417
415
  return new declaracoes_1.Continua();
418
416
  };
419
417
  Parser.prototype.declaracaoRetorna = function () {
@@ -422,7 +420,6 @@ var Parser = /** @class */ (function () {
422
420
  if (!this.verificar(tiposDeSimbolos_1.default.PONTO_E_VIRGULA)) {
423
421
  valor = this.expressao();
424
422
  }
425
- this.consumir(tiposDeSimbolos_1.default.PONTO_E_VIRGULA, "Esperado ';' após o retorno.");
426
423
  return new declaracoes_1.Retorna(palavraChave, valor);
427
424
  };
428
425
  Parser.prototype.declaracaoEscolha = function () {
@@ -434,9 +431,9 @@ var Parser = /** @class */ (function () {
434
431
  this.consumir(tiposDeSimbolos_1.default.CHAVE_ESQUERDA, "Esperado '{' antes do escopo do 'escolha'.");
435
432
  var branches = [];
436
433
  var defaultBranch = null;
437
- while (!this.match(tiposDeSimbolos_1.default.CHAVE_DIREITA) &&
434
+ while (!this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.CHAVE_DIREITA) &&
438
435
  !this.estaNoFinal()) {
439
- if (this.match(tiposDeSimbolos_1.default.CASO)) {
436
+ if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.CASO)) {
440
437
  var branchConditions = [this.expressao()];
441
438
  this.consumir(tiposDeSimbolos_1.default.DOIS_PONTOS, "Esperado ':' após o 'caso'.");
442
439
  while (this.verificar(tiposDeSimbolos_1.default.CASO)) {
@@ -446,7 +443,7 @@ var Parser = /** @class */ (function () {
446
443
  }
447
444
  var stmts = [];
448
445
  do {
449
- stmts.push(this.statement());
446
+ stmts.push(this.resolverDeclaracao());
450
447
  } while (!this.verificar(tiposDeSimbolos_1.default.CASO) &&
451
448
  !this.verificar(tiposDeSimbolos_1.default.PADRAO) &&
452
449
  !this.verificar(tiposDeSimbolos_1.default.CHAVE_DIREITA));
@@ -455,13 +452,13 @@ var Parser = /** @class */ (function () {
455
452
  stmts: stmts,
456
453
  });
457
454
  }
458
- else if (this.match(tiposDeSimbolos_1.default.PADRAO)) {
455
+ else if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.PADRAO)) {
459
456
  if (defaultBranch !== null)
460
- throw new parser_error_1.ErroAvaliador("Você só pode ter um 'padrao' em cada declaração de 'escolha'.");
457
+ throw new erros_avaliador_1.ErroAvaliador("Você só pode ter um 'padrao' em cada declaração de 'escolha'.");
461
458
  this.consumir(tiposDeSimbolos_1.default.DOIS_PONTOS, "Esperado ':' após declaração do 'padrao'.");
462
459
  var stmts = [];
463
460
  do {
464
- stmts.push(this.statement());
461
+ stmts.push(this.resolverDeclaracao());
465
462
  } while (!this.verificar(tiposDeSimbolos_1.default.CASO) &&
466
463
  !this.verificar(tiposDeSimbolos_1.default.PADRAO) &&
467
464
  !this.verificar(tiposDeSimbolos_1.default.CHAVE_DIREITA));
@@ -476,36 +473,36 @@ var Parser = /** @class */ (function () {
476
473
  this.ciclos -= 1;
477
474
  }
478
475
  };
479
- Parser.prototype.importStatement = function () {
476
+ Parser.prototype.declaracaoImportar = function () {
480
477
  this.consumir(tiposDeSimbolos_1.default.PARENTESE_ESQUERDO, "Esperado '(' após declaração.");
481
478
  var caminho = this.expressao();
482
479
  var closeBracket = this.consumir(tiposDeSimbolos_1.default.PARENTESE_DIREITO, "Esperado ')' após declaração.");
483
480
  return new declaracoes_1.Importar(caminho, closeBracket);
484
481
  };
485
- Parser.prototype.tryStatement = function () {
482
+ Parser.prototype.declaracaoTentar = function () {
486
483
  this.consumir(tiposDeSimbolos_1.default.CHAVE_ESQUERDA, "Esperado '{' após a declaração 'tente'.");
487
- var tryBlock = this.block();
484
+ var tryBlock = this.blocoEscopo();
488
485
  var catchBlock = null;
489
- if (this.match(tiposDeSimbolos_1.default.PEGUE)) {
486
+ if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.PEGUE)) {
490
487
  this.consumir(tiposDeSimbolos_1.default.CHAVE_ESQUERDA, "Esperado '{' após a declaração 'pegue'.");
491
- catchBlock = this.block();
488
+ catchBlock = this.blocoEscopo();
492
489
  }
493
490
  var elseBlock = null;
494
- if (this.match(tiposDeSimbolos_1.default.SENAO)) {
491
+ if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.SENAO)) {
495
492
  this.consumir(tiposDeSimbolos_1.default.CHAVE_ESQUERDA, "Esperado '{' após a declaração 'pegue'.");
496
- elseBlock = this.block();
493
+ elseBlock = this.blocoEscopo();
497
494
  }
498
495
  var finallyBlock = null;
499
- if (this.match(tiposDeSimbolos_1.default.FINALMENTE)) {
496
+ if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.FINALMENTE)) {
500
497
  this.consumir(tiposDeSimbolos_1.default.CHAVE_ESQUERDA, "Esperado '{' após a declaração 'pegue'.");
501
- finallyBlock = this.block();
498
+ finallyBlock = this.blocoEscopo();
502
499
  }
503
500
  return new declaracoes_1.Tente(tryBlock, catchBlock, elseBlock, finallyBlock);
504
501
  };
505
- Parser.prototype.doStatement = function () {
502
+ Parser.prototype.declaracaoFazer = function () {
506
503
  try {
507
504
  this.ciclos += 1;
508
- var doBranch = this.statement();
505
+ var doBranch = this.resolverDeclaracao();
509
506
  this.consumir(tiposDeSimbolos_1.default.ENQUANTO, "Esperado declaração do 'enquanto' após o escopo do 'fazer'.");
510
507
  this.consumir(tiposDeSimbolos_1.default.PARENTESE_ESQUERDO, "Esperado '(' após declaração 'enquanto'.");
511
508
  var whileCondition = this.expressao();
@@ -516,55 +513,54 @@ var Parser = /** @class */ (function () {
516
513
  this.ciclos -= 1;
517
514
  }
518
515
  };
519
- Parser.prototype.statement = function () {
520
- if (this.match(tiposDeSimbolos_1.default.FAZER))
521
- return this.doStatement();
522
- if (this.match(tiposDeSimbolos_1.default.TENTE))
523
- return this.tryStatement();
524
- if (this.match(tiposDeSimbolos_1.default.ESCOLHA))
516
+ Parser.prototype.resolverDeclaracao = function () {
517
+ if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.FAZER))
518
+ return this.declaracaoFazer();
519
+ if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.TENTE))
520
+ return this.declaracaoTentar();
521
+ if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.ESCOLHA))
525
522
  return this.declaracaoEscolha();
526
- if (this.match(tiposDeSimbolos_1.default.RETORNA))
523
+ if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.RETORNA))
527
524
  return this.declaracaoRetorna();
528
- if (this.match(tiposDeSimbolos_1.default.CONTINUA))
529
- return this.declaracaoContinue();
530
- if (this.match(tiposDeSimbolos_1.default.PAUSA))
531
- return this.breakStatement();
532
- if (this.match(tiposDeSimbolos_1.default.PARA))
533
- return this.forStatement();
534
- if (this.match(tiposDeSimbolos_1.default.ENQUANTO))
535
- return this.whileStatement();
536
- if (this.match(tiposDeSimbolos_1.default.SE))
525
+ if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.CONTINUA))
526
+ return this.declaracaoContinua();
527
+ if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.PAUSA))
528
+ return this.declaracaoInterromper();
529
+ if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.PARA))
530
+ return this.declaracaoPara();
531
+ if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.ENQUANTO))
532
+ return this.declaracaoEnquanto();
533
+ if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.SE))
537
534
  return this.declaracaoSe();
538
- if (this.match(tiposDeSimbolos_1.default.ESCREVA))
535
+ if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.ESCREVA))
539
536
  return this.declaracaoMostrar();
540
- if (this.match(tiposDeSimbolos_1.default.CHAVE_ESQUERDA))
541
- return new declaracoes_1.Block(this.block());
542
- return this.expressionStatement();
537
+ if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.CHAVE_ESQUERDA))
538
+ return new declaracoes_1.Bloco(this.blocoEscopo());
539
+ return this.declaracaoExpressao();
543
540
  };
544
541
  Parser.prototype.declaracaoDeVariavel = function () {
545
542
  var nome = this.consumir(tiposDeSimbolos_1.default.IDENTIFICADOR, "Esperado nome de variável.");
546
543
  var inicializador = null;
547
- if (this.match(tiposDeSimbolos_1.default.IGUAL) ||
548
- this.match(tiposDeSimbolos_1.default.MAIS_IGUAL)) {
544
+ if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.IGUAL) ||
545
+ this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.MAIS_IGUAL)) {
549
546
  inicializador = this.expressao();
550
547
  }
551
- this.consumir(tiposDeSimbolos_1.default.PONTO_E_VIRGULA, "Esperado ';' após a declaração da variável.");
552
548
  return new declaracoes_1.Var(nome, inicializador);
553
549
  };
554
- Parser.prototype.funcao = function (kind) {
555
- var nome = this.consumir(tiposDeSimbolos_1.default.IDENTIFICADOR, "Esperado nome ".concat(kind, "."));
556
- return new declaracoes_1.Funcao(nome, this.corpoDaFuncao(kind));
550
+ Parser.prototype.funcao = function (tipo) {
551
+ var nome = this.consumir(tiposDeSimbolos_1.default.IDENTIFICADOR, "Esperado nome ".concat(tipo, "."));
552
+ return new declaracoes_1.Funcao(nome, this.corpoDaFuncao(tipo));
557
553
  };
558
- Parser.prototype.corpoDaFuncao = function (kind) {
559
- this.consumir(tiposDeSimbolos_1.default.PARENTESE_ESQUERDO, "Esperado '(' ap\u00F3s o nome ".concat(kind, "."));
554
+ Parser.prototype.corpoDaFuncao = function (tipo) {
555
+ this.consumir(tiposDeSimbolos_1.default.PARENTESE_ESQUERDO, "Esperado '(' ap\u00F3s o nome ".concat(tipo, "."));
560
556
  var parametros = [];
561
557
  if (!this.verificar(tiposDeSimbolos_1.default.PARENTESE_DIREITO)) {
562
558
  do {
563
559
  if (parametros.length >= 255) {
564
- this.erro(this.peek(), "Não pode haver mais de 255 parâmetros");
560
+ this.erro(this.simboloAtual(), "Não pode haver mais de 255 parâmetros");
565
561
  }
566
562
  var paramObj = {};
567
- if (this.peek().tipo === tiposDeSimbolos_1.default.MULTIPLICACAO) {
563
+ if (this.simboloAtual().tipo === tiposDeSimbolos_1.default.MULTIPLICACAO) {
568
564
  this.consumir(tiposDeSimbolos_1.default.MULTIPLICACAO, null);
569
565
  paramObj["tipo"] = "wildcard";
570
566
  }
@@ -572,23 +568,23 @@ var Parser = /** @class */ (function () {
572
568
  paramObj["tipo"] = "standard";
573
569
  }
574
570
  paramObj["nome"] = this.consumir(tiposDeSimbolos_1.default.IDENTIFICADOR, "Esperado nome do parâmetro.");
575
- if (this.match(tiposDeSimbolos_1.default.IGUAL)) {
571
+ if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.IGUAL)) {
576
572
  paramObj["default"] = this.primario();
577
573
  }
578
574
  parametros.push(paramObj);
579
575
  if (paramObj["tipo"] === "wildcard")
580
576
  break;
581
- } while (this.match(tiposDeSimbolos_1.default.COMMA));
577
+ } while (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.VIRGULA));
582
578
  }
583
579
  this.consumir(tiposDeSimbolos_1.default.PARENTESE_DIREITO, "Esperado ')' após parâmetros.");
584
- this.consumir(tiposDeSimbolos_1.default.CHAVE_ESQUERDA, "Esperado '{' antes do escopo do ".concat(kind, "."));
585
- var corpo = this.block();
586
- return new declaracoes_1.Funcao(parametros, corpo);
580
+ this.consumir(tiposDeSimbolos_1.default.CHAVE_ESQUERDA, "Esperado '{' antes do escopo do ".concat(tipo, "."));
581
+ var corpo = this.blocoEscopo();
582
+ return new construtos_1.Funcao(parametros, corpo);
587
583
  };
588
584
  Parser.prototype.declaracaoDeClasse = function () {
589
585
  var nome = this.consumir(tiposDeSimbolos_1.default.IDENTIFICADOR, "Esperado nome da classe.");
590
586
  var superClasse = null;
591
- if (this.match(tiposDeSimbolos_1.default.HERDA)) {
587
+ if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.HERDA)) {
592
588
  this.consumir(tiposDeSimbolos_1.default.IDENTIFICADOR, "Esperado nome da SuperClasse.");
593
589
  superClasse = new construtos_1.Variavel(this.voltar());
594
590
  }
@@ -608,11 +604,11 @@ var Parser = /** @class */ (function () {
608
604
  this.consumir(tiposDeSimbolos_1.default.FUNCAO, null);
609
605
  return this.funcao("funcao");
610
606
  }
611
- if (this.match(tiposDeSimbolos_1.default.VAR))
607
+ if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.VARIAVEL))
612
608
  return this.declaracaoDeVariavel();
613
- if (this.match(tiposDeSimbolos_1.default.CLASSE))
609
+ if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.CLASSE))
614
610
  return this.declaracaoDeClasse();
615
- return this.statement();
611
+ return this.resolverDeclaracao();
616
612
  }
617
613
  catch (erro) {
618
614
  this.sincronizar();
@@ -620,6 +616,8 @@ var Parser = /** @class */ (function () {
620
616
  }
621
617
  };
622
618
  Parser.prototype.analisar = function (simbolos) {
619
+ this.atual = 0;
620
+ this.ciclos = 0;
623
621
  if (simbolos) {
624
622
  this.simbolos = simbolos;
625
623
  }