vladx 1.0.1
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/vladpm +9 -0
- package/bin/vladx +10 -0
- package/examples/esempio.vx +79 -0
- package/package.json +23 -0
- package/src/cli/cli.js +191 -0
- package/src/index.js +32 -0
- package/src/interpreter/interpreter.js +455 -0
- package/src/lexer/lexer.js +284 -0
- package/src/lexer/tokens.js +116 -0
- package/src/parser/ast.js +265 -0
- package/src/parser/parser.js +476 -0
- package/src/pm/cli.js +130 -0
- package/src/pm/commands/config.js +76 -0
- package/src/pm/commands/init.js +129 -0
- package/src/pm/commands/install.js +185 -0
- package/src/pm/commands/list.js +70 -0
- package/src/pm/commands/login.js +124 -0
- package/src/pm/commands/publish.js +115 -0
- package/src/pm/commands/search.js +55 -0
- package/src/pm/commands/uninstall.js +68 -0
- package/src/pm/utils/api.js +135 -0
- package/src/pm/utils/config.js +117 -0
- package/src/repl/repl.js +179 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VladPM - uninstall command
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
const {
|
|
8
|
+
getVladxJson,
|
|
9
|
+
saveVladxJson,
|
|
10
|
+
getVladxLock,
|
|
11
|
+
saveVladxLock,
|
|
12
|
+
getModulesDir
|
|
13
|
+
} = require('../utils/config.js');
|
|
14
|
+
|
|
15
|
+
const COLORS = {
|
|
16
|
+
reset: '\x1b[0m',
|
|
17
|
+
bright: '\x1b[1m',
|
|
18
|
+
green: '\x1b[32m',
|
|
19
|
+
red: '\x1b[31m',
|
|
20
|
+
yellow: '\x1b[33m'
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
function colorize(text, color) {
|
|
24
|
+
return `${COLORS[color]}${text}${COLORS.reset}`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async function execute(args) {
|
|
28
|
+
if (args.length === 0) {
|
|
29
|
+
console.log(colorize('ā Specificare il nome del pacchetto da rimuovere.', 'red'));
|
|
30
|
+
console.log('Uso: vladpm uninstall <pacchetto>');
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const packages = args.filter(a => !a.startsWith('-'));
|
|
35
|
+
|
|
36
|
+
console.log(colorize('\nšļø Rimozione pacchetti\n', 'bright'));
|
|
37
|
+
|
|
38
|
+
for (const name of packages) {
|
|
39
|
+
const modulesDir = getModulesDir();
|
|
40
|
+
const packageDir = path.join(modulesDir, name);
|
|
41
|
+
|
|
42
|
+
// Remove from filesystem
|
|
43
|
+
if (fs.existsSync(packageDir)) {
|
|
44
|
+
fs.rmSync(packageDir, { recursive: true });
|
|
45
|
+
console.log(colorize(` ā Rimosso ${name}`, 'green'));
|
|
46
|
+
} else {
|
|
47
|
+
console.log(colorize(` ā ${name} non installato`, 'yellow'));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Update vladx.json
|
|
51
|
+
const vladxJson = getVladxJson();
|
|
52
|
+
if (vladxJson && vladxJson.dependencies && vladxJson.dependencies[name]) {
|
|
53
|
+
delete vladxJson.dependencies[name];
|
|
54
|
+
saveVladxJson(vladxJson);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Update lock file
|
|
58
|
+
const lock = getVladxLock();
|
|
59
|
+
if (lock.dependencies && lock.dependencies[name]) {
|
|
60
|
+
delete lock.dependencies[name];
|
|
61
|
+
saveVladxLock(lock);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
console.log();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
module.exports = { execute };
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VladPM API Client
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const http = require('http');
|
|
6
|
+
const https = require('https');
|
|
7
|
+
const { URL } = require('url');
|
|
8
|
+
const { getRegistry, getToken } = require('./config.js');
|
|
9
|
+
|
|
10
|
+
function request(method, endpoint, data = null, options = {}) {
|
|
11
|
+
return new Promise((resolve, reject) => {
|
|
12
|
+
const registry = options.registry || getRegistry();
|
|
13
|
+
const url = new URL(endpoint, registry);
|
|
14
|
+
const isHttps = url.protocol === 'https:';
|
|
15
|
+
const client = isHttps ? https : http;
|
|
16
|
+
|
|
17
|
+
const reqOptions = {
|
|
18
|
+
hostname: url.hostname,
|
|
19
|
+
port: url.port || (isHttps ? 443 : 80),
|
|
20
|
+
path: url.pathname + url.search,
|
|
21
|
+
method: method,
|
|
22
|
+
headers: {
|
|
23
|
+
'Content-Type': 'application/json',
|
|
24
|
+
'User-Agent': 'VladPM/1.0.0'
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// Add auth token if available
|
|
29
|
+
const token = options.token || getToken();
|
|
30
|
+
if (token) {
|
|
31
|
+
reqOptions.headers['Authorization'] = `Bearer ${token}`;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Add custom headers
|
|
35
|
+
if (options.headers) {
|
|
36
|
+
Object.assign(reqOptions.headers, options.headers);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const req = client.request(reqOptions, (res) => {
|
|
40
|
+
let body = '';
|
|
41
|
+
res.on('data', chunk => body += chunk);
|
|
42
|
+
res.on('end', () => {
|
|
43
|
+
try {
|
|
44
|
+
const parsed = body ? JSON.parse(body) : {};
|
|
45
|
+
if (res.statusCode >= 200 && res.statusCode < 300) {
|
|
46
|
+
resolve({ status: res.statusCode, data: parsed });
|
|
47
|
+
} else {
|
|
48
|
+
reject(new Error(parsed.error || parsed.message || `HTTP ${res.statusCode}`));
|
|
49
|
+
}
|
|
50
|
+
} catch (e) {
|
|
51
|
+
if (res.statusCode >= 200 && res.statusCode < 300) {
|
|
52
|
+
resolve({ status: res.statusCode, data: body });
|
|
53
|
+
} else {
|
|
54
|
+
reject(new Error(`HTTP ${res.statusCode}: ${body}`));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
req.on('error', (e) => {
|
|
61
|
+
if (e.code === 'ECONNREFUSED') {
|
|
62
|
+
reject(new Error('Impossibile connettersi al registry. Verifica che vladpm-server sia in esecuzione.'));
|
|
63
|
+
} else {
|
|
64
|
+
reject(e);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
if (data) {
|
|
69
|
+
const payload = typeof data === 'string' ? data : JSON.stringify(data);
|
|
70
|
+
req.write(payload);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
req.end();
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async function get(endpoint, options = {}) {
|
|
78
|
+
return request('GET', endpoint, null, options);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async function post(endpoint, data, options = {}) {
|
|
82
|
+
return request('POST', endpoint, data, options);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async function put(endpoint, data, options = {}) {
|
|
86
|
+
return request('PUT', endpoint, data, options);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
async function del(endpoint, options = {}) {
|
|
90
|
+
return request('DELETE', endpoint, null, options);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Package-specific API calls
|
|
94
|
+
async function login(username, password) {
|
|
95
|
+
return post('/auth/login', { username, password });
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async function register(username, email, password) {
|
|
99
|
+
return post('/auth/register', { username, email, password });
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
async function getPackage(name) {
|
|
103
|
+
return get(`/packages/${encodeURIComponent(name)}`);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
async function getPackageVersion(name, version) {
|
|
107
|
+
return get(`/packages/${encodeURIComponent(name)}/${encodeURIComponent(version)}`);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async function publishPackage(packageData) {
|
|
111
|
+
return put(`/packages/${encodeURIComponent(packageData.name)}`, packageData);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
async function searchPackages(query) {
|
|
115
|
+
return get(`/search?q=${encodeURIComponent(query)}`);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
async function unpublishPackage(name) {
|
|
119
|
+
return del(`/packages/${encodeURIComponent(name)}`);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
module.exports = {
|
|
123
|
+
request,
|
|
124
|
+
get,
|
|
125
|
+
post,
|
|
126
|
+
put,
|
|
127
|
+
del,
|
|
128
|
+
login,
|
|
129
|
+
register,
|
|
130
|
+
getPackage,
|
|
131
|
+
getPackageVersion,
|
|
132
|
+
publishPackage,
|
|
133
|
+
searchPackages,
|
|
134
|
+
unpublishPackage
|
|
135
|
+
};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VladPM Config Utilities
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
const os = require('os');
|
|
8
|
+
|
|
9
|
+
const CONFIG_DIR = path.join(os.homedir(), '.vladpm');
|
|
10
|
+
const CONFIG_FILE = path.join(CONFIG_DIR, 'config.json');
|
|
11
|
+
const VLADX_JSON = 'vladx.json';
|
|
12
|
+
const VLADX_LOCK = 'vladx-lock.json';
|
|
13
|
+
const MODULES_DIR = 'vladx_modules';
|
|
14
|
+
|
|
15
|
+
// Default registry URL
|
|
16
|
+
const DEFAULT_REGISTRY = 'http://185.105.108.233:6789';
|
|
17
|
+
|
|
18
|
+
function ensureConfigDir() {
|
|
19
|
+
if (!fs.existsSync(CONFIG_DIR)) {
|
|
20
|
+
fs.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function getConfig() {
|
|
25
|
+
ensureConfigDir();
|
|
26
|
+
if (fs.existsSync(CONFIG_FILE)) {
|
|
27
|
+
return JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
|
|
28
|
+
}
|
|
29
|
+
return { registry: DEFAULT_REGISTRY };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function saveConfig(config) {
|
|
33
|
+
ensureConfigDir();
|
|
34
|
+
fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function getToken() {
|
|
38
|
+
const config = getConfig();
|
|
39
|
+
return config.token || null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function setToken(token, username) {
|
|
43
|
+
const config = getConfig();
|
|
44
|
+
config.token = token;
|
|
45
|
+
config.username = username;
|
|
46
|
+
saveConfig(config);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function clearToken() {
|
|
50
|
+
const config = getConfig();
|
|
51
|
+
delete config.token;
|
|
52
|
+
delete config.username;
|
|
53
|
+
saveConfig(config);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function getRegistry() {
|
|
57
|
+
const config = getConfig();
|
|
58
|
+
return config.registry || DEFAULT_REGISTRY;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function getVladxJson(dir = process.cwd()) {
|
|
62
|
+
const filePath = path.join(dir, VLADX_JSON);
|
|
63
|
+
if (fs.existsSync(filePath)) {
|
|
64
|
+
return JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function saveVladxJson(data, dir = process.cwd()) {
|
|
70
|
+
const filePath = path.join(dir, VLADX_JSON);
|
|
71
|
+
fs.writeFileSync(filePath, JSON.stringify(data, null, 2) + '\n');
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function getVladxLock(dir = process.cwd()) {
|
|
75
|
+
const filePath = path.join(dir, VLADX_LOCK);
|
|
76
|
+
if (fs.existsSync(filePath)) {
|
|
77
|
+
return JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
|
78
|
+
}
|
|
79
|
+
return { lockfileVersion: 1, dependencies: {} };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function saveVladxLock(data, dir = process.cwd()) {
|
|
83
|
+
const filePath = path.join(dir, VLADX_LOCK);
|
|
84
|
+
fs.writeFileSync(filePath, JSON.stringify(data, null, 2) + '\n');
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function getModulesDir(dir = process.cwd()) {
|
|
88
|
+
return path.join(dir, MODULES_DIR);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function ensureModulesDir(dir = process.cwd()) {
|
|
92
|
+
const modulesDir = getModulesDir(dir);
|
|
93
|
+
if (!fs.existsSync(modulesDir)) {
|
|
94
|
+
fs.mkdirSync(modulesDir, { recursive: true });
|
|
95
|
+
}
|
|
96
|
+
return modulesDir;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
module.exports = {
|
|
100
|
+
CONFIG_DIR,
|
|
101
|
+
VLADX_JSON,
|
|
102
|
+
VLADX_LOCK,
|
|
103
|
+
MODULES_DIR,
|
|
104
|
+
DEFAULT_REGISTRY,
|
|
105
|
+
getConfig,
|
|
106
|
+
saveConfig,
|
|
107
|
+
getToken,
|
|
108
|
+
setToken,
|
|
109
|
+
clearToken,
|
|
110
|
+
getRegistry,
|
|
111
|
+
getVladxJson,
|
|
112
|
+
saveVladxJson,
|
|
113
|
+
getVladxLock,
|
|
114
|
+
saveVladxLock,
|
|
115
|
+
getModulesDir,
|
|
116
|
+
ensureModulesDir
|
|
117
|
+
};
|
package/src/repl/repl.js
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VladX REPL
|
|
3
|
+
* Read-Eval-Print Loop interattivo
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const readline = require('readline');
|
|
7
|
+
const { Lexer } = require('../lexer/lexer.js');
|
|
8
|
+
const { Parser } = require('../parser/parser.js');
|
|
9
|
+
const { Interpreter } = require('../interpreter/interpreter.js');
|
|
10
|
+
|
|
11
|
+
const COLORS = {
|
|
12
|
+
reset: '\x1b[0m',
|
|
13
|
+
bright: '\x1b[1m',
|
|
14
|
+
dim: '\x1b[2m',
|
|
15
|
+
red: '\x1b[31m',
|
|
16
|
+
green: '\x1b[32m',
|
|
17
|
+
yellow: '\x1b[33m',
|
|
18
|
+
blue: '\x1b[34m',
|
|
19
|
+
magenta: '\x1b[35m',
|
|
20
|
+
cyan: '\x1b[36m'
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
function colorize(text, color) {
|
|
24
|
+
return `${COLORS[color]}${text}${COLORS.reset}`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
class REPL {
|
|
28
|
+
constructor() {
|
|
29
|
+
this.interpreter = new Interpreter();
|
|
30
|
+
this.history = [];
|
|
31
|
+
this.multilineBuffer = '';
|
|
32
|
+
this.openBraces = 0;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
start() {
|
|
36
|
+
console.log(colorize('\nāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā', 'cyan'));
|
|
37
|
+
console.log(colorize('ā', 'cyan') + colorize(' š VladX REPL v1.0.0 ', 'bright') + colorize('ā', 'cyan'));
|
|
38
|
+
console.log(colorize('ā', 'cyan') + ' Linguaggio di programmazione con sintassi ' + colorize('ā', 'cyan'));
|
|
39
|
+
console.log(colorize('ā', 'cyan') + ' italiana. Digita "aiuto" per la guida. ' + colorize('ā', 'cyan'));
|
|
40
|
+
console.log(colorize('āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā\n', 'cyan'));
|
|
41
|
+
|
|
42
|
+
const rl = readline.createInterface({
|
|
43
|
+
input: process.stdin,
|
|
44
|
+
output: process.stdout,
|
|
45
|
+
prompt: colorize('vladx> ', 'green'),
|
|
46
|
+
historySize: 100
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
rl.prompt();
|
|
50
|
+
|
|
51
|
+
rl.on('line', (line) => {
|
|
52
|
+
const trimmed = line.trim();
|
|
53
|
+
|
|
54
|
+
// Handle special commands
|
|
55
|
+
if (trimmed === 'esci' || trimmed === 'exit') {
|
|
56
|
+
console.log(colorize('\nArrivederci! š\n', 'cyan'));
|
|
57
|
+
process.exit(0);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (trimmed === 'aiuto' || trimmed === 'help') {
|
|
61
|
+
this.showHelp();
|
|
62
|
+
rl.prompt();
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (trimmed === 'pulisci' || trimmed === 'clear') {
|
|
67
|
+
console.clear();
|
|
68
|
+
rl.prompt();
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (trimmed === '') {
|
|
73
|
+
rl.prompt();
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Handle multiline input
|
|
78
|
+
this.multilineBuffer += line + '\n';
|
|
79
|
+
this.openBraces += (line.match(/{/g) || []).length;
|
|
80
|
+
this.openBraces -= (line.match(/}/g) || []).length;
|
|
81
|
+
|
|
82
|
+
if (this.openBraces > 0) {
|
|
83
|
+
rl.setPrompt(colorize('... ', 'yellow'));
|
|
84
|
+
rl.prompt();
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Execute the code
|
|
89
|
+
const code = this.multilineBuffer.trim();
|
|
90
|
+
this.multilineBuffer = '';
|
|
91
|
+
this.openBraces = 0;
|
|
92
|
+
|
|
93
|
+
if (code) {
|
|
94
|
+
this.history.push(code);
|
|
95
|
+
this.execute(code);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
rl.setPrompt(colorize('vladx> ', 'green'));
|
|
99
|
+
rl.prompt();
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
rl.on('close', () => {
|
|
103
|
+
console.log(colorize('\nArrivederci! š\n', 'cyan'));
|
|
104
|
+
process.exit(0);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
execute(code) {
|
|
109
|
+
try {
|
|
110
|
+
const lexer = new Lexer(code);
|
|
111
|
+
const tokens = lexer.tokenize();
|
|
112
|
+
|
|
113
|
+
const parser = new Parser(tokens);
|
|
114
|
+
const ast = parser.parse();
|
|
115
|
+
|
|
116
|
+
const result = this.interpreter.interpret(ast);
|
|
117
|
+
|
|
118
|
+
// Show result if it's not just print statements
|
|
119
|
+
if (result.length === 0 && ast.body.length > 0) {
|
|
120
|
+
const lastStmt = ast.body[ast.body.length - 1];
|
|
121
|
+
if (lastStmt.type === 'ExpressionStatement') {
|
|
122
|
+
const lexer2 = new Lexer(code);
|
|
123
|
+
const tokens2 = lexer2.tokenize();
|
|
124
|
+
const parser2 = new Parser(tokens2);
|
|
125
|
+
const ast2 = parser2.parse();
|
|
126
|
+
|
|
127
|
+
// Create a fresh interpreter to get the expression value
|
|
128
|
+
const tempInterpreter = new Interpreter();
|
|
129
|
+
tempInterpreter.globals = this.interpreter.globals;
|
|
130
|
+
tempInterpreter.environment = this.interpreter.environment;
|
|
131
|
+
|
|
132
|
+
try {
|
|
133
|
+
const value = tempInterpreter.evaluate(lastStmt.expression);
|
|
134
|
+
if (value !== undefined && value !== null) {
|
|
135
|
+
console.log(colorize('ā ', 'dim') + colorize(this.interpreter.stringify(value), 'yellow'));
|
|
136
|
+
}
|
|
137
|
+
} catch (e) {
|
|
138
|
+
// Ignore
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
} catch (error) {
|
|
143
|
+
console.log(colorize('ā Errore: ', 'red') + error.message);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
showHelp() {
|
|
148
|
+
console.log(colorize('\nš Guida VladX REPL\n', 'bright'));
|
|
149
|
+
console.log(colorize('Comandi REPL:', 'cyan'));
|
|
150
|
+
console.log(' aiuto, help Mostra questa guida');
|
|
151
|
+
console.log(' pulisci, clear Pulisce lo schermo');
|
|
152
|
+
console.log(' esci, exit Esce dal REPL\n');
|
|
153
|
+
|
|
154
|
+
console.log(colorize('Sintassi VladX:', 'cyan'));
|
|
155
|
+
console.log(' variabile x = 10 Dichiarazione variabile');
|
|
156
|
+
console.log(' costante PI = 3.14 Dichiarazione costante');
|
|
157
|
+
console.log(' stampa("Ciao!") Stampa output');
|
|
158
|
+
console.log(' se (cond) { } Condizionale');
|
|
159
|
+
console.log(' mentre (cond) { } Ciclo while');
|
|
160
|
+
console.log(' per (init;cond;upd) Ciclo for');
|
|
161
|
+
console.log(' funzione f(x) { } Dichiarazione funzione\n');
|
|
162
|
+
|
|
163
|
+
console.log(colorize('Operatori logici:', 'cyan'));
|
|
164
|
+
console.log(' e / && AND logico');
|
|
165
|
+
console.log(' o / || OR logico');
|
|
166
|
+
console.log(' non / ! NOT logico\n');
|
|
167
|
+
|
|
168
|
+
console.log(colorize('Valori:', 'cyan'));
|
|
169
|
+
console.log(' vero / falso Boolean');
|
|
170
|
+
console.log(' nullo Null\n');
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function startREPL() {
|
|
175
|
+
const repl = new REPL();
|
|
176
|
+
repl.start();
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
module.exports = { REPL, startREPL };
|