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