@forthic/interp 0.4.0 → 0.5.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.
@@ -1,70 +1,73 @@
1
1
  import { CodeLocation } from "./tokenizer";
2
- declare class ForthicError extends Error {
2
+ export declare class ForthicError extends Error {
3
+ private forthic;
3
4
  private note;
4
5
  private location?;
5
- constructor(note: string, location?: CodeLocation);
6
+ constructor(forthic: string, note: string, location?: CodeLocation);
7
+ getDescription(): string;
6
8
  getLocation(): CodeLocation;
9
+ getForthic(): string;
7
10
  getNote(): string;
8
11
  getMessage(): string;
9
12
  }
10
13
  export declare class UnknownWordError extends ForthicError {
11
14
  private word;
12
- constructor(word: string, location?: CodeLocation);
15
+ constructor(forthic: string, word: string, location?: CodeLocation);
13
16
  getWord(): string;
14
17
  }
15
18
  export declare class InvalidVariableNameError extends ForthicError {
16
19
  private var_name;
17
20
  private addl_note;
18
- constructor(var_name: string, addl_note: string, location?: CodeLocation);
21
+ constructor(forthic: string, var_name: string, addl_note: string, location?: CodeLocation);
19
22
  getVarName(): string;
20
23
  getAddlNote(): string;
21
24
  }
22
25
  export declare class UnknownScreenError extends ForthicError {
23
26
  private screen_name;
24
- constructor(screen_name: string, location?: CodeLocation);
27
+ constructor(forthic: string, screen_name: string, location?: CodeLocation);
25
28
  getScreenName(): string;
26
29
  }
27
30
  export declare class UnknownModuleError extends ForthicError {
28
31
  private module_name;
29
- constructor(module_name: string, location?: CodeLocation);
32
+ constructor(forthic: string, module_name: string, location?: CodeLocation);
30
33
  getModuleName(): string;
31
34
  }
32
35
  export declare class TooManyAttemptsError extends ForthicError {
33
36
  private num_attempts;
34
37
  private max_attempts;
35
- constructor(num_attempts: number, max_attempts: number, location?: CodeLocation);
38
+ constructor(forthic: string, num_attempts: number, max_attempts: number, location?: CodeLocation);
36
39
  getNumAttempts(): number;
37
40
  getMaxAttempts(): number;
38
41
  }
39
42
  export declare class WordExecutionError extends ForthicError {
40
43
  private word_name;
41
44
  private error;
42
- constructor(word_name: string, error: Error, location?: CodeLocation);
45
+ constructor(forthic: string, word_name: string, error: Error, location?: CodeLocation);
43
46
  getWordName(): string;
44
47
  getError(): Error;
45
48
  }
46
49
  export declare class ModuleError extends ForthicError {
47
50
  private module_name;
48
51
  private error;
49
- constructor(module_name: string, error: Error, location?: CodeLocation);
52
+ constructor(forthic: string, module_name: string, error: Error, location?: CodeLocation);
50
53
  getModuleName(): string;
51
54
  getError(): Error;
52
55
  }
53
56
  export declare class StackUnderflowError extends ForthicError {
54
- constructor(location?: CodeLocation);
57
+ constructor(forthic: string, location?: CodeLocation);
55
58
  }
56
59
  export declare class UnknownTokenError extends ForthicError {
57
60
  private token;
58
- constructor(token: string, location?: CodeLocation);
61
+ constructor(forthic: string, token: string, location?: CodeLocation);
59
62
  getToken(): string;
60
63
  }
61
64
  export declare class MissingSemicolonError extends ForthicError {
62
- constructor(location?: CodeLocation);
65
+ constructor(forthic: string, location?: CodeLocation);
63
66
  }
64
67
  export declare class ExtraSemicolonError extends ForthicError {
65
- constructor(location?: CodeLocation);
68
+ constructor(forthic: string, location?: CodeLocation);
66
69
  }
67
70
  export declare class IntentionalStopError extends Error {
68
71
  constructor(message: string);
69
72
  }
70
- export {};
73
+ export declare function get_error_description(forthic: string, forthicError: ForthicError): string;
@@ -1,17 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.IntentionalStopError = exports.ExtraSemicolonError = exports.MissingSemicolonError = exports.UnknownTokenError = exports.StackUnderflowError = exports.ModuleError = exports.WordExecutionError = exports.TooManyAttemptsError = exports.UnknownModuleError = exports.UnknownScreenError = exports.InvalidVariableNameError = exports.UnknownWordError = void 0;
3
+ exports.IntentionalStopError = exports.ExtraSemicolonError = exports.MissingSemicolonError = exports.UnknownTokenError = exports.StackUnderflowError = exports.ModuleError = exports.WordExecutionError = exports.TooManyAttemptsError = exports.UnknownModuleError = exports.UnknownScreenError = exports.InvalidVariableNameError = exports.UnknownWordError = exports.ForthicError = void 0;
4
+ exports.get_error_description = get_error_description;
4
5
  class ForthicError extends Error {
5
- constructor(note, location) {
6
- const location_note = location ? ` at ${location.screen_name}:${location.line}:${location.column}` : "";
7
- const message = `${note}${location_note}`;
6
+ constructor(forthic, note, location) {
7
+ const message = `${note}`;
8
8
  super(message);
9
+ this.forthic = forthic;
9
10
  this.note = note;
10
11
  this.location = location;
11
12
  }
13
+ getDescription() {
14
+ return get_error_description(this.forthic, this);
15
+ }
12
16
  getLocation() {
13
17
  return this.location;
14
18
  }
19
+ getForthic() {
20
+ return this.forthic;
21
+ }
15
22
  getNote() {
16
23
  return this.note;
17
24
  }
@@ -19,13 +26,14 @@ class ForthicError extends Error {
19
26
  return this.message;
20
27
  }
21
28
  }
29
+ exports.ForthicError = ForthicError;
22
30
  // ============================================================
23
31
  // Interpreter errors
24
32
  // Interpreter couldn't find word in dictionaries
25
33
  class UnknownWordError extends ForthicError {
26
- constructor(word, location) {
34
+ constructor(forthic, word, location) {
27
35
  const note = `Unknown word: ${word}`;
28
- super(note, location);
36
+ super(forthic, note, location);
29
37
  this.word = word;
30
38
  this.name = "UnknownWordError";
31
39
  }
@@ -36,9 +44,9 @@ class UnknownWordError extends ForthicError {
36
44
  exports.UnknownWordError = UnknownWordError;
37
45
  // Variable name is not allowed
38
46
  class InvalidVariableNameError extends ForthicError {
39
- constructor(var_name, addl_note, location) {
47
+ constructor(forthic, var_name, addl_note, location) {
40
48
  const note = `Invalid variable name: ${var_name}(${addl_note})`;
41
- super(note, location);
49
+ super(forthic, note, location);
42
50
  this.var_name = var_name;
43
51
  this.addl_note = addl_note;
44
52
  this.name = "InvalidVariableNameError";
@@ -53,9 +61,9 @@ class InvalidVariableNameError extends ForthicError {
53
61
  exports.InvalidVariableNameError = InvalidVariableNameError;
54
62
  // Interpreter couldn't find screen
55
63
  class UnknownScreenError extends ForthicError {
56
- constructor(screen_name, location) {
64
+ constructor(forthic, screen_name, location) {
57
65
  const note = `Unknown screen: ${screen_name}`;
58
- super(note, location);
66
+ super(forthic, note, location);
59
67
  this.screen_name = screen_name;
60
68
  this.name = "UnknownScreenError";
61
69
  }
@@ -66,9 +74,9 @@ class UnknownScreenError extends ForthicError {
66
74
  exports.UnknownScreenError = UnknownScreenError;
67
75
  // Interpreter couldn't find module
68
76
  class UnknownModuleError extends ForthicError {
69
- constructor(module_name, location) {
77
+ constructor(forthic, module_name, location) {
70
78
  const note = `Unknown module: ${module_name}`;
71
- super(note, location);
79
+ super(forthic, note, location);
72
80
  this.module_name = module_name;
73
81
  this.name = "UnknownModuleError";
74
82
  }
@@ -78,9 +86,9 @@ class UnknownModuleError extends ForthicError {
78
86
  }
79
87
  exports.UnknownModuleError = UnknownModuleError;
80
88
  class TooManyAttemptsError extends ForthicError {
81
- constructor(num_attempts, max_attempts, location) {
89
+ constructor(forthic, num_attempts, max_attempts, location) {
82
90
  const note = `Too many recovery attempts: ${num_attempts} of ${max_attempts}`;
83
- super(note, location);
91
+ super(forthic, note, location);
84
92
  this.num_attempts = num_attempts;
85
93
  this.max_attempts = max_attempts;
86
94
  this.name = "TooManyAttemptsError";
@@ -94,9 +102,9 @@ class TooManyAttemptsError extends ForthicError {
94
102
  }
95
103
  exports.TooManyAttemptsError = TooManyAttemptsError;
96
104
  class WordExecutionError extends ForthicError {
97
- constructor(word_name, error, location) {
98
- const note = `Error executing word: ${word_name}`;
99
- super(note, location);
105
+ constructor(forthic, word_name, error, location) {
106
+ const note = `(${error.message}) when executing word ${word_name}`;
107
+ super(forthic, note, location);
100
108
  this.word_name = word_name;
101
109
  this.error = error;
102
110
  this.name = "WordExecutionError";
@@ -110,9 +118,9 @@ class WordExecutionError extends ForthicError {
110
118
  }
111
119
  exports.WordExecutionError = WordExecutionError;
112
120
  class ModuleError extends ForthicError {
113
- constructor(module_name, error, location) {
121
+ constructor(forthic, module_name, error, location) {
114
122
  const note = `Error in module ${module_name}`;
115
- super(note, location);
123
+ super(forthic, note, location);
116
124
  this.module_name = module_name;
117
125
  this.error = error;
118
126
  this.name = "ModuleError";
@@ -126,17 +134,17 @@ class ModuleError extends ForthicError {
126
134
  }
127
135
  exports.ModuleError = ModuleError;
128
136
  class StackUnderflowError extends ForthicError {
129
- constructor(location) {
137
+ constructor(forthic, location) {
130
138
  const note = `Stack underflow`;
131
- super(note, location);
139
+ super(forthic, note, location);
132
140
  this.name = "StackUnderflowError";
133
141
  }
134
142
  }
135
143
  exports.StackUnderflowError = StackUnderflowError;
136
144
  class UnknownTokenError extends ForthicError {
137
- constructor(token, location) {
145
+ constructor(forthic, token, location) {
138
146
  const note = `(Should never happen) Unknown type of token: ${token}`;
139
- super(note, location);
147
+ super(forthic, note, location);
140
148
  this.token = token;
141
149
  this.name = "UnknownTokenError";
142
150
  }
@@ -146,17 +154,17 @@ class UnknownTokenError extends ForthicError {
146
154
  }
147
155
  exports.UnknownTokenError = UnknownTokenError;
148
156
  class MissingSemicolonError extends ForthicError {
149
- constructor(location) {
150
- const note = `Missing semicolon -- new definition started before previous one was complete`;
151
- super(note, location);
157
+ constructor(forthic, location) {
158
+ const note = `Definition was missing its semicolon`;
159
+ super(forthic, note, location);
152
160
  this.name = "MissingSemicolonError";
153
161
  }
154
162
  }
155
163
  exports.MissingSemicolonError = MissingSemicolonError;
156
164
  class ExtraSemicolonError extends ForthicError {
157
- constructor(location) {
158
- const note = `Extra semicolon -- no definition in progress`;
159
- super(note, location);
165
+ constructor(forthic, location) {
166
+ const note = `Unexpected semicolon -- no definition in progress`;
167
+ super(forthic, note, location);
160
168
  this.name = "ExtraSemicolonError";
161
169
  }
162
170
  }
@@ -171,4 +179,23 @@ class IntentionalStopError extends Error {
171
179
  }
172
180
  }
173
181
  exports.IntentionalStopError = IntentionalStopError;
182
+ // ============================================================
183
+ // Utility functions
184
+ function get_error_description(forthic, forthicError) {
185
+ // If don't have any extra info, just return the note
186
+ if (!forthic || forthic === "" || forthicError.getLocation() === undefined) {
187
+ return forthicError.getNote();
188
+ }
189
+ // Otherwise, return the note and indicate where the error occurred
190
+ const location = forthicError.getLocation();
191
+ // Extract line where error occurred and highlight the error
192
+ const line_num = location.line;
193
+ // Get lines up to line_num
194
+ const lines = forthic.split("\n").slice(0, line_num);
195
+ // Error line is the line with the error, but with the error location highlighted and everything else a space
196
+ const error_line = " ".repeat(location.column - 1) + "^".repeat(location.end_pos - location.start_pos);
197
+ // Print all forthic lines with numbers adding the error line
198
+ const error_message = `${forthicError.getNote()} at line ${line_num}:\n\`\`\`\n${lines.map((line) => `${line}`).join("\n")}\n${error_line}\n\`\`\``;
199
+ return error_message;
200
+ }
174
201
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/forthic/errors.ts"],"names":[],"mappings":";;;AAEA,MAAM,YAAa,SAAQ,KAAK;IAC5B,YAAoB,IAAY,EAAU,QAAuB;QAC7D,MAAM,aAAa,GAAG,QAAQ,CAAC,CAAC,CAAC,OAAO,QAAQ,CAAC,WAAW,IAAI,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACxG,MAAM,OAAO,GAAG,GAAG,IAAI,GAAG,aAAa,EAAE,CAAC;QAE1C,KAAK,CAAC,OAAO,CAAC,CAAC;QAJC,SAAI,GAAJ,IAAI,CAAQ;QAAU,aAAQ,GAAR,QAAQ,CAAe;IAKjE,CAAC;IAED,WAAW;QACP,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAED,OAAO;QACH,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IAED,UAAU;QACN,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;CACJ;AAED,+DAA+D;AAC/D,qBAAqB;AAErB,iDAAiD;AACjD,MAAa,gBAAiB,SAAQ,YAAY;IAChD,YAAoB,IAAY,EAAE,QAAuB;QACvD,MAAM,IAAI,GAAG,iBAAiB,IAAI,EAAE,CAAC;QACrC,KAAK,C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CAAC;IACpJ,OAAO,aAAa,CAAC;AACzB,CAAC"}
@@ -292,7 +292,7 @@ class GlobalModule extends module_1.Module {
292
292
  const module = interp.cur_module();
293
293
  varnames.forEach((v) => {
294
294
  if (v.match(/__.*/)) {
295
- throw new errors_1.InvalidVariableNameError(v, "Variable names cannot begin with '__'", interp.get_string_location());
295
+ throw new errors_1.InvalidVariableNameError(interp.get_top_input_string(), v, "Variable names cannot begin with '__'", interp.get_string_location());
296
296
  }
297
297
  module.add_variable(v);
298
298
  });