Skip to content
This repository was archived by the owner on Oct 20, 2022. It is now read-only.

Commit 17e9498

Browse files
committed
Give more details about unsupported compiler operations
1 parent c5d3422 commit 17e9498

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/code-generator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export function compile(tree: SyntaxTree): string {
6767
} else if (tree.argument1.argument2.content.lexeme == "number") {
6868
type = "%d"
6969
} else {
70-
throw 'Unsupported operation.'
70+
throw `Unsupported type '${tree.argument1.argument2.content.lexeme}'.`
7171
}
7272
return `printf("${type}", ${compile(tree.argument1)});\n`
7373
}

src/optimiser.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ function checkConstantOperations(node: SyntaxTree) {
242242
} else if (node.argument1.content.name == 'ASTERISK') {
243243
result = value1 * value2
244244
} else {
245-
throw 'Unsupported operation.'
245+
throw `Unsupported operation '${node.argument1.content.name}'.`
246246
}
247247

248248
updated = true
@@ -263,7 +263,7 @@ function checkConstantOperations(node: SyntaxTree) {
263263
}
264264
/* String */
265265
} else {
266-
throw 'Unsupported operation.'
266+
throw `Unsupported type ${node.argument1.argument1.argument2.content.lexeme}.`
267267
}
268268
}
269269
}
@@ -285,7 +285,7 @@ function checkConstantOperations(node: SyntaxTree) {
285285
} else if (node.argument2.content.name == 'ASTERISK') {
286286
result = value1 * value2
287287
} else {
288-
throw 'Unsupported operation.'
288+
throw `Unsupported operation '${node.argument2.content.name}'.`
289289
}
290290

291291
updated = true
@@ -306,7 +306,7 @@ function checkConstantOperations(node: SyntaxTree) {
306306
}
307307
/* String */
308308
} else {
309-
throw 'Unsupported operation.'
309+
throw `Unsupported type '${node.argument2.argument1.argument2.content.lexeme}'.`
310310
}
311311
}
312312
}

0 commit comments

Comments
 (0)