@designliquido/potigol 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/avaliador-sintatico/avaliador-sintatico-potigol.d.ts +137 -124
- package/avaliador-sintatico/avaliador-sintatico-potigol.d.ts.map +1 -1
- package/avaliador-sintatico/avaliador-sintatico-potigol.js +725 -709
- package/avaliador-sintatico/avaliador-sintatico-potigol.js.map +1 -1
- package/avaliador-sintatico/index.d.ts +1 -1
- package/avaliador-sintatico/index.js +17 -17
- package/avaliador-sintatico/micro-avaliador-sintatico-potigol.d.ts +20 -12
- package/avaliador-sintatico/micro-avaliador-sintatico-potigol.d.ts.map +1 -1
- package/avaliador-sintatico/micro-avaliador-sintatico-potigol.js +96 -72
- package/avaliador-sintatico/micro-avaliador-sintatico-potigol.js.map +1 -1
- package/bibliotecas/biblioteca-global.d.ts +3 -3
- package/bibliotecas/biblioteca-global.js +43 -43
- package/bibliotecas/index.d.ts +4 -4
- package/bibliotecas/index.js +20 -20
- package/bibliotecas/primitivas-numero.d.ts +13 -12
- package/bibliotecas/primitivas-numero.d.ts.map +1 -1
- package/bibliotecas/primitivas-numero.js +20 -12
- package/bibliotecas/primitivas-numero.js.map +1 -1
- package/bibliotecas/primitivas-texto.d.ts +28 -28
- package/bibliotecas/primitivas-texto.js +36 -36
- package/bibliotecas/primitivas-vetor.d.ts +26 -26
- package/bibliotecas/primitivas-vetor.js +48 -48
- package/bibliotecas/primitivas-vetor.js.map +1 -1
- package/formatador/formatador-potigol.d.ts +81 -81
- package/formatador/formatador-potigol.js +661 -661
- package/formatador/formatador-potigol.js.map +1 -1
- package/formatador/index.d.ts +1 -1
- package/formatador/index.js +17 -17
- package/index.d.ts +5 -5
- package/index.js +23 -23
- package/interfaces/index.d.ts +1 -1
- package/interfaces/index.js +17 -17
- package/interfaces/interpretador-interface-potigol.d.ts +5 -5
- package/interfaces/interpretador-interface-potigol.js +2 -2
- package/interpretador/comum.d.ts +25 -25
- package/interpretador/comum.d.ts.map +1 -1
- package/interpretador/comum.js +178 -176
- package/interpretador/comum.js.map +1 -1
- package/interpretador/index.d.ts +2 -2
- package/interpretador/index.js +18 -18
- package/interpretador/inferenciador.d.ts +1 -1
- package/interpretador/inferenciador.js +33 -33
- package/interpretador/inferenciador.js.map +1 -1
- package/interpretador/interpretador-potigol-com-depuracao.d.ts +12 -12
- package/interpretador/interpretador-potigol-com-depuracao.js +56 -56
- package/interpretador/interpretador-potigol.d.ts +17 -17
- package/interpretador/interpretador-potigol.d.ts.map +1 -1
- package/interpretador/interpretador-potigol.js +85 -81
- package/interpretador/interpretador-potigol.js.map +1 -1
- package/lexador/index.d.ts +3 -2
- package/lexador/index.d.ts.map +1 -1
- package/lexador/index.js +19 -18
- package/lexador/index.js.map +1 -1
- package/lexador/lexador-potigol.d.ts +19 -17
- package/lexador/lexador-potigol.d.ts.map +1 -1
- package/lexador/lexador-potigol.js +304 -294
- package/lexador/lexador-potigol.js.map +1 -1
- package/lexador/micro-lexador-potigol.d.ts +29 -0
- package/lexador/micro-lexador-potigol.d.ts.map +1 -0
- package/lexador/micro-lexador-potigol.js +196 -0
- package/lexador/micro-lexador-potigol.js.map +1 -0
- package/lexador/palavras-reservadas.d.ts +45 -44
- package/lexador/palavras-reservadas.d.ts.map +1 -1
- package/lexador/palavras-reservadas.js +52 -51
- package/lexador/palavras-reservadas.js.map +1 -1
- package/package.json +2 -2
- package/tipos-de-simbolos/lexico-regular.d.ts +66 -65
- package/tipos-de-simbolos/lexico-regular.d.ts.map +1 -1
- package/tipos-de-simbolos/lexico-regular.js +67 -66
- package/tipos-de-simbolos/lexico-regular.js.map +1 -1
- package/tipos-de-simbolos/micro-lexico.d.ts +42 -0
- package/tipos-de-simbolos/micro-lexico.d.ts.map +1 -0
- package/tipos-de-simbolos/micro-lexico.js +43 -0
- package/tipos-de-simbolos/micro-lexico.js.map +1 -0
|
@@ -1,295 +1,305 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.LexadorPotigol = void 0;
|
|
7
|
-
const lexador_base_linha_unica_1 = require("@designliquido/delegua/lexador/lexador-base-linha-unica");
|
|
8
|
-
const palavras_reservadas_1 = require("./palavras-reservadas");
|
|
9
|
-
const lexico_regular_1 = __importDefault(require("../tipos-de-simbolos/lexico-regular"));
|
|
10
|
-
/**
|
|
11
|
-
* Lexador para o dialeto Potigol.
|
|
12
|
-
* Este dialeto é sensível a tamanho de caixa. `Inteiro` é aceito. `inteiro` não.
|
|
13
|
-
*/
|
|
14
|
-
class LexadorPotigol extends lexador_base_linha_unica_1.LexadorBaseLinhaUnica {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
this.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
this.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
this.adicionarSimbolo(
|
|
89
|
-
this.avancar();
|
|
90
|
-
break;
|
|
91
|
-
case '
|
|
92
|
-
this.adicionarSimbolo(
|
|
93
|
-
this.avancar();
|
|
94
|
-
break;
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
this.
|
|
108
|
-
this.
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
this.adicionarSimbolo(lexico_regular_1.default.
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
this.
|
|
132
|
-
|
|
133
|
-
this.
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
this.
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
break;
|
|
152
|
-
case '
|
|
153
|
-
this.inicioSimbolo = this.atual;
|
|
154
|
-
this.avancar();
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
case '
|
|
183
|
-
this.adicionarSimbolo(tiposDeSimbolos.
|
|
184
|
-
this.avancar();
|
|
185
|
-
break;
|
|
186
|
-
|
|
187
|
-
case '
|
|
188
|
-
this.
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
}
|
|
212
|
-
break;
|
|
213
|
-
case '
|
|
214
|
-
this.
|
|
215
|
-
this.
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
break;
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
case '
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
this.
|
|
254
|
-
this.avancar();
|
|
255
|
-
break;
|
|
256
|
-
case '
|
|
257
|
-
this.
|
|
258
|
-
this.
|
|
259
|
-
this.
|
|
260
|
-
break;
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.LexadorPotigol = void 0;
|
|
7
|
+
const lexador_base_linha_unica_1 = require("@designliquido/delegua/lexador/lexador-base-linha-unica");
|
|
8
|
+
const palavras_reservadas_1 = require("./palavras-reservadas");
|
|
9
|
+
const lexico_regular_1 = __importDefault(require("../tipos-de-simbolos/lexico-regular"));
|
|
10
|
+
/**
|
|
11
|
+
* Lexador para o dialeto Potigol.
|
|
12
|
+
* Este dialeto é sensível a tamanho de caixa. `Inteiro` é aceito. `inteiro` não.
|
|
13
|
+
*/
|
|
14
|
+
class LexadorPotigol extends lexador_base_linha_unica_1.LexadorBaseLinhaUnica {
|
|
15
|
+
constructor() {
|
|
16
|
+
super();
|
|
17
|
+
this.chaveEmTexto = false;
|
|
18
|
+
}
|
|
19
|
+
logicaComumCaracteres(delimitador) {
|
|
20
|
+
while ((this.chaveEmTexto || this.simboloAtual() !== delimitador) && !this.eFinalDoCodigo()) {
|
|
21
|
+
if (this.codigo.charAt(this.atual) === '{') {
|
|
22
|
+
this.chaveEmTexto = true;
|
|
23
|
+
}
|
|
24
|
+
if (this.codigo.charAt(this.atual) === '}') {
|
|
25
|
+
this.chaveEmTexto = false;
|
|
26
|
+
}
|
|
27
|
+
this.avancar();
|
|
28
|
+
}
|
|
29
|
+
if (this.eFinalDoCodigo()) {
|
|
30
|
+
this.erros.push({
|
|
31
|
+
linha: this.linha + 1,
|
|
32
|
+
caractere: this.simboloAnterior(),
|
|
33
|
+
mensagem: 'Cadeia de caracteres não finalizada.',
|
|
34
|
+
});
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const valor = this.codigo.substring(this.inicioSimbolo + 1, this.atual);
|
|
38
|
+
return valor;
|
|
39
|
+
}
|
|
40
|
+
analisarCaracter() {
|
|
41
|
+
const valor = this.logicaComumCaracteres("'");
|
|
42
|
+
this.adicionarSimbolo(lexico_regular_1.default.CARACTERE, valor);
|
|
43
|
+
}
|
|
44
|
+
analisarTexto() {
|
|
45
|
+
const valor = this.logicaComumCaracteres('"');
|
|
46
|
+
this.adicionarSimbolo(lexico_regular_1.default.TEXTO, valor);
|
|
47
|
+
}
|
|
48
|
+
analisarNumero() {
|
|
49
|
+
let real = false;
|
|
50
|
+
while (this.eDigito(this.simboloAtual())) {
|
|
51
|
+
this.avancar();
|
|
52
|
+
}
|
|
53
|
+
if (this.simboloAtual() == '.' && this.eDigito(this.proximoSimbolo())) {
|
|
54
|
+
real = true;
|
|
55
|
+
this.avancar();
|
|
56
|
+
while (this.eDigito(this.simboloAtual())) {
|
|
57
|
+
this.avancar();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const numeroCompleto = this.codigo.substring(this.inicioSimbolo, this.atual);
|
|
61
|
+
this.adicionarSimbolo(real ? lexico_regular_1.default.REAL : lexico_regular_1.default.INTEIRO, parseFloat(numeroCompleto));
|
|
62
|
+
}
|
|
63
|
+
avancarParaProximaLinha() {
|
|
64
|
+
while (this.codigo[this.atual] !== '\n') {
|
|
65
|
+
this.atual++;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
identificarPalavraChave() {
|
|
69
|
+
while (this.eAlfabetoOuDigito(this.simboloAtual())) {
|
|
70
|
+
this.avancar();
|
|
71
|
+
}
|
|
72
|
+
const codigo = this.codigo.substring(this.inicioSimbolo, this.atual);
|
|
73
|
+
const tipo = codigo in palavras_reservadas_1.palavrasReservadas ? palavras_reservadas_1.palavrasReservadas[codigo] : lexico_regular_1.default.IDENTIFICADOR;
|
|
74
|
+
this.adicionarSimbolo(tipo);
|
|
75
|
+
}
|
|
76
|
+
analisarToken() {
|
|
77
|
+
const caractere = this.simboloAtual();
|
|
78
|
+
switch (caractere) {
|
|
79
|
+
case '[':
|
|
80
|
+
this.adicionarSimbolo(lexico_regular_1.default.COLCHETE_ESQUERDO);
|
|
81
|
+
this.avancar();
|
|
82
|
+
break;
|
|
83
|
+
case ']':
|
|
84
|
+
this.adicionarSimbolo(lexico_regular_1.default.COLCHETE_DIREITO);
|
|
85
|
+
this.avancar();
|
|
86
|
+
break;
|
|
87
|
+
case '(':
|
|
88
|
+
this.adicionarSimbolo(lexico_regular_1.default.PARENTESE_ESQUERDO);
|
|
89
|
+
this.avancar();
|
|
90
|
+
break;
|
|
91
|
+
case ')':
|
|
92
|
+
this.adicionarSimbolo(lexico_regular_1.default.PARENTESE_DIREITO);
|
|
93
|
+
this.avancar();
|
|
94
|
+
break;
|
|
95
|
+
// Até então encontradas apenas em interpolações de texto.
|
|
96
|
+
// Por ora não necessárias.
|
|
97
|
+
/* case '{':
|
|
98
|
+
this.adicionarSimbolo(tiposDeSimbolos.CHAVE_ESQUERDA);
|
|
99
|
+
this.avancar();
|
|
100
|
+
break;
|
|
101
|
+
case '}':
|
|
102
|
+
this.adicionarSimbolo(tiposDeSimbolos.CHAVE_DIREITA);
|
|
103
|
+
this.avancar();
|
|
104
|
+
break; */
|
|
105
|
+
case ':':
|
|
106
|
+
this.inicioSimbolo = this.atual;
|
|
107
|
+
this.avancar();
|
|
108
|
+
if (this.simboloAtual() === '=') {
|
|
109
|
+
this.adicionarSimbolo(lexico_regular_1.default.REATRIBUIR);
|
|
110
|
+
this.avancar();
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
this.adicionarSimbolo(lexico_regular_1.default.DOIS_PONTOS);
|
|
114
|
+
}
|
|
115
|
+
break;
|
|
116
|
+
case ',':
|
|
117
|
+
this.adicionarSimbolo(lexico_regular_1.default.VIRGULA);
|
|
118
|
+
this.avancar();
|
|
119
|
+
break;
|
|
120
|
+
case '.':
|
|
121
|
+
this.adicionarSimbolo(lexico_regular_1.default.PONTO);
|
|
122
|
+
this.avancar();
|
|
123
|
+
break;
|
|
124
|
+
case '-':
|
|
125
|
+
this.inicioSimbolo = this.atual;
|
|
126
|
+
this.avancar();
|
|
127
|
+
this.adicionarSimbolo(lexico_regular_1.default.SUBTRACAO);
|
|
128
|
+
/* if (this.simboloAtual() === '=') {
|
|
129
|
+
this.adicionarSimbolo(tiposDeSimbolos.MENOS_IGUAL);
|
|
130
|
+
this.avancar();
|
|
131
|
+
} else if (this.simboloAtual() === '-') {
|
|
132
|
+
this.adicionarSimbolo(tiposDeSimbolos.DECREMENTAR);
|
|
133
|
+
this.avancar();
|
|
134
|
+
} else {
|
|
135
|
+
this.adicionarSimbolo(tiposDeSimbolos.SUBTRACAO);
|
|
136
|
+
} */
|
|
137
|
+
break;
|
|
138
|
+
case '+':
|
|
139
|
+
this.inicioSimbolo = this.atual;
|
|
140
|
+
this.avancar();
|
|
141
|
+
this.adicionarSimbolo(lexico_regular_1.default.ADICAO);
|
|
142
|
+
/* if (this.simboloAtual() === '=') {
|
|
143
|
+
this.adicionarSimbolo(tiposDeSimbolos.MAIS_IGUAL);
|
|
144
|
+
this.avancar();
|
|
145
|
+
} else if (this.simboloAtual() === '+') {
|
|
146
|
+
this.adicionarSimbolo(tiposDeSimbolos.INCREMENTAR);
|
|
147
|
+
this.avancar();
|
|
148
|
+
} else {
|
|
149
|
+
this.adicionarSimbolo(tiposDeSimbolos.ADICAO);
|
|
150
|
+
} */
|
|
151
|
+
break;
|
|
152
|
+
case '*':
|
|
153
|
+
this.inicioSimbolo = this.atual;
|
|
154
|
+
this.avancar();
|
|
155
|
+
this.adicionarSimbolo(lexico_regular_1.default.MULTIPLICACAO);
|
|
156
|
+
break;
|
|
157
|
+
case '^':
|
|
158
|
+
this.inicioSimbolo = this.atual;
|
|
159
|
+
this.avancar();
|
|
160
|
+
this.adicionarSimbolo(lexico_regular_1.default.EXPONENCIACAO);
|
|
161
|
+
break;
|
|
162
|
+
case '=':
|
|
163
|
+
this.inicioSimbolo = this.atual;
|
|
164
|
+
this.avancar();
|
|
165
|
+
switch (this.simboloAtual()) {
|
|
166
|
+
case '=':
|
|
167
|
+
this.adicionarSimbolo(lexico_regular_1.default.IGUAL_IGUAL);
|
|
168
|
+
this.avancar();
|
|
169
|
+
break;
|
|
170
|
+
case '>':
|
|
171
|
+
this.adicionarSimbolo(lexico_regular_1.default.SETA);
|
|
172
|
+
this.avancar();
|
|
173
|
+
break;
|
|
174
|
+
default:
|
|
175
|
+
this.adicionarSimbolo(lexico_regular_1.default.IGUAL);
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
break;
|
|
179
|
+
case '#':
|
|
180
|
+
this.avancarParaProximaLinha();
|
|
181
|
+
break;
|
|
182
|
+
/* case '&':
|
|
183
|
+
this.adicionarSimbolo(tiposDeSimbolos.BIT_AND);
|
|
184
|
+
this.avancar();
|
|
185
|
+
break;
|
|
186
|
+
|
|
187
|
+
case '~':
|
|
188
|
+
this.adicionarSimbolo(tiposDeSimbolos.BIT_NOT);
|
|
189
|
+
this.avancar();
|
|
190
|
+
break;
|
|
191
|
+
|
|
192
|
+
case '|':
|
|
193
|
+
this.adicionarSimbolo(tiposDeSimbolos.BIT_OR);
|
|
194
|
+
this.avancar();
|
|
195
|
+
break;
|
|
196
|
+
*/
|
|
197
|
+
case '<':
|
|
198
|
+
this.avancar();
|
|
199
|
+
switch (this.simboloAtual()) {
|
|
200
|
+
case '=':
|
|
201
|
+
this.adicionarSimbolo(lexico_regular_1.default.MENOR_IGUAL);
|
|
202
|
+
this.avancar();
|
|
203
|
+
break;
|
|
204
|
+
case '>':
|
|
205
|
+
this.adicionarSimbolo(lexico_regular_1.default.DIFERENTE);
|
|
206
|
+
this.avancar();
|
|
207
|
+
break;
|
|
208
|
+
default:
|
|
209
|
+
this.adicionarSimbolo(lexico_regular_1.default.MENOR);
|
|
210
|
+
break;
|
|
211
|
+
}
|
|
212
|
+
break;
|
|
213
|
+
case '>':
|
|
214
|
+
this.avancar();
|
|
215
|
+
if (this.simboloAtual() === '=') {
|
|
216
|
+
this.adicionarSimbolo(lexico_regular_1.default.MAIOR_IGUAL);
|
|
217
|
+
this.avancar();
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
this.adicionarSimbolo(lexico_regular_1.default.MAIOR);
|
|
221
|
+
}
|
|
222
|
+
break;
|
|
223
|
+
case '/':
|
|
224
|
+
this.inicioSimbolo = this.atual;
|
|
225
|
+
this.avancar();
|
|
226
|
+
this.adicionarSimbolo(lexico_regular_1.default.DIVISAO);
|
|
227
|
+
/* switch (this.simboloAtual()) {
|
|
228
|
+
case '/':
|
|
229
|
+
this.avancarParaProximaLinha();
|
|
230
|
+
break;
|
|
231
|
+
case '*':
|
|
232
|
+
this.encontrarFimComentarioAsterisco();
|
|
233
|
+
break;
|
|
234
|
+
case '=':
|
|
235
|
+
this.adicionarSimbolo(tiposDeSimbolos.DIVISAO_IGUAL);
|
|
236
|
+
this.avancar();s
|
|
237
|
+
break;
|
|
238
|
+
default:
|
|
239
|
+
|
|
240
|
+
break;
|
|
241
|
+
} */
|
|
242
|
+
break;
|
|
243
|
+
// Esta sessão ignora espaços em branco na tokenização.
|
|
244
|
+
// Ponto-e-vírgula é opcional em Delégua, então pode apenas ser ignorado.
|
|
245
|
+
case ' ':
|
|
246
|
+
case '\0':
|
|
247
|
+
case '\r':
|
|
248
|
+
case '\t':
|
|
249
|
+
case ';':
|
|
250
|
+
this.avancar();
|
|
251
|
+
break;
|
|
252
|
+
case '\n':
|
|
253
|
+
this.linha++;
|
|
254
|
+
this.avancar();
|
|
255
|
+
break;
|
|
256
|
+
case '"':
|
|
257
|
+
this.avancar();
|
|
258
|
+
this.analisarTexto();
|
|
259
|
+
this.avancar();
|
|
260
|
+
break;
|
|
261
|
+
case "'":
|
|
262
|
+
this.avancar();
|
|
263
|
+
this.analisarCaracter();
|
|
264
|
+
this.avancar();
|
|
265
|
+
break;
|
|
266
|
+
case '_':
|
|
267
|
+
this.inicioSimbolo = this.atual;
|
|
268
|
+
this.avancar();
|
|
269
|
+
this.adicionarSimbolo(lexico_regular_1.default.TRACO_BAIXO);
|
|
270
|
+
break;
|
|
271
|
+
default:
|
|
272
|
+
if (this.eDigito(caractere))
|
|
273
|
+
this.analisarNumero();
|
|
274
|
+
else if (this.eAlfabeto(caractere))
|
|
275
|
+
this.identificarPalavraChave();
|
|
276
|
+
else {
|
|
277
|
+
this.erros.push({
|
|
278
|
+
linha: this.linha + 1,
|
|
279
|
+
caractere: caractere,
|
|
280
|
+
mensagem: 'Caractere inesperado.',
|
|
281
|
+
});
|
|
282
|
+
this.avancar();
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
mapear(codigo, hashArquivo) {
|
|
287
|
+
this.erros = [];
|
|
288
|
+
this.simbolos = [];
|
|
289
|
+
this.inicioSimbolo = 0;
|
|
290
|
+
this.atual = 0;
|
|
291
|
+
this.linha = 0;
|
|
292
|
+
this.codigo = codigo.join('\n') || '';
|
|
293
|
+
this.hashArquivo = hashArquivo;
|
|
294
|
+
while (!this.eFinalDoCodigo()) {
|
|
295
|
+
this.inicioSimbolo = this.atual;
|
|
296
|
+
this.analisarToken();
|
|
297
|
+
}
|
|
298
|
+
return {
|
|
299
|
+
simbolos: this.simbolos,
|
|
300
|
+
erros: this.erros,
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
exports.LexadorPotigol = LexadorPotigol;
|
|
295
305
|
//# sourceMappingURL=lexador-potigol.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lexador-potigol.js","sourceRoot":"","sources":["../../fontes/lexador/lexador-potigol.ts"],"names":[],"mappings":";;;;;;AAEA,sGAAgG;AAGhG,+DAA2D;AAC3D,yFAAkE;AAElE;;;GAGG;AACH,MAAa,cAAe,SAAQ,gDAAqB;
|
|
1
|
+
{"version":3,"file":"lexador-potigol.js","sourceRoot":"","sources":["../../fontes/lexador/lexador-potigol.ts"],"names":[],"mappings":";;;;;;AAEA,sGAAgG;AAGhG,+DAA2D;AAC3D,yFAAkE;AAElE;;;GAGG;AACH,MAAa,cAAe,SAAQ,gDAAqB;IAGrD;QACI,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;IAC9B,CAAC;IAES,qBAAqB,CAAC,WAAmB;QAC/C,OAAO,CAAC,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,YAAY,EAAE,KAAK,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE;YACzF,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,EAAE;gBACxC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;aAC5B;YAED,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,EAAE;gBACxC,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;aAC7B;YAED,IAAI,CAAC,OAAO,EAAE,CAAC;SAClB;QAED,IAAI,IAAI,CAAC,cAAc,EAAE,EAAE;YACvB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;gBACZ,KAAK,EAAE,IAAI,CAAC,KAAK,GAAG,CAAC;gBACrB,SAAS,EAAE,IAAI,CAAC,eAAe,EAAE;gBACjC,QAAQ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