vladx 1.2.6 → 1.3.2

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vladx",
3
- "version": "1.2.6",
3
+ "version": "1.3.2",
4
4
  "description": "VladX - Linguaggio di programmazione con sintassi italiana",
5
5
  "main": "src/index.js",
6
6
  "type": "commonjs",
@@ -1,21 +1,12 @@
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
-
1
+ variabile passport = {}
2
+ passport.nome = chiedi("Come ti chiami? ")
3
+ passport.eta = chiedi("Quanti anni hai? ")
4
+
5
+ se(passport.eta >= 18) {
6
+ stampa("Sei maggiorenne")
7
+ } altrimenti {
8
+ stampa("Sei minorenne")
9
+ }
10
+ stampa(passport)
11
+
12
+ Archivio.scrivi(`passports/${passport.nome}.txt`, JSON.stringify(passport))
@@ -0,0 +1 @@
1
+ {"nome":"Vlad","eta":"12"}
package/src/cli/cli.js CHANGED
@@ -10,7 +10,8 @@ const { Parser } = require('../parser/parser.js');
10
10
  const { Interpreter } = require('../interpreter/interpreter.js');
11
11
  const { startREPL } = require('../repl/repl.js');
12
12
 
13
- const VERSION = '1.0.0';
13
+ const packageJson = require('../../package.json');
14
+ const VERSION = packageJson.version;
14
15
 
15
16
  const COLORS = {
16
17
  reset: '\x1b[0m',
@@ -225,6 +225,23 @@ class Interpreter {
225
225
  call: (_, args) => Array.isArray(args[0])
226
226
  });
227
227
 
228
+ this.globals.define('booleano', {
229
+ call: (_, args) => Boolean(args[0])
230
+ });
231
+
232
+ this.globals.define('intero', {
233
+ call: (_, args) => parseInt(args[0])
234
+ });
235
+
236
+ this.globals.define('JSON', {
237
+ stringify: {
238
+ call: (_, args) => JSON.stringify(args[0], args[1], args[2])
239
+ },
240
+ parse: {
241
+ call: (_, args) => JSON.parse(args[0])
242
+ }
243
+ });
244
+
228
245
  this.globals.define('aspetta', {
229
246
  call: (_, args) => {
230
247
  const ms = args[0];