@forthic/interp 0.1.0 → 0.3.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.
Files changed (41) hide show
  1. package/dist/cjs/forthic/errors.d.ts +70 -0
  2. package/dist/cjs/forthic/errors.js +174 -0
  3. package/dist/cjs/forthic/errors.js.map +1 -0
  4. package/dist/cjs/forthic/global_module/map_word.d.ts +3 -1
  5. package/dist/cjs/forthic/global_module/map_word.js +16 -6
  6. package/dist/cjs/forthic/global_module/map_word.js.map +1 -1
  7. package/dist/cjs/forthic/global_module.d.ts +2 -1
  8. package/dist/cjs/forthic/global_module.js +36 -23
  9. package/dist/cjs/forthic/global_module.js.map +1 -1
  10. package/dist/cjs/forthic/interpreter.d.ts +13 -1
  11. package/dist/cjs/forthic/interpreter.js +64 -41
  12. package/dist/cjs/forthic/interpreter.js.map +1 -1
  13. package/dist/cjs/forthic/module.js +2 -4
  14. package/dist/cjs/forthic/module.js.map +1 -1
  15. package/dist/cjs/forthic/tokenizer.d.ts +21 -2
  16. package/dist/cjs/forthic/tokenizer.js +57 -21
  17. package/dist/cjs/forthic/tokenizer.js.map +1 -1
  18. package/dist/cjs/index.d.ts +1 -0
  19. package/dist/cjs/index.js +1 -0
  20. package/dist/cjs/index.js.map +1 -1
  21. package/dist/esm/forthic/errors.d.ts +70 -0
  22. package/dist/esm/forthic/errors.js +174 -0
  23. package/dist/esm/forthic/errors.js.map +1 -0
  24. package/dist/esm/forthic/global_module/map_word.d.ts +3 -1
  25. package/dist/esm/forthic/global_module/map_word.js +16 -6
  26. package/dist/esm/forthic/global_module/map_word.js.map +1 -1
  27. package/dist/esm/forthic/global_module.d.ts +2 -1
  28. package/dist/esm/forthic/global_module.js +36 -23
  29. package/dist/esm/forthic/global_module.js.map +1 -1
  30. package/dist/esm/forthic/interpreter.d.ts +13 -1
  31. package/dist/esm/forthic/interpreter.js +64 -41
  32. package/dist/esm/forthic/interpreter.js.map +1 -1
  33. package/dist/esm/forthic/module.js +2 -4
  34. package/dist/esm/forthic/module.js.map +1 -1
  35. package/dist/esm/forthic/tokenizer.d.ts +21 -2
  36. package/dist/esm/forthic/tokenizer.js +57 -21
  37. package/dist/esm/forthic/tokenizer.js.map +1 -1
  38. package/dist/esm/index.d.ts +1 -0
  39. package/dist/esm/index.js +1 -0
  40. package/dist/esm/index.js.map +1 -1
  41. package/package.json +1 -4
@@ -15,7 +15,9 @@ export declare class MapWord {
15
15
  push_error?: boolean;
16
16
  with_key?: boolean;
17
17
  cur_index: number;
18
- result: any[];
18
+ result: any[] | {
19
+ [key: string]: any;
20
+ };
19
21
  errors: any[];
20
22
  is_debugging: boolean;
21
23
  processing_item: boolean;
@@ -34,7 +34,10 @@ class MapWord {
34
34
  this.result = [];
35
35
  this.errors = [];
36
36
  if (this.num_interps > 1) {
37
- const group_size = Math.ceil(items.length / this.num_interps);
37
+ interp.stack_push(items);
38
+ await interp.run("LENGTH");
39
+ const num_items = interp.stack_pop();
40
+ const group_size = Math.ceil(num_items / this.num_interps);
38
41
  interp.stack_push(items);
39
42
  interp.stack_push(group_size);
40
43
  await interp.run("GROUPS-OF");
@@ -49,13 +52,20 @@ class MapWord {
49
52
  }
50
53
  const run_results = await Promise.all(interp_runs);
51
54
  // Gather results
52
- let result = [];
55
+ const is_array = items instanceof Array;
56
+ let array_result = [];
57
+ let object_result = {};
53
58
  let errors = [];
54
59
  for (const res of run_results) {
55
- result = [...result, ...res[0]];
60
+ if (is_array) {
61
+ array_result = [...array_result, ...res[0]];
62
+ }
63
+ else {
64
+ object_result = { ...object_result, ...res[0] };
65
+ }
56
66
  errors = [...errors, ...res[1]];
57
67
  }
58
- this.result = result;
68
+ this.result = is_array ? array_result : object_result;
59
69
  this.errors = errors;
60
70
  }
61
71
  else {
@@ -83,7 +93,7 @@ class MapWord {
83
93
  let error = null;
84
94
  try {
85
95
  // If this runs successfully, it would have pushed the result onto the stack
86
- await interp.run(forthic, forthic_location);
96
+ await interp.run(forthic, { reference_location: forthic_location });
87
97
  }
88
98
  catch (e) {
89
99
  // Since this didn't run successfully, push null onto the stack
@@ -93,7 +103,7 @@ class MapWord {
93
103
  errors.push(error);
94
104
  }
95
105
  else {
96
- await interp.run(forthic, forthic_location);
106
+ await interp.run(forthic, { reference_location: forthic_location });
97
107
  }
98
108
  return interp.stack_pop();
99
109
  }
@@ -1 +1 @@
1
- {"version":3,"file":"map_word.js","sourceRoot":"","sources":["../../../../src/forthic/global_module/map_word.ts"],"names":[],"mappings":";;;AAAA,gDAAiD;AAUjD,6BAA6B;AAC7B,MAAa,OAAO;IAgBlB,YACE,KAAY,EACZ,OAAY,EACZ,gBAAqB,EACrB,KAAmB;QAEnB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QAEnB,YAAY;QACZ,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC;QAC9B,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;QACtC,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC;QACnC,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAE/B,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;QAC1B,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;IACvB,CAAC;IACD,KAAK,CAAC,OAAO,CAAC,MAAmB;QAC/B,MAAM,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;IAED,KAAK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CAAC;wBAC1B,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;wBACf,MAAM,YAAY,CAChB,IAAI,EACJ,KAAK,GAAG,CAAC,EACT,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,EACvB,MAAM,CACP,CAAC;oBACJ,CAAC;yBAAM,CAAC;wBACN,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;wBACf,MAAM,cAAc,CAClB,IAAI,EACJ,KAAK,GAAG,CAAC,EACT,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,EACvB,MAAM,CACP,CAAC;oBACJ,CAAC;gBACH,CAAC;qBAAM,CAAC;oBACN,KAAK,CAAC,IAAI,CAAC,MAAM,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;gBAC/C,CAAC;YACH,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;QAED,MAAM,MAAM,GAAG,EAAE,CAAC;QAClB,IAAI,MAAW,CAAC;QAChB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACzB,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,MAAM,GAAG,MAAM,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;QACxD,CAAC;aAAM,CAAC;YACN,MAAM,GAAG,MAAM,cAAc,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;QAC1D,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1B,CAAC;CACF;AA/MD,0BA+MC"}
@@ -1,5 +1,5 @@
1
1
  import { Module, Word } from "./module";
2
- import type { Interpreter } from "./interpreter";
2
+ import { type Interpreter } from "./interpreter";
3
3
  export declare class GlobalModule extends Module {
4
4
  module_id: string;
5
5
  literal_handlers: Array<(value: any) => any>;
@@ -163,5 +163,6 @@ export declare class GlobalModule extends Module {
163
163
  word_JSON_to(interp: Interpreter): void;
164
164
  word_LOAD_SCREEN(interp: Interpreter): Promise<void>;
165
165
  word_dot_s(interp: Interpreter): void;
166
+ word_dot_S(interp: Interpreter): void;
166
167
  word_minus(interp: Interpreter): void;
167
168
  }
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GlobalModule = void 0;
4
4
  const module_1 = require("./module");
5
- const ForthicError_1 = require("./ForthicError");
6
5
  const utils_1 = require("./utils");
7
6
  const map_word_1 = require("./global_module/map_word");
8
7
  const tokenizer_1 = require("./tokenizer");
8
+ const errors_1 = require("./errors");
9
9
  const DLE = String.fromCharCode(16); // ASCII char for "Data Link Escape" used as an untypeable quote
10
10
  class GlobalModule extends module_1.Module {
11
11
  constructor(interp) {
@@ -119,6 +119,7 @@ class GlobalModule extends module_1.Module {
119
119
  this.add_module_word("JSON>", this.word_JSON_to);
120
120
  this.add_module_word("LOAD-SCREEN", this.word_LOAD_SCREEN);
121
121
  this.add_module_word(".s", this.word_dot_s);
122
+ this.add_module_word(".S", this.word_dot_S);
122
123
  // --------------------
123
124
  // Date/time words
124
125
  this.add_module_word("AM", this.word_AM);
@@ -291,7 +292,7 @@ class GlobalModule extends module_1.Module {
291
292
  const module = interp.cur_module();
292
293
  varnames.forEach((v) => {
293
294
  if (v.match(/__.*/)) {
294
- throw new ForthicError_1.ForthicError("global_module-696", `word_VARIABLES: variable names cannot begin with '__': '${JSON.stringify(v)}'`, "This is a reserved variable naming convention");
295
+ throw new errors_1.InvalidVariableNameError(v, "Variable names cannot begin with '__'", interp.get_string_location());
295
296
  }
296
297
  module.add_variable(v);
297
298
  });
@@ -319,7 +320,7 @@ class GlobalModule extends module_1.Module {
319
320
  const string = interp.stack_pop();
320
321
  const string_location = interp.get_string_location();
321
322
  if (string)
322
- await interp.run(string, string_location);
323
+ await interp.run(string, { reference_location: string_location });
323
324
  }
324
325
  // ( names -- )
325
326
  word_EXPORT(interp) {
@@ -573,7 +574,7 @@ class GlobalModule extends module_1.Module {
573
574
  if (flags.with_key)
574
575
  interp.stack_push(key);
575
576
  interp.stack_push(value);
576
- await interp.run(forthic, string_location);
577
+ await interp.run(forthic, { reference_location: string_location });
577
578
  const group = interp.stack_pop();
578
579
  if (!result[group])
579
580
  result[group] = [];
@@ -630,7 +631,7 @@ class GlobalModule extends module_1.Module {
630
631
  for (let i = 0; i < items.length; i++) {
631
632
  const item = items[i];
632
633
  interp.stack_push(item);
633
- await interp.run(forthic, string_location);
634
+ await interp.run(forthic, { reference_location: string_location });
634
635
  const keys = interp.stack_pop();
635
636
  keys.forEach((k) => {
636
637
  const lowercased_key = k.toLowerCase();
@@ -669,7 +670,7 @@ class GlobalModule extends module_1.Module {
669
670
  if (flags.push_error)
670
671
  errors.push(await execute_returning_error(interp, forthic, string_location));
671
672
  else
672
- await interp.run(forthic, string_location);
673
+ await interp.run(forthic, { reference_location: string_location });
673
674
  }
674
675
  }
675
676
  else {
@@ -683,7 +684,7 @@ class GlobalModule extends module_1.Module {
683
684
  if (flags.push_error)
684
685
  errors.push(await execute_returning_error(interp, forthic, string_location));
685
686
  else
686
- await interp.run(forthic, string_location);
687
+ await interp.run(forthic, { reference_location: string_location });
687
688
  }
688
689
  }
689
690
  if (flags.push_error)
@@ -752,7 +753,7 @@ class GlobalModule extends module_1.Module {
752
753
  value2 = container2[i];
753
754
  interp.stack_push(container1[i]);
754
755
  interp.stack_push(value2);
755
- await interp.run(forthic, string_location);
756
+ await interp.run(forthic, { reference_location: string_location });
756
757
  const res = interp.stack_pop();
757
758
  result.push(res);
758
759
  }
@@ -764,7 +765,7 @@ class GlobalModule extends module_1.Module {
764
765
  const k = keys[i];
765
766
  interp.stack_push(container1[k]);
766
767
  interp.stack_push(container2[k]);
767
- await interp.run(forthic, string_location);
768
+ await interp.run(forthic, { reference_location: string_location });
768
769
  const res = interp.stack_pop();
769
770
  result[k] = res;
770
771
  }
@@ -836,7 +837,7 @@ class GlobalModule extends module_1.Module {
836
837
  const item = array[index];
837
838
  if (!start_found) {
838
839
  interp.stack_push(item);
839
- await interp.run(fstart, fstart_string_location);
840
+ await interp.run(fstart, { reference_location: fstart_string_location });
840
841
  start_found = interp.stack_pop();
841
842
  if (start_found) {
842
843
  start_index = index;
@@ -844,7 +845,7 @@ class GlobalModule extends module_1.Module {
844
845
  }
845
846
  if (start_found && !end_found) {
846
847
  interp.stack_push(item);
847
- await interp.run(fend, fend_string_location);
848
+ await interp.run(fend, { reference_location: fend_string_location });
848
849
  end_found = interp.stack_pop();
849
850
  if (end_found) {
850
851
  end_index = index;
@@ -1029,7 +1030,7 @@ class GlobalModule extends module_1.Module {
1029
1030
  if (flags.with_key)
1030
1031
  interp.stack_push(i);
1031
1032
  interp.stack_push(item);
1032
- await interp.run(forthic, string_location);
1033
+ await interp.run(forthic, { reference_location: string_location });
1033
1034
  const should_select = interp.stack_pop();
1034
1035
  if (should_select)
1035
1036
  result.push(item);
@@ -1044,7 +1045,7 @@ class GlobalModule extends module_1.Module {
1044
1045
  if (flags.with_key)
1045
1046
  interp.stack_push(k);
1046
1047
  interp.stack_push(v);
1047
- await interp.run(forthic, string_location);
1048
+ await interp.run(forthic, { reference_location: string_location });
1048
1049
  const should_select = interp.stack_pop();
1049
1050
  if (should_select)
1050
1051
  result[k] = v;
@@ -1199,7 +1200,7 @@ class GlobalModule extends module_1.Module {
1199
1200
  for (let i = 0; i < vals.length; i++) {
1200
1201
  const val = vals[i];
1201
1202
  interp.stack_push(val);
1202
- await interp.run(forthic, flag_string_position);
1203
+ await interp.run(forthic, { reference_location: flag_string_position });
1203
1204
  const aug_val = interp.stack_pop();
1204
1205
  res.push([val, aug_val]);
1205
1206
  }
@@ -1417,7 +1418,7 @@ class GlobalModule extends module_1.Module {
1417
1418
  interp.stack_push(initial);
1418
1419
  container.forEach(async (item) => {
1419
1420
  interp.stack_push(item);
1420
- await interp.run(forthic, string_location);
1421
+ await interp.run(forthic, { reference_location: string_location });
1421
1422
  });
1422
1423
  result = interp.stack_pop();
1423
1424
  }
@@ -1426,7 +1427,7 @@ class GlobalModule extends module_1.Module {
1426
1427
  Object.keys(container).forEach(async (k) => {
1427
1428
  const v = container[k];
1428
1429
  interp.stack_push(v);
1429
- await interp.run(forthic, string_location);
1430
+ await interp.run(forthic, { reference_location: string_location });
1430
1431
  });
1431
1432
  result = interp.stack_pop();
1432
1433
  }
@@ -2138,7 +2139,7 @@ class GlobalModule extends module_1.Module {
2138
2139
  }
2139
2140
  for (const item of items) {
2140
2141
  interp.stack_push(item);
2141
- await interp.run(fvalue, string_location);
2142
+ await interp.run(fvalue, { reference_location: string_location });
2142
2143
  const value = interp.stack_pop();
2143
2144
  let bucket = "BEFORE";
2144
2145
  for (const range_start of start_ranges) {
@@ -2298,7 +2299,7 @@ class GlobalModule extends module_1.Module {
2298
2299
  const string_location = interp.get_string_location();
2299
2300
  let value = interp.stack_pop();
2300
2301
  if (value === undefined || value === null || value === "") {
2301
- await interp.run(default_forthic, string_location);
2302
+ await interp.run(default_forthic, { reference_location: string_location });
2302
2303
  value = interp.stack_pop();
2303
2304
  }
2304
2305
  interp.stack_push(value);
@@ -2325,7 +2326,7 @@ class GlobalModule extends module_1.Module {
2325
2326
  // Store item so we can push it back later
2326
2327
  const item = interp.stack_pop();
2327
2328
  interp.stack_push(item);
2328
- await interp.run(forthic, string_location);
2329
+ await interp.run(forthic, { reference_location: string_location });
2329
2330
  const res = interp.stack_pop();
2330
2331
  // Push original item and result
2331
2332
  interp.stack_push(item);
@@ -2371,12 +2372,24 @@ class GlobalModule extends module_1.Module {
2371
2372
  const screen_forthic = interp.get_screen_forthic(name);
2372
2373
  const location = new tokenizer_1.CodeLocation({ screen_name: name });
2373
2374
  // await interp.run(screen_forthic, location);
2374
- await interp.run(screen_forthic, location);
2375
+ await interp.run(screen_forthic, { reference_location: location });
2375
2376
  }
2376
2377
  // ( -- )
2377
2378
  word_dot_s(interp) {
2378
- const stack = interp.stack;
2379
- console.log(stack);
2379
+ const stack = interp.get_stack();
2380
+ if (stack.length > 0) {
2381
+ console.log(stack[stack.length - 1]);
2382
+ }
2383
+ else {
2384
+ console.log("<STACK EMPTY>");
2385
+ }
2386
+ throw new errors_1.IntentionalStopError(".s");
2387
+ }
2388
+ // ( -- )
2389
+ word_dot_S(interp) {
2390
+ const stack = interp.get_stack();
2391
+ console.log(JSON.stringify(stack, null, 2));
2392
+ throw new errors_1.IntentionalStopError(".S");
2380
2393
  }
2381
2394
  // ( a b -- a - b )
2382
2395
  word_minus(interp) {
@@ -2402,7 +2415,7 @@ function drill_for_value(record, fields) {
2402
2415
  async function execute_returning_error(interp, forthic, string_location) {
2403
2416
  let result = null;
2404
2417
  try {
2405
- await interp.run(forthic, string_location);
2418
+ await interp.run(forthic, { reference_location: string_location });
2406
2419
  }
2407
2420
  catch (e) {
2408
2421
  result = e;