@designliquido/lincones-sqlite 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -0
- package/bin/lincones-sqlite +3 -0
- package/bin/lincones-sqlite.cmd +1 -0
- package/comum/execucao.d.ts +1 -0
- package/comum/execucao.js +40 -0
- package/comum/execucao.js.map +1 -0
- package/comum/fontes/avaliador-sintatico/avaliador-sintatico-base.d.ts +15 -0
- package/comum/fontes/avaliador-sintatico/avaliador-sintatico-base.js +46 -0
- package/comum/fontes/avaliador-sintatico/avaliador-sintatico-base.js.map +1 -0
- package/comum/fontes/avaliador-sintatico/avaliador-sintatico.d.ts +15 -0
- package/comum/fontes/avaliador-sintatico/avaliador-sintatico.js +263 -0
- package/comum/fontes/avaliador-sintatico/avaliador-sintatico.js.map +1 -0
- package/comum/fontes/avaliador-sintatico/erro-avaliador-sintatico.d.ts +5 -0
- package/comum/fontes/avaliador-sintatico/erro-avaliador-sintatico.js +12 -0
- package/comum/fontes/avaliador-sintatico/erro-avaliador-sintatico.js.map +1 -0
- package/comum/fontes/avaliador-sintatico/index.d.ts +3 -0
- package/comum/fontes/avaliador-sintatico/index.js +23 -0
- package/comum/fontes/avaliador-sintatico/index.js.map +1 -0
- package/comum/fontes/comandos/atualizar.d.ts +14 -0
- package/comum/fontes/comandos/atualizar.js +14 -0
- package/comum/fontes/comandos/atualizar.js.map +1 -0
- package/comum/fontes/comandos/comando.d.ts +6 -0
- package/comum/fontes/comandos/comando.js +14 -0
- package/comum/fontes/comandos/comando.js.map +1 -0
- package/comum/fontes/comandos/criar.d.ts +7 -0
- package/comum/fontes/comandos/criar.js +13 -0
- package/comum/fontes/comandos/criar.js.map +1 -0
- package/comum/fontes/comandos/excluir.d.ts +6 -0
- package/comum/fontes/comandos/excluir.js +13 -0
- package/comum/fontes/comandos/excluir.js.map +1 -0
- package/comum/fontes/comandos/index.d.ts +6 -0
- package/comum/fontes/comandos/index.js +23 -0
- package/comum/fontes/comandos/index.js.map +1 -0
- package/comum/fontes/comandos/inserir.d.ts +8 -0
- package/comum/fontes/comandos/inserir.js +14 -0
- package/comum/fontes/comandos/inserir.js.map +1 -0
- package/comum/fontes/comandos/selecionar.d.ts +9 -0
- package/comum/fontes/comandos/selecionar.js +15 -0
- package/comum/fontes/comandos/selecionar.js.map +1 -0
- package/comum/fontes/construtos/coluna.d.ts +11 -0
- package/comum/fontes/construtos/coluna.js +16 -0
- package/comum/fontes/construtos/coluna.js.map +1 -0
- package/comum/fontes/construtos/condicao.d.ts +6 -0
- package/comum/fontes/construtos/condicao.js +12 -0
- package/comum/fontes/construtos/condicao.js.map +1 -0
- package/comum/fontes/construtos/index.d.ts +1 -0
- package/comum/fontes/construtos/index.js +18 -0
- package/comum/fontes/construtos/index.js.map +1 -0
- package/comum/fontes/interfaces/avaliador-sintatico-interface.d.ts +14 -0
- package/comum/fontes/interfaces/avaliador-sintatico-interface.js +3 -0
- package/comum/fontes/interfaces/avaliador-sintatico-interface.js.map +1 -0
- package/comum/fontes/interfaces/index.d.ts +3 -0
- package/comum/fontes/interfaces/index.js +18 -0
- package/comum/fontes/interfaces/index.js.map +1 -0
- package/comum/fontes/interfaces/lincones-interface.d.ts +3 -0
- package/comum/fontes/interfaces/lincones-interface.js +3 -0
- package/comum/fontes/interfaces/lincones-interface.js.map +1 -0
- package/comum/fontes/interfaces/retornos/index.d.ts +16 -0
- package/comum/fontes/interfaces/retornos/index.js +3 -0
- package/comum/fontes/interfaces/retornos/index.js.map +1 -0
- package/comum/fontes/interfaces/simbolo-interface.d.ts +6 -0
- package/comum/fontes/interfaces/simbolo-interface.js +3 -0
- package/comum/fontes/interfaces/simbolo-interface.js.map +1 -0
- package/comum/fontes/lexador/index.d.ts +26 -0
- package/comum/fontes/lexador/index.js +220 -0
- package/comum/fontes/lexador/index.js.map +1 -0
- package/comum/fontes/lexador/simbolo.d.ts +9 -0
- package/comum/fontes/lexador/simbolo.js +16 -0
- package/comum/fontes/lexador/simbolo.js.map +1 -0
- package/comum/fontes/lincones.d.ts +10 -0
- package/comum/fontes/lincones.js +21 -0
- package/comum/fontes/lincones.js.map +1 -0
- package/comum/fontes/palavras-reservadas.d.ts +26 -0
- package/comum/fontes/palavras-reservadas.js +32 -0
- package/comum/fontes/palavras-reservadas.js.map +1 -0
- package/comum/fontes/tipos-de-simbolos.d.ts +38 -0
- package/comum/fontes/tipos-de-simbolos.js +40 -0
- package/comum/fontes/tipos-de-simbolos.js.map +1 -0
- package/comum/fontes/tradutor/index.d.ts +18 -0
- package/comum/fontes/tradutor/index.js +161 -0
- package/comum/fontes/tradutor/index.js.map +1 -0
- package/comum/index.d.ts +1 -0
- package/comum/index.js +6 -0
- package/comum/index.js.map +1 -0
- package/comum/jest.config.d.ts +3 -0
- package/comum/jest.config.js +12 -0
- package/comum/jest.config.js.map +1 -0
- package/execucao.d.ts +1 -0
- package/execucao.js +55 -0
- package/execucao.js.map +1 -0
- package/fontes/avaliador-sintatico/avaliador-sintatico.d.ts +15 -0
- package/fontes/avaliador-sintatico/avaliador-sintatico.js +262 -0
- package/fontes/avaliador-sintatico/avaliador-sintatico.js.map +1 -0
- package/fontes/avaliador-sintatico/index.d.ts +2 -0
- package/fontes/avaliador-sintatico/index.js +21 -0
- package/fontes/avaliador-sintatico/index.js.map +1 -0
- package/fontes/infraestrutura/cliente-sqlite.d.ts +10 -0
- package/fontes/infraestrutura/cliente-sqlite.js +65 -0
- package/fontes/infraestrutura/cliente-sqlite.js.map +1 -0
- package/fontes/infraestrutura/index.d.ts +2 -0
- package/fontes/infraestrutura/index.js +19 -0
- package/fontes/infraestrutura/index.js.map +1 -0
- package/fontes/infraestrutura/retorno-comando.d.ts +7 -0
- package/fontes/infraestrutura/retorno-comando.js +22 -0
- package/fontes/infraestrutura/retorno-comando.js.map +1 -0
- package/fontes/lexador/index.d.ts +26 -0
- package/fontes/lexador/index.js +220 -0
- package/fontes/lexador/index.js.map +1 -0
- package/fontes/lincones-sqlite.d.ts +13 -0
- package/fontes/lincones-sqlite.js +29 -0
- package/fontes/lincones-sqlite.js.map +1 -0
- package/fontes/palavras-reservadas.d.ts +26 -0
- package/fontes/palavras-reservadas.js +32 -0
- package/fontes/palavras-reservadas.js.map +1 -0
- package/fontes/tradutor/index.d.ts +19 -0
- package/fontes/tradutor/index.js +150 -0
- package/fontes/tradutor/index.js.map +1 -0
- package/index.d.ts +1 -0
- package/index.js +18 -0
- package/index.js.map +1 -0
- package/package.json +62 -0
|
@@ -0,0 +1,220 @@
|
|
|
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.Lexador = void 0;
|
|
7
|
+
const simbolo_1 = require("../../comum/fontes/lexador/simbolo");
|
|
8
|
+
const palavras_reservadas_1 = __importDefault(require("../palavras-reservadas"));
|
|
9
|
+
const tipos_de_simbolos_1 = __importDefault(require("../../comum/fontes/tipos-de-simbolos"));
|
|
10
|
+
class Lexador {
|
|
11
|
+
eDigito(caractere) {
|
|
12
|
+
return caractere >= '0' && caractere <= '9';
|
|
13
|
+
}
|
|
14
|
+
eAlfabeto(caractere) {
|
|
15
|
+
const acentuacoes = [
|
|
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
|
+
return ((caractere >= 'a' && caractere <= 'z') ||
|
|
43
|
+
(caractere >= 'A' && caractere <= 'Z') ||
|
|
44
|
+
acentuacoes.includes(caractere));
|
|
45
|
+
}
|
|
46
|
+
eAlfabetoOuDigito(caractere) {
|
|
47
|
+
return this.eDigito(caractere) || this.eAlfabeto(caractere);
|
|
48
|
+
}
|
|
49
|
+
eFinalDoCodigo() {
|
|
50
|
+
return (this.eUltimaLinha() &&
|
|
51
|
+
this.codigo[this.codigo.length - 1].length <= this.atual);
|
|
52
|
+
}
|
|
53
|
+
eUltimaLinha() {
|
|
54
|
+
return this.linha >= this.codigo.length - 1;
|
|
55
|
+
}
|
|
56
|
+
eFinalDaLinha() {
|
|
57
|
+
if (this.codigo.length === this.linha) {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
return this.atual >= this.codigo[this.linha].length;
|
|
61
|
+
}
|
|
62
|
+
simboloAtual() {
|
|
63
|
+
if (this.eFinalDaLinha())
|
|
64
|
+
return '\0';
|
|
65
|
+
return this.codigo[this.linha].charAt(this.atual);
|
|
66
|
+
}
|
|
67
|
+
avancar() {
|
|
68
|
+
this.atual += 1;
|
|
69
|
+
if (this.eFinalDaLinha() && !this.eUltimaLinha()) {
|
|
70
|
+
this.linha++;
|
|
71
|
+
this.atual = 0;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
proximoSimbolo() {
|
|
75
|
+
return this.codigo[this.linha].charAt(this.atual + 1);
|
|
76
|
+
}
|
|
77
|
+
simboloAnterior() {
|
|
78
|
+
return this.codigo[this.linha].charAt(this.atual - 1);
|
|
79
|
+
}
|
|
80
|
+
analisarNumero() {
|
|
81
|
+
while (this.eDigito(this.simboloAtual())) {
|
|
82
|
+
this.avancar();
|
|
83
|
+
}
|
|
84
|
+
if (this.simboloAtual() == '.' && this.eDigito(this.proximoSimbolo())) {
|
|
85
|
+
this.avancar();
|
|
86
|
+
while (this.eDigito(this.simboloAtual())) {
|
|
87
|
+
this.avancar();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const numeroCompleto = this.codigo[this.linha].substring(this.inicioSimbolo, this.atual);
|
|
91
|
+
this.adicionarSimbolo(tipos_de_simbolos_1.default.NUMERO, parseFloat(numeroCompleto));
|
|
92
|
+
}
|
|
93
|
+
analisarTexto(delimitador = '"') {
|
|
94
|
+
while (this.simboloAtual() !== delimitador && !this.eFinalDoCodigo()) {
|
|
95
|
+
this.avancar();
|
|
96
|
+
}
|
|
97
|
+
if (this.eFinalDoCodigo()) {
|
|
98
|
+
this.erros.push({
|
|
99
|
+
linha: this.linha + 1,
|
|
100
|
+
caractere: this.simboloAnterior(),
|
|
101
|
+
mensagem: 'Texto não finalizado.'
|
|
102
|
+
});
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const valor = this.codigo[this.linha].substring(this.inicioSimbolo + 1, this.atual);
|
|
106
|
+
this.adicionarSimbolo(tipos_de_simbolos_1.default.TEXTO, valor);
|
|
107
|
+
}
|
|
108
|
+
adicionarSimbolo(tipo, literal = null) {
|
|
109
|
+
const texto = this.codigo[this.linha].substring(this.inicioSimbolo, this.atual);
|
|
110
|
+
this.simbolos.push(new simbolo_1.Simbolo(tipo, literal || texto, literal, this.linha + 1));
|
|
111
|
+
}
|
|
112
|
+
identificarPalavraChave() {
|
|
113
|
+
while (this.eAlfabetoOuDigito(this.simboloAtual())) {
|
|
114
|
+
this.avancar();
|
|
115
|
+
}
|
|
116
|
+
const codigo = this.codigo[this.linha].substring(this.inicioSimbolo, this.atual).toLowerCase();
|
|
117
|
+
const tipo = codigo in palavras_reservadas_1.default
|
|
118
|
+
? palavras_reservadas_1.default[codigo]
|
|
119
|
+
: tipos_de_simbolos_1.default.IDENTIFICADOR;
|
|
120
|
+
this.adicionarSimbolo(tipo);
|
|
121
|
+
}
|
|
122
|
+
analisarToken() {
|
|
123
|
+
const caractere = this.simboloAtual();
|
|
124
|
+
switch (caractere) {
|
|
125
|
+
// Esta sessão ignora espaços em branco na tokenização.
|
|
126
|
+
case ' ':
|
|
127
|
+
case '\0':
|
|
128
|
+
case '\r':
|
|
129
|
+
case '\t':
|
|
130
|
+
this.avancar();
|
|
131
|
+
break;
|
|
132
|
+
case ';':
|
|
133
|
+
this.adicionarSimbolo(tipos_de_simbolos_1.default.PONTO_VIRGULA, ';');
|
|
134
|
+
this.linha++;
|
|
135
|
+
this.avancar();
|
|
136
|
+
break;
|
|
137
|
+
case '"':
|
|
138
|
+
this.avancar();
|
|
139
|
+
this.analisarTexto('"');
|
|
140
|
+
this.avancar();
|
|
141
|
+
break;
|
|
142
|
+
case "'":
|
|
143
|
+
this.avancar();
|
|
144
|
+
this.analisarTexto("'");
|
|
145
|
+
this.avancar();
|
|
146
|
+
break;
|
|
147
|
+
case '(':
|
|
148
|
+
this.adicionarSimbolo(tipos_de_simbolos_1.default.PARENTESE_ESQUERDO, '(');
|
|
149
|
+
this.avancar();
|
|
150
|
+
break;
|
|
151
|
+
case ')':
|
|
152
|
+
this.adicionarSimbolo(tipos_de_simbolos_1.default.PARENTESE_DIREITO, ')');
|
|
153
|
+
this.avancar();
|
|
154
|
+
break;
|
|
155
|
+
case ',':
|
|
156
|
+
this.adicionarSimbolo(tipos_de_simbolos_1.default.VIRGULA, ',');
|
|
157
|
+
this.avancar();
|
|
158
|
+
break;
|
|
159
|
+
case '=':
|
|
160
|
+
this.adicionarSimbolo(tipos_de_simbolos_1.default.IGUAL, '=');
|
|
161
|
+
this.avancar();
|
|
162
|
+
break;
|
|
163
|
+
case '*':
|
|
164
|
+
this.adicionarSimbolo(tipos_de_simbolos_1.default.TUDO, '*');
|
|
165
|
+
this.avancar();
|
|
166
|
+
break;
|
|
167
|
+
case '<':
|
|
168
|
+
this.avancar();
|
|
169
|
+
if (this.simboloAtual() === '=') {
|
|
170
|
+
this.adicionarSimbolo(tipos_de_simbolos_1.default.MENOR_IGUAL);
|
|
171
|
+
this.avancar();
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
this.adicionarSimbolo(tipos_de_simbolos_1.default.MENOR);
|
|
175
|
+
}
|
|
176
|
+
break;
|
|
177
|
+
case '>':
|
|
178
|
+
this.avancar();
|
|
179
|
+
if (this.simboloAtual() === '=') {
|
|
180
|
+
this.adicionarSimbolo(tipos_de_simbolos_1.default.MAIOR_IGUAL);
|
|
181
|
+
this.avancar();
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
this.adicionarSimbolo(tipos_de_simbolos_1.default.MAIOR);
|
|
185
|
+
}
|
|
186
|
+
break;
|
|
187
|
+
default:
|
|
188
|
+
if (this.eDigito(caractere))
|
|
189
|
+
this.analisarNumero();
|
|
190
|
+
else if (this.eAlfabeto(caractere))
|
|
191
|
+
this.identificarPalavraChave();
|
|
192
|
+
else {
|
|
193
|
+
this.erros.push({
|
|
194
|
+
linha: this.linha + 1,
|
|
195
|
+
caractere: caractere,
|
|
196
|
+
mensagem: 'Caractere inesperado.'
|
|
197
|
+
});
|
|
198
|
+
this.avancar();
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
mapear(codigo) {
|
|
203
|
+
this.inicioSimbolo = 0;
|
|
204
|
+
this.atual = 0;
|
|
205
|
+
this.linha = 0;
|
|
206
|
+
this.codigo = codigo || [''];
|
|
207
|
+
this.simbolos = [];
|
|
208
|
+
this.erros = [];
|
|
209
|
+
while (!this.eFinalDoCodigo()) {
|
|
210
|
+
this.inicioSimbolo = this.atual;
|
|
211
|
+
this.analisarToken();
|
|
212
|
+
}
|
|
213
|
+
return {
|
|
214
|
+
simbolos: this.simbolos,
|
|
215
|
+
erros: this.erros
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
exports.Lexador = Lexador;
|
|
220
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","s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atico";
|
|
3
|
+
import { Lexador } from "./lexador";
|
|
4
|
+
import { ClienteSQLite } from "./infraestrutura/cliente-sqlite";
|
|
5
|
+
import { RetornoComando } from "./infraestrutura";
|
|
6
|
+
export declare class LinconesSQLite {
|
|
7
|
+
lexador: Lexador;
|
|
8
|
+
avaliadorSintatico: AvaliadorSintatico;
|
|
9
|
+
tradutor: Tradutor;
|
|
10
|
+
clienteSQLite: ClienteSQLite;
|
|
11
|
+
constructor();
|
|
12
|
+
executar(comando: string): Promise<RetornoComando>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LinconesSQLite = void 0;
|
|
4
|
+
const tradutor_1 = require("../comum/fontes/tradutor");
|
|
5
|
+
const avaliador_sintatico_1 = require("../comum/fontes/avaliador-sintatico");
|
|
6
|
+
const lexador_1 = require("./lexador");
|
|
7
|
+
const cliente_sqlite_1 = require("./infraestrutura/cliente-sqlite");
|
|
8
|
+
const infraestrutura_1 = require("./infraestrutura");
|
|
9
|
+
class LinconesSQLite {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.lexador = new lexador_1.Lexador();
|
|
12
|
+
this.avaliadorSintatico = new avaliador_sintatico_1.AvaliadorSintatico();
|
|
13
|
+
this.tradutor = new tradutor_1.Tradutor();
|
|
14
|
+
this.clienteSQLite = new cliente_sqlite_1.ClienteSQLite();
|
|
15
|
+
}
|
|
16
|
+
async executar(comando) {
|
|
17
|
+
const resultadoLexador = this.lexador.mapear([comando]);
|
|
18
|
+
const resultadoAvaliacaoSintatica = this.avaliadorSintatico.analisar(resultadoLexador);
|
|
19
|
+
const resultadoTraducao = this.tradutor.traduzir(resultadoAvaliacaoSintatica.comandos);
|
|
20
|
+
if (resultadoAvaliacaoSintatica.comandos.length <= 0) {
|
|
21
|
+
return new infraestrutura_1.RetornoComando(null);
|
|
22
|
+
}
|
|
23
|
+
const resultadoExecucao = await this.clienteSQLite.executarComando(resultadoTraducao);
|
|
24
|
+
const retorno = new infraestrutura_1.RetornoComando(resultadoExecucao);
|
|
25
|
+
return retorno;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.LinconesSQLite = LinconesSQLite;
|
|
29
|
+
//# sourceMappingURL=lincones-sqlite.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lincones-sqlite.js","sourceRoot":"","sources":["../../fontes/lincones-sqlite.ts"],"names":[],"mappings":";;;AAAA,uDAAoD;AACpD,6EAAyE;AACzE,uCAAoC;AACpC,oEAAgE;AAChE,qDAAkD;AAElD,MAAa,cAAc;IAMvB;QACI,IAAI,CAAC,OAAO,GAAG,IAAI,iBAAO,EAAE,CAAC;QAC7B,IAAI,CAAC,kBAAkB,GAAG,IAAI,wCAAkB,EAAE,CAAC;QACnD,IAAI,CAAC,QAAQ,GAAG,IAAI,mBAAQ,EAAE,CAAC;QAC/B,IAAI,CAAC,aAAa,GAAG,IAAI,8BAAa,EAAE,CAAC;IAC7C,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,OAAe;QAC1B,MAAM,gBAAgB,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;QACxD,MAAM,2BAA2B,GAAG,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;QACvF,MAAM,iBAAiB,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,2BAA2B,CAAC,QAAQ,CAAC,CAAC;QAEvF,IAAI,2BAA2B,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC,EAAE;YAClD,OAAO,IAAI,+BAAc,CAAC,IAAI,CAAC,CAAC;SACnC;QAED,MAAM,iBAAiB,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAAC;QACtF,MAAM,OAAO,GAAG,IAAI,+BAAc,CAAC,iBAAiB,CAAC,CAAC;QAEtD,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ;AA3BD,wCA2BC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
atualizar: string;
|
|
3
|
+
auto: string;
|
|
4
|
+
chave: string;
|
|
5
|
+
criar: string;
|
|
6
|
+
de: string;
|
|
7
|
+
definir: string;
|
|
8
|
+
e: string;
|
|
9
|
+
em: string;
|
|
10
|
+
excluir: string;
|
|
11
|
+
falso: string;
|
|
12
|
+
incremento: string;
|
|
13
|
+
inserir: string;
|
|
14
|
+
inteiro: string;
|
|
15
|
+
logico: string;
|
|
16
|
+
nao: string;
|
|
17
|
+
nulo: string;
|
|
18
|
+
onde: string;
|
|
19
|
+
primaria: string;
|
|
20
|
+
selecionar: string;
|
|
21
|
+
tabela: string;
|
|
22
|
+
texto: string;
|
|
23
|
+
valores: string;
|
|
24
|
+
verdadeiro: string;
|
|
25
|
+
};
|
|
26
|
+
export default _default;
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
const tipos_de_simbolos_1 = __importDefault(require("../comum/fontes/tipos-de-simbolos"));
|
|
7
|
+
exports.default = {
|
|
8
|
+
atualizar: tipos_de_simbolos_1.default.ATUALIZAR,
|
|
9
|
+
auto: tipos_de_simbolos_1.default.AUTO,
|
|
10
|
+
chave: tipos_de_simbolos_1.default.CHAVE,
|
|
11
|
+
criar: tipos_de_simbolos_1.default.CRIAR,
|
|
12
|
+
de: tipos_de_simbolos_1.default.DE,
|
|
13
|
+
definir: tipos_de_simbolos_1.default.DEFINIR,
|
|
14
|
+
e: tipos_de_simbolos_1.default.E,
|
|
15
|
+
em: tipos_de_simbolos_1.default.EM,
|
|
16
|
+
excluir: tipos_de_simbolos_1.default.EXCLUIR,
|
|
17
|
+
falso: tipos_de_simbolos_1.default.FALSO,
|
|
18
|
+
incremento: tipos_de_simbolos_1.default.INCREMENTO,
|
|
19
|
+
inserir: tipos_de_simbolos_1.default.INSERIR,
|
|
20
|
+
inteiro: tipos_de_simbolos_1.default.INTEIRO,
|
|
21
|
+
logico: tipos_de_simbolos_1.default.LOGICO,
|
|
22
|
+
nao: tipos_de_simbolos_1.default.NAO,
|
|
23
|
+
nulo: tipos_de_simbolos_1.default.NULO,
|
|
24
|
+
onde: tipos_de_simbolos_1.default.ONDE,
|
|
25
|
+
primaria: tipos_de_simbolos_1.default.PRIMARIA,
|
|
26
|
+
selecionar: tipos_de_simbolos_1.default.SELECIONAR,
|
|
27
|
+
tabela: tipos_de_simbolos_1.default.TABELA,
|
|
28
|
+
texto: tipos_de_simbolos_1.default.TEXTO,
|
|
29
|
+
valores: tipos_de_simbolos_1.default.VALORES,
|
|
30
|
+
verdadeiro: tipos_de_simbolos_1.default.VERDADEIRO
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=palavras-reservadas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"palavras-reservadas.js","sourceRoot":"","sources":["../../fontes/palavras-reservadas.ts"],"names":[],"mappings":";;;;;AAAA,0FAAgE;AAEhE,kBAAe;IACX,SAAS,EAAE,2BAAe,CAAC,SAAS;IACpC,IAAI,EAAE,2BAAe,CAAC,IAAI;IAC1B,KAAK,EAAE,2BAAe,CAAC,KAAK;IAC5B,KAAK,EAAE,2BAAe,CAAC,KAAK;IAC5B,EAAE,EAAE,2BAAe,CAAC,EAAE;IACtB,OAAO,EAAE,2BAAe,CAAC,OAAO;IAChC,CAAC,EAAE,2BAAe,CAAC,CAAC;IACpB,EAAE,EAAE,2BAAe,CAAC,EAAE;IACtB,OAAO,EAAE,2BAAe,CAAC,OAAO;IAChC,KAAK,EAAE,2BAAe,CAAC,KAAK;IAC5B,UAAU,EAAE,2BAAe,CAAC,UAAU;IACtC,OAAO,EAAE,2BAAe,CAAC,OAAO;IAChC,OAAO,EAAE,2BAAe,CAAC,OAAO;IAChC,MAAM,EAAE,2BAAe,CAAC,MAAM;IAC9B,GAAG,EAAE,2BAAe,CAAC,GAAG;IACxB,IAAI,EAAE,2BAAe,CAAC,IAAI;IAC1B,IAAI,EAAE,2BAAe,CAAC,IAAI;IAC1B,QAAQ,EAAE,2BAAe,CAAC,QAAQ;IAClC,UAAU,EAAE,2BAAe,CAAC,UAAU;IACtC,MAAM,EAAE,2BAAe,CAAC,MAAM;IAC9B,KAAK,EAAE,2BAAe,CAAC,KAAK;IAC5B,OAAO,EAAE,2BAAe,CAAC,OAAO;IAChC,UAAU,EAAE,2BAAe,CAAC,UAAU;CACzC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Coluna } from "../../comum/fontes/avaliador-sintatico";
|
|
2
|
+
import { Atualizar, Comando, Criar, Excluir, Inserir, Selecionar } from "../../comum/fontes/comandos";
|
|
3
|
+
export declare class Tradutor {
|
|
4
|
+
traduzirOperador(operador: string): boolean | "=";
|
|
5
|
+
traduzirComandoAtualizar(comandoAtualizar: Atualizar): string;
|
|
6
|
+
traduzirColuna(coluna: Coluna): string;
|
|
7
|
+
traduzirComandoCriar(comandoCriar: Criar): string;
|
|
8
|
+
traduzirComandoExcluir(comandoExcluir: Excluir): string;
|
|
9
|
+
traduzirComandoInserir(comandoInserir: Inserir): string;
|
|
10
|
+
traduzirComandoSelecionar(comandoSelecionar: Selecionar): string;
|
|
11
|
+
dicionarioComandos: {
|
|
12
|
+
Atualizar: any;
|
|
13
|
+
Criar: any;
|
|
14
|
+
Excluir: any;
|
|
15
|
+
Inserir: any;
|
|
16
|
+
Selecionar: any;
|
|
17
|
+
};
|
|
18
|
+
traduzir(comandos: Comando[]): string;
|
|
19
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
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.Tradutor = void 0;
|
|
7
|
+
const tipos_de_simbolos_1 = __importDefault(require("../../comum/fontes/tipos-de-simbolos"));
|
|
8
|
+
class Tradutor {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.dicionarioComandos = {
|
|
11
|
+
Atualizar: this.traduzirComandoAtualizar.bind(this),
|
|
12
|
+
Criar: this.traduzirComandoCriar.bind(this),
|
|
13
|
+
Excluir: this.traduzirComandoExcluir.bind(this),
|
|
14
|
+
Inserir: this.traduzirComandoInserir.bind(this),
|
|
15
|
+
Selecionar: this.traduzirComandoSelecionar.bind(this)
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
traduzirOperador(operador) {
|
|
19
|
+
switch (operador) {
|
|
20
|
+
case tipos_de_simbolos_1.default.IGUAL:
|
|
21
|
+
return '=';
|
|
22
|
+
case tipos_de_simbolos_1.default.VERDADEIRO:
|
|
23
|
+
return true;
|
|
24
|
+
case tipos_de_simbolos_1.default.FALSO:
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
traduzirComandoAtualizar(comandoAtualizar) {
|
|
29
|
+
let resultado = 'UPDATE ';
|
|
30
|
+
resultado += `${comandoAtualizar.tabela}\nSET `;
|
|
31
|
+
for (const valorAtualizacao of comandoAtualizar.colunasEValores) {
|
|
32
|
+
if (valorAtualizacao.direita.tipo === tipos_de_simbolos_1.default.TEXTO) {
|
|
33
|
+
resultado += `${valorAtualizacao.esquerda.lexema} = '${valorAtualizacao.direita.lexema}', `;
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if ([tipos_de_simbolos_1.default.VERDADEIRO, tipos_de_simbolos_1.default.FALSO].includes(valorAtualizacao.direita.tipo)) {
|
|
37
|
+
resultado += `${valorAtualizacao.esquerda.lexema} = ${this.traduzirOperador(valorAtualizacao.direita.tipo)}, `;
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
resultado += `${valorAtualizacao.esquerda.lexema} = ${valorAtualizacao.direita.lexema}, `;
|
|
41
|
+
}
|
|
42
|
+
resultado = resultado.slice(0, -2);
|
|
43
|
+
if (comandoAtualizar.condicoes.length > 0) {
|
|
44
|
+
resultado += `\nWHERE `;
|
|
45
|
+
for (const condicao of comandoAtualizar.condicoes) {
|
|
46
|
+
resultado += `${condicao.esquerda.lexema} ${this.traduzirOperador(condicao.operador)} ${condicao.direita} AND `;
|
|
47
|
+
}
|
|
48
|
+
resultado = resultado.slice(0, -5);
|
|
49
|
+
}
|
|
50
|
+
return resultado;
|
|
51
|
+
}
|
|
52
|
+
traduzirColuna(coluna) {
|
|
53
|
+
let traduzir = "";
|
|
54
|
+
if (coluna.chavePrimaria)
|
|
55
|
+
traduzir += "PRIMARY KEY ";
|
|
56
|
+
if (tipos_de_simbolos_1.default.INTEIRO === coluna.tipo) {
|
|
57
|
+
traduzir += `INTEGER `;
|
|
58
|
+
}
|
|
59
|
+
else if (tipos_de_simbolos_1.default.TEXTO === coluna.tipo) {
|
|
60
|
+
const simbolo = coluna.tamanho;
|
|
61
|
+
traduzir += `VARCHAR(${simbolo.literal}) `;
|
|
62
|
+
}
|
|
63
|
+
else if (tipos_de_simbolos_1.default.LOGICO === coluna.tipo)
|
|
64
|
+
traduzir += "BOOLEAN ";
|
|
65
|
+
if (coluna.nulo)
|
|
66
|
+
traduzir += "NULL";
|
|
67
|
+
else
|
|
68
|
+
traduzir += "NOT NULL";
|
|
69
|
+
return traduzir;
|
|
70
|
+
}
|
|
71
|
+
traduzirComandoCriar(comandoCriar) {
|
|
72
|
+
let resultado = `CREATE TABLE ${comandoCriar.tabela} (`;
|
|
73
|
+
for (const coluna of comandoCriar.colunas) {
|
|
74
|
+
resultado += `${coluna.nomeColuna} ${this.traduzirColuna(coluna)}, `;
|
|
75
|
+
}
|
|
76
|
+
resultado = resultado.slice(0, -2);
|
|
77
|
+
resultado += ")";
|
|
78
|
+
return resultado;
|
|
79
|
+
}
|
|
80
|
+
traduzirComandoExcluir(comandoExcluir) {
|
|
81
|
+
let resultado = 'DELETE FROM ';
|
|
82
|
+
resultado += `${comandoExcluir.tabela} `;
|
|
83
|
+
resultado = resultado.slice(0, -1);
|
|
84
|
+
if (comandoExcluir.condicoes.length > 0) {
|
|
85
|
+
resultado += `\nWHERE `;
|
|
86
|
+
for (const condicao of comandoExcluir.condicoes) {
|
|
87
|
+
resultado += `${condicao.esquerda.lexema} ${this.traduzirOperador(condicao.operador)} ${condicao.direita} AND `;
|
|
88
|
+
}
|
|
89
|
+
resultado = resultado.slice(0, -5);
|
|
90
|
+
}
|
|
91
|
+
return resultado;
|
|
92
|
+
}
|
|
93
|
+
traduzirComandoInserir(comandoInserir) {
|
|
94
|
+
let resultado = 'INSERT INTO ';
|
|
95
|
+
resultado += `${comandoInserir.tabela} (`;
|
|
96
|
+
for (const coluna of comandoInserir.colunas) {
|
|
97
|
+
resultado += `${coluna}, `;
|
|
98
|
+
}
|
|
99
|
+
resultado = resultado.slice(0, -2);
|
|
100
|
+
resultado += `)\nVALUES (`;
|
|
101
|
+
for (const valor of comandoInserir.valores) {
|
|
102
|
+
if (typeof valor.literal === "string") {
|
|
103
|
+
resultado += `"${valor.literal}", `;
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
else if ([tipos_de_simbolos_1.default.VERDADEIRO, tipos_de_simbolos_1.default.FALSO].includes(valor.tipo)) {
|
|
107
|
+
resultado += `${this.traduzirOperador(valor.tipo)}, `;
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
resultado += `${valor.literal}, `;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
resultado = resultado.slice(0, -2);
|
|
115
|
+
resultado += `)`;
|
|
116
|
+
return resultado;
|
|
117
|
+
}
|
|
118
|
+
traduzirComandoSelecionar(comandoSelecionar) {
|
|
119
|
+
let resultado = 'SELECT ';
|
|
120
|
+
// Colunas
|
|
121
|
+
if (comandoSelecionar.tudo) {
|
|
122
|
+
resultado += '*';
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
for (const coluna of comandoSelecionar.colunas) {
|
|
126
|
+
resultado += coluna + ', ';
|
|
127
|
+
}
|
|
128
|
+
resultado = resultado.slice(0, -2);
|
|
129
|
+
}
|
|
130
|
+
resultado += `\nFROM ${comandoSelecionar.tabela}`;
|
|
131
|
+
// Condições
|
|
132
|
+
if (comandoSelecionar.condicoes.length > 0) {
|
|
133
|
+
resultado += '\n WHERE ';
|
|
134
|
+
for (const condicao of comandoSelecionar.condicoes) {
|
|
135
|
+
resultado += `${condicao.esquerda.lexema} ${this.traduzirOperador(condicao.operador)} ${condicao.direita} AND `;
|
|
136
|
+
}
|
|
137
|
+
resultado = resultado.slice(0, -5);
|
|
138
|
+
}
|
|
139
|
+
return resultado;
|
|
140
|
+
}
|
|
141
|
+
traduzir(comandos) {
|
|
142
|
+
let resultado = '';
|
|
143
|
+
for (const comando of comandos.filter(c => c)) {
|
|
144
|
+
resultado += `${this.dicionarioComandos[comando.constructor.name](comando)} \n`;
|
|
145
|
+
}
|
|
146
|
+
return resultado;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
exports.Tradutor = Tradutor;
|
|
150
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../fontes/tradutor/index.ts"],"names":[],"mappings":";;;;;;AAIA,6FAAmE;AAEnE,MAAa,QAAQ;IAArB;QA2JI,uBAAkB,GAAG;YACjB,SAAS,EAAE,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,IAAI,CAAC;YACnD,KAAK,EAAE,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC;YAC3C,OAAO,EAAE,IAAI,CAAC,sBAAsB,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,CAAC,QAAQ,CAAC,MAAM,IAAI,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,OAAO,OAAO,CAAC;aACnH;YACD,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;SACtC;QAED,OAAO,SAAS,CAAC;IACrB,CAAC;IAUD,QAAQ,CAAC,QAAmB;QACxB,IAAI,SAAS,GAAG,EAAE,CAAC;QAEnB,KAAK,MAAM,OAAO,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE;YAC3C,SAAS,IAAI,GAAG,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;SACnF;QAED,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ;AA5KD,4BA4KC"}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./fontes/lincones-sqlite";
|
package/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./fontes/lincones-sqlite"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAyC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@designliquido/lincones-sqlite",
|
|
3
|
+
"description": "Implementação de LinConEs para SQLite.",
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"author": "Leonel Sanches da Silva",
|
|
7
|
+
"contributors": [
|
|
8
|
+
{
|
|
9
|
+
"name": "Leonel Sanches da Silva",
|
|
10
|
+
"url": "https://www.linkedin.com/in/leonelsanchesdasilva/"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"name": "Italo Brito Brandão",
|
|
14
|
+
"url": "https://github.com/ItaloCobains"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"name": "Samuel Renan Gonçalves Vaz",
|
|
18
|
+
"url": "https://www.linkedin.com/in/samuel-renan-gon%C3%A7alves-vaz-b6b83a103/"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/DesignLiquido/lincones-sqlite/issues"
|
|
24
|
+
},
|
|
25
|
+
"homepage": "https://github.com/DesignLiquido/lincones-sqlite#readme",
|
|
26
|
+
"scripts": {
|
|
27
|
+
"empacotar": "rimraf ./dist && tsc && copyfiles -V ./bin/lincones-sqlite ./bin/lincones-sqlite.cmd ./dist && copyfiles -V ./README.md ./dist && copyfiles -V ./package.json ./dist",
|
|
28
|
+
"formatacao-prettier": "prettier --config .prettierrc *.ts --write",
|
|
29
|
+
"publicar-npm": "npm publish --access public",
|
|
30
|
+
"lint": "eslint . --ext .ts",
|
|
31
|
+
"testes-unitarios": "jest --coverage"
|
|
32
|
+
},
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "git+https://github.com/DesignLiquido/lincones-sqlite.git"
|
|
36
|
+
},
|
|
37
|
+
"bin": {
|
|
38
|
+
"lincones-sqlite": "./bin/lincones-sqlite"
|
|
39
|
+
},
|
|
40
|
+
"keywords": [
|
|
41
|
+
"lincones",
|
|
42
|
+
"sql",
|
|
43
|
+
"sqlite"
|
|
44
|
+
],
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/jest": "^29.2.3",
|
|
47
|
+
"@types/node": "^18.11.9",
|
|
48
|
+
"@typescript-eslint/eslint-plugin": "^5.45.0",
|
|
49
|
+
"@typescript-eslint/parser": "^5.45.0",
|
|
50
|
+
"eslint": "^8.28.0",
|
|
51
|
+
"jest": "^29.3.1",
|
|
52
|
+
"rimraf": "^3.0.2",
|
|
53
|
+
"ts-jest": "^29.0.3",
|
|
54
|
+
"ts-node": "^10.9.1",
|
|
55
|
+
"typescript": "^4.9.3"
|
|
56
|
+
},
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"@types/sqlite3": "^3.1.8",
|
|
59
|
+
"prettier": "^2.8.0",
|
|
60
|
+
"sqlite": "3"
|
|
61
|
+
}
|
|
62
|
+
}
|