raizcode-ofc 1.8.0 → 1.10.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/compilador.js +301 -86
- package/exemplos/teste.js +6 -0
- package/exemplos/teste.rc +5 -0
- package/icons/raizcode-icon-theme.json +17 -0
- package/package.json +11 -37
package/compilador.js
CHANGED
|
@@ -3,101 +3,255 @@
|
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const path = require('path');
|
|
5
5
|
const os = require('os');
|
|
6
|
-
const http = require('http');
|
|
6
|
+
const http = require('http');
|
|
7
7
|
const { execSync, exec } = require('child_process');
|
|
8
8
|
|
|
9
9
|
const args = process.argv.slice(2);
|
|
10
10
|
const arquivoOuCmd = args[0];
|
|
11
11
|
|
|
12
|
-
//
|
|
12
|
+
// ─────────────────────────────────────────
|
|
13
|
+
// SETUP DO VSCODE
|
|
14
|
+
// ─────────────────────────────────────────
|
|
13
15
|
if (arquivoOuCmd === '--setup') {
|
|
14
16
|
const extDir = path.join(os.homedir(), '.vscode', 'extensions', 'raizcode-extension');
|
|
15
17
|
try {
|
|
16
18
|
if (!fs.existsSync(extDir)) fs.mkdirSync(extDir, { recursive: true });
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
|
|
20
|
+
// Copia arquivos necessários
|
|
21
|
+
['syntaxes', 'icons'].forEach(pasta => {
|
|
22
|
+
const src = path.join(__dirname, pasta);
|
|
23
|
+
const dest = path.join(extDir, pasta);
|
|
20
24
|
if (fs.existsSync(src)) {
|
|
21
|
-
|
|
22
|
-
else fs.copyFileSync(src, dest);
|
|
25
|
+
fs.cpSync(src, dest, { recursive: true });
|
|
23
26
|
}
|
|
24
27
|
});
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
|
|
29
|
+
// Gera o package.json da extensão VSCode com suporte a Temas de Ícones
|
|
30
|
+
const pkgExtensao = {
|
|
31
|
+
name: "raizcode-extension",
|
|
32
|
+
displayName: "Raizcode",
|
|
33
|
+
version: "1.9.0",
|
|
34
|
+
publisher: "riquefla",
|
|
35
|
+
engines: { vscode: "^1.60.0" },
|
|
36
|
+
contributes: {
|
|
37
|
+
languages: [
|
|
38
|
+
{
|
|
39
|
+
id: "raizcode",
|
|
40
|
+
aliases: ["Raizcode", "rc"],
|
|
41
|
+
extensions: [".rc"]
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
id: "raizcode-estrutura",
|
|
45
|
+
aliases: ["Raizcode Estrutura", "rcx"],
|
|
46
|
+
extensions: [".rcx"]
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
id: "raizcode-estilo",
|
|
50
|
+
aliases: ["Raizcode Estilo", "rcc"],
|
|
51
|
+
extensions: [".rcc"]
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
grammars: [
|
|
55
|
+
{
|
|
56
|
+
language: "raizcode",
|
|
57
|
+
scopeName: "source.rc",
|
|
58
|
+
path: "./syntaxes/raizcode.tmLanguage.json"
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
// Ativa o suporte oficial aos seus ícones no VS Code
|
|
62
|
+
iconThemes: [
|
|
63
|
+
{
|
|
64
|
+
id: "raizcode-icons",
|
|
65
|
+
label: "Raizcode Icons",
|
|
66
|
+
path: "./icons/raizcode-icon-theme.json"
|
|
67
|
+
}
|
|
68
|
+
]
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
fs.writeFileSync(
|
|
73
|
+
path.join(extDir, 'package.json'),
|
|
74
|
+
JSON.stringify(pkgExtensao, null, 2)
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
console.log("✅ Extensão Raizcode instalada! Reinicie o VS Code.");
|
|
78
|
+
console.log("💡 Lembre-se de selecionar 'Raizcode Icons' em: Arquivo > Preferências > Tema de Ícone de Arquivo");
|
|
79
|
+
} catch (e) {
|
|
80
|
+
console.error("❌ Erro no setup:", e.message);
|
|
81
|
+
}
|
|
27
82
|
process.exit();
|
|
28
83
|
}
|
|
29
84
|
|
|
30
|
-
//
|
|
31
|
-
|
|
85
|
+
// ─────────────────────────────────────────
|
|
86
|
+
// UTILITÁRIOS
|
|
87
|
+
// ─────────────────────────────────────────
|
|
32
88
|
|
|
33
|
-
//
|
|
89
|
+
// Abre o navegador de forma correta em qualquer sistema
|
|
90
|
+
function abrirNavegador(url) {
|
|
91
|
+
const plataforma = os.platform();
|
|
92
|
+
if (plataforma === 'win32') exec(`start ${url}`);
|
|
93
|
+
else if (plataforma === 'darwin') exec(`open ${url}`);
|
|
94
|
+
else if (process.env.TERM === 'xterm-termux' || fs.existsSync('/data/data/com.termux')) exec(`termux-open ${url}`);
|
|
95
|
+
else exec(`xdg-open ${url}`);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Reporta erros com número de linha para o usuário
|
|
99
|
+
function erroDeCompilacao(mensagem, numeroLinha) {
|
|
100
|
+
console.error(`\n❌ Erro na linha ${numeroLinha}: ${mensagem}`);
|
|
101
|
+
console.error(` Verifique seu código .rc e tente novamente.\n`);
|
|
102
|
+
process.exit(1);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// ─────────────────────────────────────────
|
|
106
|
+
// TRADUTORES DE ESTRUTURA (RCX) E ESTILO (RCC)
|
|
107
|
+
// ─────────────────────────────────────────
|
|
34
108
|
|
|
35
109
|
function traduzirEstrutura(conteudo) {
|
|
36
|
-
if(!conteudo) return "";
|
|
37
|
-
|
|
110
|
+
if (!conteudo) return "";
|
|
111
|
+
|
|
112
|
+
return conteudo.split('\n').map((linha, idx) => {
|
|
38
113
|
let t = linha.trim();
|
|
39
|
-
if(!t) return "";
|
|
40
|
-
|
|
41
|
-
|
|
114
|
+
if (!t || t.startsWith('//')) return "";
|
|
115
|
+
|
|
116
|
+
// Captura string entre aspas de forma segura
|
|
117
|
+
const pegarTexto = (cmd) => {
|
|
118
|
+
const match = t.match(new RegExp(`^${cmd}\\s+"(.*)"`));
|
|
119
|
+
return match ? match[1] : t.replace(cmd + ' ', '').replace(/"/g, '');
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
if (t.startsWith('titulo ')) return `<h1>${pegarTexto('titulo')}</h1>`;
|
|
123
|
+
if (t.startsWith('subtitulo ')) return `<h2>${pegarTexto('subtitulo')}</h2>`;
|
|
124
|
+
if (t.startsWith('texto ')) return `<p>${pegarTexto('texto')}</p>`;
|
|
125
|
+
if (t.startsWith('link ')) {
|
|
126
|
+
// link "Clique aqui" url "https://..."
|
|
127
|
+
const m = t.match(/^link\s+"(.+?)"\s+url\s+"(.+?)"/);
|
|
128
|
+
if (m) return `<a href="${m[2]}" target="_blank">${m[1]}</a>`;
|
|
129
|
+
}
|
|
130
|
+
if (t.startsWith('imagem ')) return `<img src="${pegarTexto('imagem')}" alt="imagem" style="max-width:100%;">`;
|
|
42
131
|
if (t.startsWith('botao ')) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return `<button id="${id}">${texto}</button>`;
|
|
132
|
+
const m = t.match(/^botao\s+"(.+?)"\s+id\s+"(.+?)"/);
|
|
133
|
+
if (m) return `<button id="${m[2]}">${m[1]}</button>`;
|
|
134
|
+
return `<button>${pegarTexto('botao')}</button>`;
|
|
47
135
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
136
|
+
if (t.startsWith('entrada ')) {
|
|
137
|
+
const m = t.match(/^entrada\s+id\s+"(.+?)"\s+dica\s+"(.+?)"/);
|
|
138
|
+
if (m) return `<input id="${m[1]}" placeholder="${m[2]}">`;
|
|
139
|
+
return `<input placeholder="${pegarTexto('entrada')}">`;
|
|
140
|
+
}
|
|
141
|
+
if (t.startsWith('caixa ')) return `<div class="${pegarTexto('caixa')}">`;
|
|
142
|
+
if (t === 'fim') return `</div>`;
|
|
143
|
+
|
|
144
|
+
return ``;
|
|
145
|
+
}).join('\n');
|
|
54
146
|
}
|
|
55
147
|
|
|
56
148
|
function traduzirEstilo(conteudo) {
|
|
57
|
-
if(!conteudo) return "";
|
|
58
|
-
|
|
149
|
+
if (!conteudo) return "";
|
|
150
|
+
return conteudo
|
|
59
151
|
.replace(/fundo:/g, 'background:')
|
|
60
152
|
.replace(/cor-texto:/g, 'color:')
|
|
153
|
+
.replace(/tamanho-texto:/g, 'font-size:')
|
|
154
|
+
.replace(/margem:/g, 'margin:')
|
|
155
|
+
.replace(/borda:/g, 'border:')
|
|
156
|
+
.replace(/arredondado:/g, 'border-radius:')
|
|
61
157
|
.replace(/verde-neon/g, '#00ff88')
|
|
62
|
-
.replace(/amarelo-neon/g, '#ffff00')
|
|
158
|
+
.replace(/amarelo-neon/g, '#ffff00')
|
|
159
|
+
.replace(/azul-neon/g, '#00cfff')
|
|
160
|
+
.replace(/vermelho-neon/g, '#ff4444')
|
|
63
161
|
.replace(/ao-passar-mouse:/g, '&:hover')
|
|
64
|
-
.replace(/estilo
|
|
65
|
-
.replace(/
|
|
66
|
-
return css;
|
|
162
|
+
.replace(/estilo\s+/g, '.')
|
|
163
|
+
.replace(/\bfim\b/g, '}');
|
|
67
164
|
}
|
|
68
165
|
|
|
69
|
-
//
|
|
70
|
-
|
|
166
|
+
// ─────────────────────────────────────────
|
|
167
|
+
// TRADUTOR PRINCIPAL (RC → JS)
|
|
168
|
+
// ─────────────────────────────────────────
|
|
169
|
+
|
|
170
|
+
function traduzir(linha, numeroLinha, contexto) {
|
|
71
171
|
let t = linha.trim();
|
|
72
|
-
if (!t || t.startsWith("//")) return
|
|
73
|
-
|
|
74
|
-
//
|
|
172
|
+
if (!t || t.startsWith("//")) return linha; // preserva indentação
|
|
173
|
+
|
|
174
|
+
// Título da página
|
|
75
175
|
if (t.startsWith('pagina ')) {
|
|
76
|
-
ehSite = true;
|
|
77
|
-
|
|
176
|
+
contexto.ehSite = true;
|
|
177
|
+
const titulo = t.replace(/^pagina\s+/, '');
|
|
78
178
|
return `document.title = ${titulo};`;
|
|
79
179
|
}
|
|
80
180
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
181
|
+
// UI: mostrar elemento na tela pelo id
|
|
182
|
+
if (t.startsWith('mostrar_tela ')) {
|
|
183
|
+
const m = t.match(/^mostrar_tela\s+"(.+?)"\s+em\s+"(.+?)"/);
|
|
184
|
+
if (m) return `document.getElementById("${m[2]}").innerText = "${m[1]}";`;
|
|
185
|
+
}
|
|
85
186
|
|
|
86
|
-
//
|
|
87
|
-
if (t.startsWith('
|
|
187
|
+
// Ao clicar: evento de clique
|
|
188
|
+
if (t.startsWith('ao_clicar ')) {
|
|
189
|
+
const m = t.match(/^ao_clicar\s+"(.+?)"/);
|
|
190
|
+
if (m) return `document.getElementById("${m[1]}").addEventListener("click", function() {`;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Comandos básicos
|
|
194
|
+
if (t.startsWith('alerta ')) return `alert(${t.replace(/^alerta\s+/, '')});`;
|
|
195
|
+
if (t.startsWith('mudar_fundo ')) return `document.body.style.background = ${t.replace(/^mudar_fundo\s+/, '')};`;
|
|
196
|
+
if (t.startsWith('mostrar ')) return `console.log(${t.replace(/^mostrar\s+/, '')});`;
|
|
197
|
+
|
|
198
|
+
// Variável com parsing correto de strings com espaços
|
|
88
199
|
if (t.startsWith('variavel ')) {
|
|
89
|
-
|
|
90
|
-
|
|
200
|
+
const m = t.match(/^variavel\s+(\w+)\s+(.*)/);
|
|
201
|
+
if (!m) erroDeCompilacao(`Sintaxe incorreta: "${t}" — Use: variavel nome "valor"`, numeroLinha);
|
|
202
|
+
return `let ${m[1]} = ${m[2]};`;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (t.startsWith('constante ')) {
|
|
206
|
+
const m = t.match(/^constante\s+(\w+)\s+(.*)/);
|
|
207
|
+
if (!m) erroDeCompilacao(`Sintaxe incorreta: "${t}" — Use: constante nome "valor"`, numeroLinha);
|
|
208
|
+
return `const ${m[1]} = ${m[2]};`;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// Estruturas de controle
|
|
212
|
+
if (t.startsWith('se ')) return `if (${t.replace(/^se\s+/, '').replace(/\bend\b/, '')}) {`;
|
|
213
|
+
if (t === 'senao') return `} else {`;
|
|
214
|
+
if (t.startsWith('senaose ')) return `} else if (${t.replace(/^senaose\s+/, '')}) {`;
|
|
215
|
+
if (t === 'fim') return `}`;
|
|
216
|
+
|
|
217
|
+
// Loops
|
|
218
|
+
if (t.startsWith('repetir ')) {
|
|
219
|
+
const m = t.match(/^repetir\s+(\d+)\s+vezes/);
|
|
220
|
+
if (m) return `for (let _i = 0; _i < ${m[1]}; _i++) {`;
|
|
221
|
+
}
|
|
222
|
+
if (t.startsWith('enquanto ')) return `while (${t.replace(/^enquanto\s+/, '')}) {`;
|
|
223
|
+
|
|
224
|
+
// Funções
|
|
225
|
+
if (t.startsWith('funcao ')) {
|
|
226
|
+
const m = t.match(/^funcao\s+(\w+)\s*\((.*)\)/);
|
|
227
|
+
if (m) return `function ${m[1]}(${m[2]}) {`;
|
|
91
228
|
}
|
|
92
|
-
if (t.startsWith('
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
229
|
+
if (t.startsWith('retornar ')) return `return ${t.replace(/^retornar\s+/, '')};`;
|
|
230
|
+
|
|
231
|
+
return t; // passa JS puro direto
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// ─────────────────────────────────────────
|
|
235
|
+
// VALIDAÇÃO DE BLOCOS
|
|
236
|
+
// ─────────────────────────────────────────
|
|
237
|
+
function validarBlocos(linhas) {
|
|
238
|
+
let pilha = 0;
|
|
239
|
+
linhas.forEach((linha, idx) => {
|
|
240
|
+
const t = linha.trim();
|
|
241
|
+
if (t.startsWith('se ') || t.startsWith('enquanto ') || t.startsWith('funcao ') || t.startsWith('repetir ') || t.startsWith('ao_clicar ')) pilha++;
|
|
242
|
+
if (t === 'fim') pilha--;
|
|
243
|
+
if (pilha < 0) erroDeCompilacao(`"fim" sobrando sem um bloco aberto.`, idx + 1);
|
|
244
|
+
});
|
|
245
|
+
if (pilha > 0) erroDeCompilacao(`Faltam ${pilha} "fim" para fechar bloco(s) abertos.`, linhas.length);
|
|
96
246
|
}
|
|
97
247
|
|
|
98
|
-
//
|
|
248
|
+
// ─────────────────────────────────────────
|
|
249
|
+
// PONTO DE ENTRADA
|
|
250
|
+
// ─────────────────────────────────────────
|
|
99
251
|
if (!arquivoOuCmd) {
|
|
100
|
-
console.log("🌱 Raizcode
|
|
252
|
+
console.log("🌱 Raizcode v1.9 — A linguagem brasileira");
|
|
253
|
+
console.log(" Uso: raizcode <arquivo.rc>");
|
|
254
|
+
console.log(" Setup VSCode: raizcode --setup");
|
|
101
255
|
process.exit();
|
|
102
256
|
}
|
|
103
257
|
|
|
@@ -105,79 +259,140 @@ const caminho = path.resolve(arquivoOuCmd);
|
|
|
105
259
|
const nomeBase = caminho.substring(0, caminho.lastIndexOf('.'));
|
|
106
260
|
|
|
107
261
|
if (!fs.existsSync(caminho)) {
|
|
108
|
-
console.
|
|
262
|
+
console.error(`❌ Arquivo não encontrado: ${arquivoOuCmd}`);
|
|
109
263
|
process.exit(1);
|
|
110
264
|
}
|
|
111
265
|
|
|
112
266
|
try {
|
|
113
267
|
const arqRcx = nomeBase + '.rcx';
|
|
114
|
-
const arqRcc = nomeBase + '.rcc';
|
|
115
|
-
|
|
268
|
+
const arqRcc = nomeBase + '.rcc';
|
|
269
|
+
|
|
116
270
|
let htmlExtra = "";
|
|
117
271
|
let cssExtra = "";
|
|
272
|
+
const contexto = { ehSite: false };
|
|
118
273
|
|
|
119
274
|
if (fs.existsSync(arqRcx)) {
|
|
120
275
|
htmlExtra = traduzirEstrutura(fs.readFileSync(arqRcx, 'utf-8'));
|
|
121
|
-
ehSite = true;
|
|
276
|
+
contexto.ehSite = true;
|
|
122
277
|
}
|
|
123
|
-
if (fs.existsSync(arqRcc)) {
|
|
278
|
+
if (fs.existsSync(arqRcc)) {
|
|
124
279
|
cssExtra = traduzirEstilo(fs.readFileSync(arqRcc, 'utf-8'));
|
|
125
|
-
ehSite = true;
|
|
280
|
+
contexto.ehSite = true;
|
|
126
281
|
}
|
|
127
282
|
|
|
128
283
|
const codigo = fs.readFileSync(caminho, 'utf-8');
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
|
|
284
|
+
const linhas = codigo.split('\n');
|
|
285
|
+
|
|
286
|
+
// Valida antes de compilar
|
|
287
|
+
validarBlocos(linhas);
|
|
288
|
+
|
|
289
|
+
const js = linhas.map((linha, idx) => traduzir(linha, idx + 1, contexto)).join('\n');
|
|
290
|
+
|
|
291
|
+
const saidaJS = nomeBase + '.js';
|
|
132
292
|
const saidaHTML = nomeBase + '.html';
|
|
133
293
|
|
|
134
|
-
if (ehSite) {
|
|
135
|
-
const
|
|
136
|
-
|
|
294
|
+
if (contexto.ehSite) {
|
|
295
|
+
const porta = args[1] ? parseInt(args[1]) : 3000;
|
|
296
|
+
const estruturaHTML = `<!DOCTYPE html>
|
|
137
297
|
<html lang="pt-br">
|
|
138
298
|
<head>
|
|
139
299
|
<meta charset="UTF-8">
|
|
140
300
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
301
|
+
<title>Raizcode</title>
|
|
141
302
|
<style>
|
|
142
|
-
|
|
143
|
-
|
|
303
|
+
* { box-sizing: border-box; }
|
|
304
|
+
body {
|
|
305
|
+
background: #0d0d0d;
|
|
306
|
+
color: #f0f0f0;
|
|
307
|
+
font-family: sans-serif;
|
|
308
|
+
display: flex;
|
|
309
|
+
justify-content: center;
|
|
310
|
+
align-items: center;
|
|
311
|
+
min-height: 100vh;
|
|
312
|
+
margin: 0;
|
|
313
|
+
padding: 20px;
|
|
314
|
+
}
|
|
315
|
+
#raiz-app {
|
|
316
|
+
text-align: center;
|
|
317
|
+
border: 1px solid #00ff88;
|
|
318
|
+
padding: 40px;
|
|
319
|
+
border-radius: 20px;
|
|
320
|
+
background: #1a1a1a;
|
|
321
|
+
box-shadow: 0 0 30px rgba(0,255,136,0.2);
|
|
322
|
+
max-width: 800px;
|
|
323
|
+
width: 100%;
|
|
324
|
+
}
|
|
144
325
|
h1 { color: #00ff88; text-shadow: 0 0 10px #00ff88; }
|
|
145
|
-
|
|
326
|
+
h2 { color: #00cfff; }
|
|
327
|
+
a { color: #00ff88; }
|
|
328
|
+
button {
|
|
329
|
+
background: #00ff88;
|
|
330
|
+
color: #000;
|
|
331
|
+
border: none;
|
|
332
|
+
padding: 12px 28px;
|
|
333
|
+
border-radius: 10px;
|
|
334
|
+
font-weight: bold;
|
|
335
|
+
cursor: pointer;
|
|
336
|
+
margin: 8px;
|
|
337
|
+
font-size: 1rem;
|
|
338
|
+
transition: opacity 0.2s;
|
|
339
|
+
}
|
|
340
|
+
button:hover { opacity: 0.8; }
|
|
341
|
+
input {
|
|
342
|
+
background: #111;
|
|
343
|
+
border: 1px solid #00ff88;
|
|
344
|
+
color: #fff;
|
|
345
|
+
padding: 10px 16px;
|
|
346
|
+
border-radius: 8px;
|
|
347
|
+
margin: 8px;
|
|
348
|
+
font-size: 1rem;
|
|
349
|
+
}
|
|
146
350
|
${cssExtra}
|
|
147
351
|
</style>
|
|
148
352
|
</head>
|
|
149
353
|
<body>
|
|
150
354
|
<div id="raiz-app">${htmlExtra}</div>
|
|
151
|
-
<script
|
|
355
|
+
<script>
|
|
356
|
+
${js}
|
|
357
|
+
</script>
|
|
152
358
|
</body>
|
|
153
359
|
</html>`;
|
|
154
|
-
|
|
155
|
-
//
|
|
360
|
+
|
|
361
|
+
// Salva HTML para inspeção (opcional)
|
|
362
|
+
fs.writeFileSync(saidaHTML, estruturaHTML);
|
|
363
|
+
|
|
156
364
|
const server = http.createServer((req, res) => {
|
|
157
|
-
res.writeHead(200, { 'Content-Type': 'text/html' });
|
|
365
|
+
res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
|
|
158
366
|
res.end(estruturaHTML);
|
|
159
367
|
});
|
|
160
368
|
|
|
161
|
-
server.listen(
|
|
162
|
-
console.log(
|
|
163
|
-
|
|
369
|
+
server.listen(porta, () => {
|
|
370
|
+
console.log(`\n🌱 Raizcode — Servidor ativo!`);
|
|
371
|
+
console.log(`🌐 Acesse: http://localhost:${porta}`);
|
|
372
|
+
console.log(`⏹ Pressione Ctrl+C para encerrar.\n`);
|
|
373
|
+
abrirNavegador(`http://localhost:${porta}`);
|
|
164
374
|
});
|
|
165
375
|
|
|
166
|
-
//
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
// LIMPEZA que você pediu: Apaga depois de um tempo para não poluir
|
|
170
|
-
setTimeout(() => {
|
|
376
|
+
// Mantém servidor vivo até Ctrl+C
|
|
377
|
+
process.on('SIGINT', () => {
|
|
378
|
+
console.log('\n👋 Servidor encerrado.');
|
|
171
379
|
if (fs.existsSync(saidaHTML)) fs.unlinkSync(saidaHTML);
|
|
172
|
-
if (fs.existsSync(saidaJS)) fs.unlinkSync(saidaJS);
|
|
173
380
|
process.exit();
|
|
174
|
-
}
|
|
381
|
+
});
|
|
175
382
|
|
|
176
383
|
} else {
|
|
384
|
+
// Modo script: executa e apaga
|
|
177
385
|
fs.writeFileSync(saidaJS, js);
|
|
178
|
-
|
|
179
|
-
|
|
386
|
+
try {
|
|
387
|
+
execSync(`node "${saidaJS}"`, { stdio: 'inherit' });
|
|
388
|
+
} finally {
|
|
389
|
+
if (fs.existsSync(saidaJS)) fs.unlinkSync(saidaJS);
|
|
390
|
+
}
|
|
180
391
|
}
|
|
392
|
+
|
|
181
393
|
} catch (err) {
|
|
182
|
-
|
|
394
|
+
if (!err.already_reported) {
|
|
395
|
+
console.error(`\n❌ Erro inesperado: ${err.message}\n`);
|
|
396
|
+
}
|
|
397
|
+
process.exit(1);
|
|
183
398
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"iconDefinitions": {
|
|
3
|
+
"_rc": { "iconPath": "./rc.png" },
|
|
4
|
+
"_rcx": { "iconPath": "./rcx.png" },
|
|
5
|
+
"_rcc": { "iconPath": "./rcc.png" }
|
|
6
|
+
},
|
|
7
|
+
"fileExtensions": {
|
|
8
|
+
"rc": "_rc",
|
|
9
|
+
"rcx": "_rcx",
|
|
10
|
+
"rcc": "_rcc"
|
|
11
|
+
},
|
|
12
|
+
"fileNames": {
|
|
13
|
+
"index.rc": "_rc",
|
|
14
|
+
"index.rcx": "_rcx",
|
|
15
|
+
"index.rcc": "_rcc"
|
|
16
|
+
}
|
|
17
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "raizcode-ofc",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Linguagem de programação
|
|
3
|
+
"version": "1.10.0",
|
|
4
|
+
"description": "Linguagem de programação brasileira — escreva código em português.",
|
|
5
5
|
"main": "compilador.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"raizcode": "./compilador.js"
|
|
@@ -15,10 +15,13 @@
|
|
|
15
15
|
"raizcode",
|
|
16
16
|
"linguagem",
|
|
17
17
|
"portugues",
|
|
18
|
+
"pt-br",
|
|
18
19
|
"compilador",
|
|
19
20
|
"javascript",
|
|
20
21
|
"web",
|
|
21
|
-
"desenvolvimento"
|
|
22
|
+
"desenvolvimento",
|
|
23
|
+
"iniciantes",
|
|
24
|
+
"educacao"
|
|
22
25
|
],
|
|
23
26
|
"author": "Riquefla",
|
|
24
27
|
"license": "MIT",
|
|
@@ -26,40 +29,11 @@
|
|
|
26
29
|
"node": ">=14.0.0"
|
|
27
30
|
},
|
|
28
31
|
"files": [
|
|
32
|
+
"compilador.js",
|
|
29
33
|
"icons/",
|
|
30
34
|
"syntaxes/",
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
]
|
|
35
|
-
"contributes": {
|
|
36
|
-
"languages": [
|
|
37
|
-
{
|
|
38
|
-
"id": "raizcode",
|
|
39
|
-
"aliases": ["Raizcode", "rc"],
|
|
40
|
-
"extensions": [".rc"],
|
|
41
|
-
"configuration": "./language-configuration.json",
|
|
42
|
-
"icon": { "dark": "./icons/rc.png", "light": "./icons/rc.png" }
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
"id": "raizcode-estrutura",
|
|
46
|
-
"aliases": ["Raizcode Estrutura", "rcx"],
|
|
47
|
-
"extensions": [".rcx"],
|
|
48
|
-
"icon": { "dark": "./icons/rcx.png", "light": "./icons/rcx.png" }
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
"id": "raizcode-estilo",
|
|
52
|
-
"aliases": ["Raizcode Estilo", "rcc"],
|
|
53
|
-
"extensions": [".rcc"],
|
|
54
|
-
"icon": { "dark": "./icons/rcc.png", "light": "./icons/rcc.png" }
|
|
55
|
-
}
|
|
56
|
-
],
|
|
57
|
-
"grammars": [
|
|
58
|
-
{
|
|
59
|
-
"language": "raizcode",
|
|
60
|
-
"scopeName": "source.rc",
|
|
61
|
-
"path": "./syntaxes/raizcode.tmLanguage.json"
|
|
62
|
-
}
|
|
63
|
-
]
|
|
64
|
-
}
|
|
35
|
+
"exemplos/",
|
|
36
|
+
"README.md",
|
|
37
|
+
"package.json"
|
|
38
|
+
]
|
|
65
39
|
}
|