raizcode-ofc 1.5.0 → 1.8.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,6 +3,7 @@
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
7
  const { execSync, exec } = require('child_process');
7
8
 
8
9
  const args = process.argv.slice(2);
@@ -44,6 +45,8 @@ function traduzirEstrutura(conteudo) {
44
45
  let id = p[1] ? p[1].replace(/"/g, '') : 'btn-' + Math.floor(Math.random()*1000);
45
46
  return `<button id="${id}">${texto}</button>`;
46
47
  }
48
+ // Acrescentado: Comando de Imagem
49
+ if (t.startsWith('imagem ')) return `<img src="${t.replace('imagem ', '').replace(/"/g, '')}" style="max-width:100%;">`;
47
50
  if (t.startsWith('caixa ')) return `<div class="${t.replace('caixa ', '').replace(/"/g, '')}">`;
48
51
  if (t === 'fim') return `</div>`;
49
52
  return "";
@@ -56,6 +59,7 @@ function traduzirEstilo(conteudo) {
56
59
  .replace(/fundo:/g, 'background:')
57
60
  .replace(/cor-texto:/g, 'color:')
58
61
  .replace(/verde-neon/g, '#00ff88')
62
+ .replace(/amarelo-neon/g, '#ffff00') // Novo estilo
59
63
  .replace(/ao-passar-mouse:/g, '&:hover')
60
64
  .replace(/estilo /g, '.')
61
65
  .replace(/fim/g, '}');
@@ -75,6 +79,9 @@ function traduzir(linha) {
75
79
  }
76
80
 
77
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 ', '')};`;
78
85
 
79
86
  // --- COMANDOS ORIGINAIS ---
80
87
  if (t.startsWith('mostrar ')) return t.replace('mostrar ', 'console.log(') + ');';
@@ -104,7 +111,7 @@ if (!fs.existsSync(caminho)) {
104
111
 
105
112
  try {
106
113
  const arqRcx = nomeBase + '.rcx';
107
- const arqEstilo = nomeBase + '.estilo';
114
+ const arqRcc = nomeBase + '.rcc'; // Atualizado para buscar .rcc
108
115
 
109
116
  let htmlExtra = "";
110
117
  let cssExtra = "";
@@ -113,15 +120,14 @@ try {
113
120
  htmlExtra = traduzirEstrutura(fs.readFileSync(arqRcx, 'utf-8'));
114
121
  ehSite = true;
115
122
  }
116
- if (fs.existsSync(arqEstilo)) {
117
- cssExtra = traduzirEstilo(fs.readFileSync(arqEstilo, 'utf-8'));
123
+ if (fs.existsSync(arqRcc)) { // Agora busca o arquivo de estilo .rcc
124
+ cssExtra = traduzirEstilo(fs.readFileSync(arqRcc, 'utf-8'));
118
125
  ehSite = true;
119
126
  }
120
127
 
121
128
  const codigo = fs.readFileSync(caminho, 'utf-8');
122
129
  const js = codigo.split('\n').map(traduzir).join('\n');
123
130
 
124
- // Nomes dos arquivos que vamos "esconder"
125
131
  const saidaJS = nomeBase + '.js';
126
132
  const saidaHTML = nomeBase + '.html';
127
133
 
@@ -146,20 +152,26 @@ try {
146
152
  </body>
147
153
  </html>`;
148
154
 
155
+ // Resolve o problema do Localhost criando um servidor temporário
156
+ const server = http.createServer((req, res) => {
157
+ res.writeHead(200, { 'Content-Type': 'text/html' });
158
+ res.end(estruturaHTML);
159
+ });
160
+
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`);
164
+ });
165
+
166
+ // Mantive a sua lógica de criar o arquivo físico para garantir o funcionamento
149
167
  fs.writeFileSync(saidaHTML, estruturaHTML);
150
- console.log(`🌐 [Raizcode] Abrindo pré-visualização...`);
151
-
152
- const cmd = os.platform() === 'win32' ? `start ${saidaHTML}` :
153
- (os.platform() === 'darwin' ? `open ${saidaHTML}` :
154
- `termux-open ${saidaHTML}`);
155
168
 
156
- exec(cmd);
157
-
158
- // LIMPEZA: Apaga o HTML depois de 5 segundos (tempo de abrir)
169
+ // LIMPEZA que você pediu: Apaga depois de um tempo para não poluir
159
170
  setTimeout(() => {
160
171
  if (fs.existsSync(saidaHTML)) fs.unlinkSync(saidaHTML);
161
172
  if (fs.existsSync(saidaJS)) fs.unlinkSync(saidaJS);
162
- }, 5000);
173
+ process.exit();
174
+ }, 10000);
163
175
 
164
176
  } else {
165
177
  fs.writeFileSync(saidaJS, js);
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,24 @@
1
1
  {
2
2
  "name": "raizcode-ofc",
3
- "version": "1.5.0",
4
- "description": "Linguagem de programação Brasileira focada em simplicidade e performance.",
3
+ "version": "1.8.0",
4
+ "description": "Linguagem de programação Brasileira independente: RC (Lógica), RCX (Estrutura) e RCC (Estilo).",
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",
17
18
  "compilador",
18
- "javascript"
19
+ "javascript",
20
+ "web",
21
+ "desenvolvimento"
19
22
  ],
20
23
  "author": "Riquefla",
21
24
  "license": "MIT",
@@ -23,12 +26,40 @@
23
26
  "node": ">=14.0.0"
24
27
  },
25
28
  "files": [
26
- "src/",
27
- "bin/",
28
29
  "icons/",
29
30
  "syntaxes/",
30
31
  "compilador.js",
31
32
  "package.json",
32
33
  "README.md"
33
- ]
34
- }
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
+ }
65
+ }
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