novac 2.1.1 → 2.2.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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2026
3
+ Purcwix (c) 2026
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the Software), to deal
package/bin/novac CHANGED
@@ -114,6 +114,7 @@ program
114
114
  addrs: {},
115
115
  additions: {},
116
116
  raw: process.argv,
117
+ program,
117
118
  };
118
119
  const unknown = process.argv.slice(2).slice(options.length);
119
120
  for (let i = 0; i < unknown.length; i++) {
@@ -143,7 +144,7 @@ program
143
144
  cli.additions[key] = true;
144
145
  }
145
146
  }
146
- try { const _r = run(src, { cli }); if (_r instanceof Promise) _r.catch(e => { console.error(chalk.red(e.message || e)); process.exit(1); }); }
147
+ try { const _r = run(src, { cli, _filename: file, _dirname: path.dirname(file) }); if (_r instanceof Promise) _r.catch(e => { console.error(chalk.red(e.message || e)); process.exit(1); }); }
147
148
  catch (e) { console.error(chalk.red(e.message || e)); process.exit(1); }
148
149
  });
149
150
 
@@ -165,8 +166,8 @@ program
165
166
  console.error(chalk.red(`Error reading file "${file}": ${e.message}`));
166
167
  process.exit(1);
167
168
  }
168
- const cli = { args, options, addrs: {}, additions: {}, raw: process.argv };
169
- try { const _r = run(src, { cli }); if (_r instanceof Promise) _r.catch(e => { console.error(chalk.red(e.message || e)); process.exit(1); }); }
169
+ const cli = { args, options, addrs: {}, additions: {}, raw: process.argv, program, };
170
+ try { const _r = run(src, { cli, _filename: file, _dirname: path.dirname(file), }); if (_r instanceof Promise) _r.catch(e => { console.error(chalk.red(e.message || e)); process.exit(1); }); }
170
171
  catch (e) { console.error(chalk.red(e.message || e)); process.exit(1); }
171
172
  });
172
173
 
@@ -314,6 +315,8 @@ program.command('ast <files...>')
314
315
  program.command('repl')
315
316
  .description('Start interactive REPL')
316
317
  .action(() => {
318
+ stdlib._filename = 'nv:repl';
319
+ stdlib._dirname = 'nv';
317
320
  const executor = new Executor('', stdlib);
318
321
  const historyFile = path.join(process.env.HOME || process.env.USERPROFILE || '.', '.nova_repl_history');
319
322
 
package/bin/nvc CHANGED
File without changes
package/bin/nvml CHANGED
File without changes
package/examples/bf.nv ADDED
@@ -0,0 +1,61 @@
1
+ let { TView, Terminal } = includeKit("libterm");
2
+
3
+ // ─────────────────────────────────────────────────────────────────────────────
4
+ // Boot Terminal (starts input, enters alt-screen, wires resize)
5
+ // ─────────────────────────────────────────────────────────────────────────────
6
+
7
+ const term = Terminal(nat {
8
+ altScreen: true,
9
+ mouse: true,
10
+ theme: 'dark',
11
+ logLevel: 'debug',
12
+ });
13
+
14
+ // ─────────────────────────────────────────────────────────────────────────────
15
+ // Layout: top bar / [left pane | right pane] / sensor bar / bottom bar
16
+ // ─────────────────────────────────────────────────────────────────────────────
17
+
18
+ term.on('ready', async () => {
19
+ let view = term.createView();
20
+ let code = await view.prompt("Enter Brainfuck code:");
21
+ let output = "";
22
+ let data = [0, 30000];
23
+ let dataPtr = 0;
24
+ let codePtr = 0;
25
+ while (codePtr < code.length) {
26
+ let cmd = code[codePtr];
27
+ if (cmd == '>') {
28
+ dataPtr++;
29
+ } else if (cmd == '<') {
30
+ dataPtr--;
31
+ } else if (cmd == '+') {
32
+ data[dataPtr] = (data[dataPtr] + 1) % 256;
33
+ } else if (cmd == '-') {
34
+ data[dataPtr] = (data[dataPtr] - 1) % 256;
35
+ } else if (cmd == '.') {
36
+ output += charCode(data[dataPtr]);
37
+ } else if (cmd == ',') {
38
+ data[dataPtr] = charAt(await view.prompt('Input: '));
39
+ } else if (cmd == '[') {
40
+ if (data[dataPtr] == 0) {
41
+ let Loop = 1;
42
+ while (Loop > 0) {
43
+ codePtr++;
44
+ if (code[codePtr] == '[') Loop++;
45
+ else if (code[codePtr] == ']') Loop--;
46
+ }
47
+ }
48
+ } else if (cmd == ']') {
49
+ if (data[dataPtr] != 0) {
50
+ let Loop = 1;
51
+ while (Loop > 0) {
52
+ codePtr--;
53
+ if (code[codePtr] == ']') Loop++;
54
+ else if (code[codePtr] == '[') Loop--;
55
+ }
56
+ }
57
+ }
58
+ codePtr++;
59
+ }
60
+ await view.writeText(0, 0, "Output: " + output, nat { color: 'green' });
61
+ })
@@ -0,0 +1,21 @@
1
+ let Tkit = includeKit("libterm");
2
+ let Terminal = Tkit.Terminal;
3
+ let parseExpr = includeKit('kitparse').parseExpr;
4
+
5
+ // ─────────────────────────────────────────────────────────────────────────────
6
+ // Boot Terminal (starts input, enters alt-screen)
7
+ // ─────────────────────────────────────────────────────────────────────────────
8
+
9
+ const term = Terminal(nat {
10
+ altScreen: true,
11
+ mouse: true,
12
+ theme: 'dark',
13
+ logLevel: 'debug',
14
+ });
15
+
16
+ term.on('ready', async () => {
17
+ let view = term.createView();
18
+ let code = await view.prompt("Enter Math:");
19
+
20
+ await view.writeText(0, 0, "Output: " + parseExpr(code), nat { color: 'green' });
21
+ })