vladx 1.2.5 → 1.2.6
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/package.json
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
variabile nome = chiedi("Come ti chiami? ");
|
|
2
|
+
stampa(`Ciao ${nome}`);
|
|
3
|
+
|
|
4
|
+
variabile eta = 20
|
|
5
|
+
stampa(`Ho ${eta} anni`)
|
|
6
|
+
|
|
7
|
+
variabile persona = {nome: "Vlad", eta: 20}
|
|
8
|
+
stampa(`Persona: ${persona}`)
|
|
9
|
+
|
|
10
|
+
variabile lista = [1, 2, 3, 4, 5]
|
|
11
|
+
stampa(`Lista: ${lista}`)
|
|
12
|
+
|
|
13
|
+
variabile lista_di_liste = [[1, 2], [3, 4], [5, 6]]
|
|
14
|
+
stampa(`Lista di liste: ${lista_di_liste}`)
|
|
15
|
+
|
|
16
|
+
variabile lista_di_liste_di_liste = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]
|
|
17
|
+
stampa(`Lista di liste di liste: ${lista_di_liste_di_liste}`)
|
|
18
|
+
|
|
19
|
+
variabile lista_di_liste_di_liste_di_liste = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]
|
|
20
|
+
stampa(`Lista di liste di liste di liste: ${lista_di_liste_di_liste_di_liste}`)
|
|
21
|
+
|
|
@@ -236,6 +236,32 @@ class Interpreter {
|
|
|
236
236
|
}
|
|
237
237
|
});
|
|
238
238
|
|
|
239
|
+
this.globals.define('chiedi', {
|
|
240
|
+
call: (_, args) => {
|
|
241
|
+
if (args[0] !== undefined) {
|
|
242
|
+
process.stdout.write(String(args[0]));
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const buffer = Buffer.alloc(1);
|
|
246
|
+
let input = '';
|
|
247
|
+
|
|
248
|
+
try {
|
|
249
|
+
while (true) {
|
|
250
|
+
const bytesRead = fs.readSync(0, buffer, 0, 1, null);
|
|
251
|
+
if (bytesRead === 0) break; // EOF
|
|
252
|
+
const char = buffer.toString('utf8');
|
|
253
|
+
if (char === '\n') break;
|
|
254
|
+
if (char === '\r') continue;
|
|
255
|
+
input += char;
|
|
256
|
+
}
|
|
257
|
+
} catch (e) {
|
|
258
|
+
// Ignore errors on read (e.g. pipe closed)
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
return input;
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
|
|
239
265
|
this._registerStdLib();
|
|
240
266
|
}
|
|
241
267
|
|