@designliquido/delegua-node 1.3.15 → 1.3.17
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/bin/package.json +11 -11
- package/delegua.d.ts +21 -21
- package/delegua.js +74 -74
- package/delegua.js.map +1 -1
- package/depuracao/index.d.ts +1 -1
- package/depuracao/index.js +17 -17
- package/depuracao/servidor-depuracao.d.ts +41 -42
- package/depuracao/servidor-depuracao.d.ts.map +1 -1
- package/depuracao/servidor-depuracao.js +297 -297
- package/depuracao/servidor-depuracao.js.map +1 -1
- package/execucao.d.ts +1 -1
- package/execucao.js +48 -48
- package/execucao.js.map +1 -1
- package/formatadores/index.d.ts +6 -6
- package/formatadores/index.js +57 -57
- package/formatadores/index.js.map +1 -1
- package/importador/importador-javascript.d.ts +15 -15
- package/importador/importador-javascript.js +62 -62
- package/importador/importador-javascript.js.map +1 -1
- package/importador/importador.d.ts +28 -28
- package/importador/importador.js +81 -81
- package/importador/importador.js.map +1 -1
- package/importador/index.d.ts +2 -2
- package/importador/index.js +18 -18
- package/importador/retorno-importador.d.ts +9 -9
- package/importador/retorno-importador.js +2 -2
- package/index.d.ts +3 -3
- package/index.js +19 -19
- package/interfaces/delegua-interface.d.ts +6 -6
- package/interfaces/delegua-interface.js +2 -2
- package/interfaces/importador-interface.d.ts +8 -8
- package/interfaces/importador-interface.js +2 -2
- package/interfaces/index.d.ts +2 -2
- package/interfaces/index.js +18 -18
- package/interfaces/nucleo-execucao-interface.d.ts +12 -12
- package/interfaces/nucleo-execucao-interface.js +2 -2
- package/interpretador/index.d.ts +1 -1
- package/interpretador/index.js +17 -17
- package/interpretador/interpretador-com-depuracao-importacao.d.ts +15 -15
- package/interpretador/interpretador-com-depuracao-importacao.js +76 -76
- package/interpretador/interpretador-com-depuracao-importacao.js.map +1 -1
- package/interpretador/interpretador.d.ts +19 -19
- package/interpretador/interpretador.js +80 -80
- package/interpretador/interpretador.js.map +1 -1
- package/interpretador/mecanismo-importacao-bibliotecas.d.ts +2 -2
- package/interpretador/mecanismo-importacao-bibliotecas.js +131 -132
- package/interpretador/mecanismo-importacao-bibliotecas.js.map +1 -1
- package/lexador/lexador-json.d.ts +20 -20
- package/lexador/lexador-json.js +64 -64
- package/lexador/lexador-json.js.map +1 -1
- package/nucleo-comum.d.ts +12 -12
- package/nucleo-comum.js +48 -48
- package/nucleo-comum.js.map +1 -1
- package/nucleo-execucao.d.ts +72 -72
- package/nucleo-execucao.js +358 -358
- package/nucleo-execucao.js.map +1 -1
- package/nucleo-traducao.d.ts +36 -36
- package/nucleo-traducao.js +127 -127
- package/nucleo-traducao.js.map +1 -1
- package/package.json +11 -11
|
@@ -1,133 +1,132 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
//
|
|
72
|
-
//
|
|
73
|
-
//
|
|
74
|
-
//
|
|
75
|
-
//
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
let resultado = null;
|
|
93
|
-
const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
|
94
|
-
const global = processoFilho.spawnSync(npm, ['root', '--location=global']);
|
|
95
|
-
const caminhoAbsoluto = caminho.join(global.output[1].toString().trim()) + `\\${caminhoRelativo}\\package.json`;
|
|
96
|
-
let arquivoInicio = JSON.parse(sistemaArquivos.readFileSync(caminhoAbsoluto, 'utf-8')).main || 'index.js';
|
|
97
|
-
await (
|
|
98
|
-
`\\${caminhoRelativo}\\${arquivoInicio.replace('./', '')}
|
|
99
|
-
resultado = resposta;
|
|
100
|
-
});
|
|
101
|
-
return resultado;
|
|
102
|
-
};
|
|
103
|
-
const importarPacoteDeleguaCompleto = async (nome) => {
|
|
104
|
-
return await importarPacoteCaminhoBase(`delegua\\node_modules\\${nome}`);
|
|
105
|
-
};
|
|
106
|
-
const importarPacoteExternoCompleto = async (nome) => {
|
|
107
|
-
return await importarPacoteCaminhoBase(nome);
|
|
108
|
-
};
|
|
109
|
-
const verificarModulosDelegua = (nome) => {
|
|
110
|
-
const modulos = {
|
|
111
|
-
estatistica: '@designliquido/delegua-estatistica',
|
|
112
|
-
estatística: '@designliquido/delegua-estatistica',
|
|
113
|
-
fisica: '@designliquido/delegua-fisica',
|
|
114
|
-
física: '@designliquido/delegua-fisica',
|
|
115
|
-
http: '@designliquido/delegua-http',
|
|
116
|
-
json: '@designliquido/delegua-json',
|
|
117
|
-
matematica: '@designliquido/delegua-matematica',
|
|
118
|
-
matemática: '@designliquido/delegua-matematica',
|
|
119
|
-
tempo: '@designliquido/delegua-tempo',
|
|
120
|
-
};
|
|
121
|
-
if (Object.keys(modulos).includes(nome)) {
|
|
122
|
-
return modulos[nome].toString();
|
|
123
|
-
}
|
|
124
|
-
return false;
|
|
125
|
-
};
|
|
126
|
-
async function default_1(nome) {
|
|
127
|
-
const nomeBibliotecaResolvido = verificarModulosDelegua(nome);
|
|
128
|
-
return nomeBibliotecaResolvido
|
|
129
|
-
? carregarBibliotecaDelegua(String(nomeBibliotecaResolvido))
|
|
130
|
-
: await carregarBiblioteca(nome, nome);
|
|
131
|
-
}
|
|
132
|
-
exports.default = default_1;
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.default = default_1;
|
|
27
|
+
const processoFilho = __importStar(require("child_process"));
|
|
28
|
+
const caminho = __importStar(require("path"));
|
|
29
|
+
const sistemaArquivos = __importStar(require("fs"));
|
|
30
|
+
const excecoes_1 = require("@designliquido/delegua/excecoes");
|
|
31
|
+
const funcao_padrao_1 = require("@designliquido/delegua/estruturas/funcao-padrao");
|
|
32
|
+
const modulo_1 = require("@designliquido/delegua/estruturas/modulo");
|
|
33
|
+
const classe_padrao_1 = require("@designliquido/delegua/estruturas/classe-padrao");
|
|
34
|
+
const carregarBibliotecaDelegua = (nome) => {
|
|
35
|
+
let dadosDoModulo;
|
|
36
|
+
try {
|
|
37
|
+
dadosDoModulo = require(nome);
|
|
38
|
+
}
|
|
39
|
+
catch (erro) {
|
|
40
|
+
// Biblioteca não existe localmente. Tentar importação global
|
|
41
|
+
try {
|
|
42
|
+
dadosDoModulo = importarPacoteDeleguaCompleto(nome);
|
|
43
|
+
}
|
|
44
|
+
catch (erro2) {
|
|
45
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(null, `Biblioteca ${nome} não encontrada para importação.`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return modularizarBiblioteca(dadosDoModulo, nome);
|
|
49
|
+
};
|
|
50
|
+
const carregarBiblioteca = async (nomeDaBiblioteca, caminhoDaBiblioteca) => {
|
|
51
|
+
let dadosDoModulo;
|
|
52
|
+
try {
|
|
53
|
+
dadosDoModulo = require(caminhoDaBiblioteca);
|
|
54
|
+
}
|
|
55
|
+
catch (erro) {
|
|
56
|
+
try {
|
|
57
|
+
dadosDoModulo = await importarPacoteExternoCompleto(nomeDaBiblioteca);
|
|
58
|
+
}
|
|
59
|
+
catch (erro2) {
|
|
60
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(null, `Biblioteca ${nomeDaBiblioteca} não encontrada para importação. Informações adicionais: ${(erro2 === null || erro2 === void 0 ? void 0 : erro2.message) || '(nenhuma)'}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return modularizarBiblioteca(dadosDoModulo, nomeDaBiblioteca);
|
|
64
|
+
};
|
|
65
|
+
const modularizarBiblioteca = (dadosDoModulo, nome) => {
|
|
66
|
+
const novoModulo = new modulo_1.DeleguaModulo(nome);
|
|
67
|
+
const chaves = Object.keys(dadosDoModulo);
|
|
68
|
+
for (let i = 0; i < chaves.length; i++) {
|
|
69
|
+
const moduloAtual = dadosDoModulo[chaves[i]];
|
|
70
|
+
if (typeof moduloAtual === 'function') {
|
|
71
|
+
// Por definição, funções tradicionais e classes são identificadas em JavaScript como "functions".
|
|
72
|
+
// A primeira heurística era verificando a propriedade `prototype`, mas isso não funciona bem
|
|
73
|
+
// porque classes e funções avulsas todas possuem prototype.
|
|
74
|
+
// Uma heurística nova é converter `moduloAtual` para `string` e verificar se a declaração começa com `class`.
|
|
75
|
+
// Se sim, podemos dizer que a "function" é uma classe padrão.
|
|
76
|
+
// Caso contrário, é uma função (`FuncaoPadrao`).
|
|
77
|
+
if (String(moduloAtual).startsWith('class')) {
|
|
78
|
+
const classePadrao = new classe_padrao_1.ClassePadrao(chaves[i], moduloAtual);
|
|
79
|
+
novoModulo.componentes[chaves[i]] = classePadrao;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
novoModulo.componentes[chaves[i]] = new funcao_padrao_1.FuncaoPadrao(moduloAtual.length, moduloAtual);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
novoModulo.componentes[chaves[i]] = moduloAtual;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return novoModulo;
|
|
90
|
+
};
|
|
91
|
+
const importarPacoteCaminhoBase = async (caminhoRelativo) => {
|
|
92
|
+
let resultado = null;
|
|
93
|
+
const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
|
94
|
+
const global = processoFilho.spawnSync(npm, ['root', '--location=global']);
|
|
95
|
+
const caminhoAbsoluto = caminho.join(global.output[1].toString().trim()) + `\\${caminhoRelativo}\\package.json`;
|
|
96
|
+
let arquivoInicio = JSON.parse(sistemaArquivos.readFileSync(caminhoAbsoluto, 'utf-8')).main || 'index.js';
|
|
97
|
+
await Promise.resolve(`${caminho.join('file:///' + global.output[1].toString().trim()) +
|
|
98
|
+
`\\${caminhoRelativo}\\${arquivoInicio.replace('./', '')}`}`).then(s => __importStar(require(s))).then((resposta) => {
|
|
99
|
+
resultado = resposta;
|
|
100
|
+
});
|
|
101
|
+
return resultado;
|
|
102
|
+
};
|
|
103
|
+
const importarPacoteDeleguaCompleto = async (nome) => {
|
|
104
|
+
return await importarPacoteCaminhoBase(`delegua\\node_modules\\${nome}`);
|
|
105
|
+
};
|
|
106
|
+
const importarPacoteExternoCompleto = async (nome) => {
|
|
107
|
+
return await importarPacoteCaminhoBase(nome);
|
|
108
|
+
};
|
|
109
|
+
const verificarModulosDelegua = (nome) => {
|
|
110
|
+
const modulos = {
|
|
111
|
+
estatistica: '@designliquido/delegua-estatistica',
|
|
112
|
+
estatística: '@designliquido/delegua-estatistica',
|
|
113
|
+
fisica: '@designliquido/delegua-fisica',
|
|
114
|
+
física: '@designliquido/delegua-fisica',
|
|
115
|
+
http: '@designliquido/delegua-http',
|
|
116
|
+
json: '@designliquido/delegua-json',
|
|
117
|
+
matematica: '@designliquido/delegua-matematica',
|
|
118
|
+
matemática: '@designliquido/delegua-matematica',
|
|
119
|
+
tempo: '@designliquido/delegua-tempo',
|
|
120
|
+
};
|
|
121
|
+
if (Object.keys(modulos).includes(nome)) {
|
|
122
|
+
return modulos[nome].toString();
|
|
123
|
+
}
|
|
124
|
+
return false;
|
|
125
|
+
};
|
|
126
|
+
async function default_1(nome) {
|
|
127
|
+
const nomeBibliotecaResolvido = verificarModulosDelegua(nome);
|
|
128
|
+
return nomeBibliotecaResolvido
|
|
129
|
+
? carregarBibliotecaDelegua(String(nomeBibliotecaResolvido))
|
|
130
|
+
: await carregarBiblioteca(nome, nome);
|
|
131
|
+
}
|
|
133
132
|
//# sourceMappingURL=mecanismo-importacao-bibliotecas.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mecanismo-importacao-bibliotecas.js","sourceRoot":"","sources":["../../fontes/interpretador/mecanismo-importacao-bibliotecas.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"mecanismo-importacao-bibliotecas.js","sourceRoot":"","sources":["../../fontes/interpretador/mecanismo-importacao-bibliotecas.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA0HA,4BAKC;AA/HD,6DAA+C;AAC/C,8CAAgC;AAChC,oDAAsC;AAEtC,8DAAwE;AACxE,mFAA+E;AAC/E,qEAAyE;AACzE,mFAA+E;AAE/E,MAAM,yBAAyB,GAAG,CAAC,IAAY,EAAE,EAAE;IAC/C,IAAI,aAAkB,CAAC;IAEvB,IAAI,CAAC;QACD,aAAa,GAAG,OAAO,CAAC,IAAI,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CAAC,CAAC,QAAQ,EAAE,CAAC;IACpC,CAAC;IAED,OAAO,KAAK,CAAC;AACjB,CAAC,CAAC;AAEa,KAAK,oBAAW,IAAY;IACvC,MAAM,uBAAuB,GAAqB,uBAAuB,CAAC,IAAI,CAAC,CAAC;IAChF,OAAO,uBAAuB;QAC1B,CAAC,CAAC,yBAAyB,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAC;QAC5D,CAAC,CAAC,MAAM,kBAAkB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Lexador JSON importado do pacote https://github.com/joeattardi/json-colorizer,
|
|
3
|
-
* com algumas modificações.
|
|
4
|
-
*/
|
|
5
|
-
export declare class LexadorJson {
|
|
6
|
-
tokenTypes: {
|
|
7
|
-
regex: RegExp;
|
|
8
|
-
tokenType: string;
|
|
9
|
-
}[];
|
|
10
|
-
getTokens(json: any, options?: any): any[];
|
|
11
|
-
/**
|
|
12
|
-
* @author Willian Magalhães Gonçalves
|
|
13
|
-
* @description Are all tokens analyzed?
|
|
14
|
-
* @param {*} input - Input
|
|
15
|
-
* @param {*} foundToken - Found token
|
|
16
|
-
* @returns {boolean} checkResult - Check result
|
|
17
|
-
* @private
|
|
18
|
-
*/
|
|
19
|
-
private _allTokensAnalyzed;
|
|
20
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Lexador JSON importado do pacote https://github.com/joeattardi/json-colorizer,
|
|
3
|
+
* com algumas modificações.
|
|
4
|
+
*/
|
|
5
|
+
export declare class LexadorJson {
|
|
6
|
+
tokenTypes: {
|
|
7
|
+
regex: RegExp;
|
|
8
|
+
tokenType: string;
|
|
9
|
+
}[];
|
|
10
|
+
getTokens(json: any, options?: any): any[];
|
|
11
|
+
/**
|
|
12
|
+
* @author Willian Magalhães Gonçalves
|
|
13
|
+
* @description Are all tokens analyzed?
|
|
14
|
+
* @param {*} input - Input
|
|
15
|
+
* @param {*} foundToken - Found token
|
|
16
|
+
* @returns {boolean} checkResult - Check result
|
|
17
|
+
* @private
|
|
18
|
+
*/
|
|
19
|
+
private _allTokensAnalyzed;
|
|
20
|
+
}
|
|
21
21
|
//# sourceMappingURL=lexador-json.d.ts.map
|
package/lexador/lexador-json.js
CHANGED
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LexadorJson = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Lexador JSON importado do pacote https://github.com/joeattardi/json-colorizer,
|
|
6
|
-
* com algumas modificações.
|
|
7
|
-
*/
|
|
8
|
-
class LexadorJson {
|
|
9
|
-
constructor() {
|
|
10
|
-
this.tokenTypes = [
|
|
11
|
-
{ regex: /^\s+/, tokenType: "WHITESPACE" },
|
|
12
|
-
{ regex: /^{/, tokenType: "OPEN_BRACE" },
|
|
13
|
-
{ regex: /^}/, tokenType: "CLOSE_BRACE" },
|
|
14
|
-
{ regex: /^\[/, tokenType: "OPEN_BRACKET" },
|
|
15
|
-
{ regex: /^\]/, tokenType: "CLOSE_BRACKET" },
|
|
16
|
-
{ regex: /^:/, tokenType: "COLON" },
|
|
17
|
-
{ regex: /^,/, tokenType: "COMMA" },
|
|
18
|
-
{ regex: /^-?\d+(?:\.\d+)?(?:e[+-]?\d+)?/i, tokenType: "NUMBER_LITERAL" },
|
|
19
|
-
{ regex: /^"(?:\\.|[^"\\])*"(?=\s*:)/, tokenType: "STRING_KEY" },
|
|
20
|
-
{ regex: /^"(?:\\.|[^"\\])*"/, tokenType: "STRING_LITERAL" },
|
|
21
|
-
{ regex: /^true|^false/, tokenType: "BOOLEAN_LITERAL" },
|
|
22
|
-
{ regex: /^null/, tokenType: "NULL_LITERAL" },
|
|
23
|
-
];
|
|
24
|
-
}
|
|
25
|
-
getTokens(json, options = {}) {
|
|
26
|
-
let input;
|
|
27
|
-
if (options.pretty) {
|
|
28
|
-
const inputObj = typeof json === "string" ? JSON.parse(json) : json;
|
|
29
|
-
input = JSON.stringify(inputObj, null, 2);
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
input = typeof json === "string" ? json : JSON.stringify(json);
|
|
33
|
-
}
|
|
34
|
-
let tokens = [];
|
|
35
|
-
let foundToken;
|
|
36
|
-
do {
|
|
37
|
-
foundToken = false;
|
|
38
|
-
for (let i = 0; i < this.tokenTypes.length; i++) {
|
|
39
|
-
const match = this.tokenTypes[i].regex.exec(input);
|
|
40
|
-
if (match) {
|
|
41
|
-
tokens.push({ type: this.tokenTypes[i].tokenType, value: match[0] });
|
|
42
|
-
input = input.substring(match[0].length);
|
|
43
|
-
foundToken = true;
|
|
44
|
-
break;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
} while (this._allTokensAnalyzed(input, foundToken));
|
|
48
|
-
return tokens;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* @author Willian Magalhães Gonçalves
|
|
52
|
-
* @description Are all tokens analyzed?
|
|
53
|
-
* @param {*} input - Input
|
|
54
|
-
* @param {*} foundToken - Found token
|
|
55
|
-
* @returns {boolean} checkResult - Check result
|
|
56
|
-
* @private
|
|
57
|
-
*/
|
|
58
|
-
_allTokensAnalyzed(input, foundToken) {
|
|
59
|
-
const safeInput = input || {};
|
|
60
|
-
const inputLength = safeInput.length;
|
|
61
|
-
return inputLength > 0 && foundToken;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
exports.LexadorJson = LexadorJson;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LexadorJson = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Lexador JSON importado do pacote https://github.com/joeattardi/json-colorizer,
|
|
6
|
+
* com algumas modificações.
|
|
7
|
+
*/
|
|
8
|
+
class LexadorJson {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.tokenTypes = [
|
|
11
|
+
{ regex: /^\s+/, tokenType: "WHITESPACE" },
|
|
12
|
+
{ regex: /^{/, tokenType: "OPEN_BRACE" },
|
|
13
|
+
{ regex: /^}/, tokenType: "CLOSE_BRACE" },
|
|
14
|
+
{ regex: /^\[/, tokenType: "OPEN_BRACKET" },
|
|
15
|
+
{ regex: /^\]/, tokenType: "CLOSE_BRACKET" },
|
|
16
|
+
{ regex: /^:/, tokenType: "COLON" },
|
|
17
|
+
{ regex: /^,/, tokenType: "COMMA" },
|
|
18
|
+
{ regex: /^-?\d+(?:\.\d+)?(?:e[+-]?\d+)?/i, tokenType: "NUMBER_LITERAL" },
|
|
19
|
+
{ regex: /^"(?:\\.|[^"\\])*"(?=\s*:)/, tokenType: "STRING_KEY" },
|
|
20
|
+
{ regex: /^"(?:\\.|[^"\\])*"/, tokenType: "STRING_LITERAL" },
|
|
21
|
+
{ regex: /^true|^false/, tokenType: "BOOLEAN_LITERAL" },
|
|
22
|
+
{ regex: /^null/, tokenType: "NULL_LITERAL" },
|
|
23
|
+
];
|
|
24
|
+
}
|
|
25
|
+
getTokens(json, options = {}) {
|
|
26
|
+
let input;
|
|
27
|
+
if (options.pretty) {
|
|
28
|
+
const inputObj = typeof json === "string" ? JSON.parse(json) : json;
|
|
29
|
+
input = JSON.stringify(inputObj, null, 2);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
input = typeof json === "string" ? json : JSON.stringify(json);
|
|
33
|
+
}
|
|
34
|
+
let tokens = [];
|
|
35
|
+
let foundToken;
|
|
36
|
+
do {
|
|
37
|
+
foundToken = false;
|
|
38
|
+
for (let i = 0; i < this.tokenTypes.length; i++) {
|
|
39
|
+
const match = this.tokenTypes[i].regex.exec(input);
|
|
40
|
+
if (match) {
|
|
41
|
+
tokens.push({ type: this.tokenTypes[i].tokenType, value: match[0] });
|
|
42
|
+
input = input.substring(match[0].length);
|
|
43
|
+
foundToken = true;
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
} while (this._allTokensAnalyzed(input, foundToken));
|
|
48
|
+
return tokens;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* @author Willian Magalhães Gonçalves
|
|
52
|
+
* @description Are all tokens analyzed?
|
|
53
|
+
* @param {*} input - Input
|
|
54
|
+
* @param {*} foundToken - Found token
|
|
55
|
+
* @returns {boolean} checkResult - Check result
|
|
56
|
+
* @private
|
|
57
|
+
*/
|
|
58
|
+
_allTokensAnalyzed(input, foundToken) {
|
|
59
|
+
const safeInput = input || {};
|
|
60
|
+
const inputLength = safeInput.length;
|
|
61
|
+
return inputLength > 0 && foundToken;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.LexadorJson = LexadorJson;
|
|
65
65
|
//# sourceMappingURL=lexador-json.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lexador-json.js","sourceRoot":"","sources":["../../fontes/lexador/lexador-json.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,MAAa,WAAW;IAAxB;QACE,eAAU,GAAG;YACX,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE;YAC1C,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE;YACxC,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,aAAa,EAAE;YACzC,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE;YAC3C,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE;YAC5C,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE;YACnC,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE;YACnC,EAAE,KAAK,EAAE,iCAAiC,EAAE,SAAS,EAAE,gBAAgB,EAAE;YACzE,EAAE,KAAK,EAAE,4BAA4B,EAAE,SAAS,EAAE,YAAY,EAAE;YAChE,EAAE,KAAK,EAAE,oBAAoB,EAAE,S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ChB,CAAC;IAED;;;;;;;OAOG;IACK,kBAAkB,CAAC,KAAU,EAAE,UAAe;QACpD,MAAM,SAAS,GAAG,KAAK,IAAI,EAAE,CAAC;QAE9B,MAAM,WAAW,GAAG,SAAS,CAAC,MAAM,CAAC;QACrC,OAAO,WAAW,GAAG,CAAC,IAAI,UAAU,CAAC;IACvC,CAAC;CACF;AA3DD,kCA2DC"}
|
package/nucleo-comum.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { SimboloInterface } from "@designliquido/delegua/interfaces";
|
|
2
|
-
import { RetornoImportador } from "./importador";
|
|
3
|
-
export declare abstract class NucleoComum {
|
|
4
|
-
/**
|
|
5
|
-
* Verifica erros nas etapas de lexação e avaliação sintática.
|
|
6
|
-
* @param retornoImportador Um objeto que implementa a interface RetornoImportador.
|
|
7
|
-
* @returns Verdadeiro se há erros. Falso caso contrário.
|
|
8
|
-
*/
|
|
9
|
-
protected afericaoErros(retornoImportador: RetornoImportador<any, any>): boolean;
|
|
10
|
-
protected reportar(linha: number, onde: any, mensagem: string): void;
|
|
11
|
-
protected erro(simbolo: SimboloInterface, mensagemDeErro: string): void;
|
|
12
|
-
}
|
|
1
|
+
import { SimboloInterface } from "@designliquido/delegua/interfaces";
|
|
2
|
+
import { RetornoImportador } from "./importador";
|
|
3
|
+
export declare abstract class NucleoComum {
|
|
4
|
+
/**
|
|
5
|
+
* Verifica erros nas etapas de lexação e avaliação sintática.
|
|
6
|
+
* @param retornoImportador Um objeto que implementa a interface RetornoImportador.
|
|
7
|
+
* @returns Verdadeiro se há erros. Falso caso contrário.
|
|
8
|
+
*/
|
|
9
|
+
protected afericaoErros(retornoImportador: RetornoImportador<any, any>): boolean;
|
|
10
|
+
protected reportar(linha: number, onde: any, mensagem: string): void;
|
|
11
|
+
protected erro(simbolo: SimboloInterface, mensagemDeErro: string): void;
|
|
12
|
+
}
|
|
13
13
|
//# sourceMappingURL=nucleo-comum.d.ts.map
|
package/nucleo-comum.js
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
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.NucleoComum = void 0;
|
|
7
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
-
const delegua_1 = __importDefault(require("@designliquido/delegua/tipos-de-simbolos/delegua"));
|
|
9
|
-
class NucleoComum {
|
|
10
|
-
/**
|
|
11
|
-
* Verifica erros nas etapas de lexação e avaliação sintática.
|
|
12
|
-
* @param retornoImportador Um objeto que implementa a interface RetornoImportador.
|
|
13
|
-
* @returns Verdadeiro se há erros. Falso caso contrário.
|
|
14
|
-
*/
|
|
15
|
-
afericaoErros(retornoImportador) {
|
|
16
|
-
if (retornoImportador.retornoLexador.erros.length > 0) {
|
|
17
|
-
for (const erroLexador of retornoImportador.retornoLexador.erros) {
|
|
18
|
-
this.reportar(erroLexador.linha, ` no '${erroLexador.caractere}'`, erroLexador.mensagem);
|
|
19
|
-
}
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
if (retornoImportador.retornoAvaliadorSintatico.erros.length > 0) {
|
|
23
|
-
for (const erroAvaliadorSintatico of retornoImportador.retornoAvaliadorSintatico.erros) {
|
|
24
|
-
this.erro(erroAvaliadorSintatico.simbolo, erroAvaliadorSintatico.message);
|
|
25
|
-
}
|
|
26
|
-
return true;
|
|
27
|
-
}
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
reportar(linha, onde, mensagem) {
|
|
31
|
-
/* if (this.nomeArquivo)
|
|
32
|
-
console.error(
|
|
33
|
-
chalk.red(`[Arquivo: ${this.nomeArquivo}] [Linha: ${linha}]`) + ` Erro${onde}: ${mensagem}`
|
|
34
|
-
);
|
|
35
|
-
else */
|
|
36
|
-
console.error(chalk_1.default.red(`[Linha: ${linha}]`) + ` Erro${onde}: ${mensagem}`);
|
|
37
|
-
}
|
|
38
|
-
erro(simbolo, mensagemDeErro) {
|
|
39
|
-
const _simbolo = simbolo || { tipo: delegua_1.default.EOF, linha: -1, lexema: '(indefinido)' };
|
|
40
|
-
if (_simbolo.tipo === delegua_1.default.EOF) {
|
|
41
|
-
this.reportar(Number(_simbolo.linha), ' no final do código', mensagemDeErro);
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
this.reportar(Number(_simbolo.linha), ` no '${_simbolo.lexema}'`, mensagemDeErro);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
exports.NucleoComum = NucleoComum;
|
|
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.NucleoComum = void 0;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const delegua_1 = __importDefault(require("@designliquido/delegua/tipos-de-simbolos/delegua"));
|
|
9
|
+
class NucleoComum {
|
|
10
|
+
/**
|
|
11
|
+
* Verifica erros nas etapas de lexação e avaliação sintática.
|
|
12
|
+
* @param retornoImportador Um objeto que implementa a interface RetornoImportador.
|
|
13
|
+
* @returns Verdadeiro se há erros. Falso caso contrário.
|
|
14
|
+
*/
|
|
15
|
+
afericaoErros(retornoImportador) {
|
|
16
|
+
if (retornoImportador.retornoLexador.erros.length > 0) {
|
|
17
|
+
for (const erroLexador of retornoImportador.retornoLexador.erros) {
|
|
18
|
+
this.reportar(erroLexador.linha, ` no '${erroLexador.caractere}'`, erroLexador.mensagem);
|
|
19
|
+
}
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
if (retornoImportador.retornoAvaliadorSintatico.erros.length > 0) {
|
|
23
|
+
for (const erroAvaliadorSintatico of retornoImportador.retornoAvaliadorSintatico.erros) {
|
|
24
|
+
this.erro(erroAvaliadorSintatico.simbolo, erroAvaliadorSintatico.message);
|
|
25
|
+
}
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
reportar(linha, onde, mensagem) {
|
|
31
|
+
/* if (this.nomeArquivo)
|
|
32
|
+
console.error(
|
|
33
|
+
chalk.red(`[Arquivo: ${this.nomeArquivo}] [Linha: ${linha}]`) + ` Erro${onde}: ${mensagem}`
|
|
34
|
+
);
|
|
35
|
+
else */
|
|
36
|
+
console.error(chalk_1.default.red(`[Linha: ${linha}]`) + ` Erro${onde}: ${mensagem}`);
|
|
37
|
+
}
|
|
38
|
+
erro(simbolo, mensagemDeErro) {
|
|
39
|
+
const _simbolo = simbolo || { tipo: delegua_1.default.EOF, linha: -1, lexema: '(indefinido)' };
|
|
40
|
+
if (_simbolo.tipo === delegua_1.default.EOF) {
|
|
41
|
+
this.reportar(Number(_simbolo.linha), ' no final do código', mensagemDeErro);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
this.reportar(Number(_simbolo.linha), ` no '${_simbolo.lexema}'`, mensagemDeErro);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.NucleoComum = NucleoComum;
|
|
49
49
|
//# sourceMappingURL=nucleo-comum.js.map
|
package/nucleo-comum.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nucleo-comum.js","sourceRoot":"","sources":["../fontes/nucleo-comum.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,+FAA+E;AAK/E,MAAsB,WAAW;IAC7B;;;;OAIG;IACO,aAAa,CAAC,iBAA8C;QAClE,IAAI,iBAAiB,CAAC,cAAc,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"nucleo-comum.js","sourceRoot":"","sources":["../fontes/nucleo-comum.ts"],"names":[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