Adapt bf and chef to error handling

This commit is contained in:
Nilay Majorwar
2022-01-22 15:44:05 +05:30
parent 0efd4c79ef
commit 22ee70948a
8 changed files with 46 additions and 42 deletions

View File

@@ -1,5 +1,6 @@
import { MonacoTokensProvider } from "../types";
/** Error thrown on malformed syntax. Caught and converted into ParseError higher up */
export class SyntaxError extends Error {
constructor(message: string) {
super(message);
@@ -7,6 +8,11 @@ export class SyntaxError extends Error {
}
}
/** Check if an error is instance of SyntaxError */
export const isSyntaxError = (error: any): error is SyntaxError => {
return error instanceof SyntaxError || error.name === "SyntaxError";
};
/** Sample Hello World program for Chef */
export const sampleProgram = [
"Hello World Souffle.",
@@ -50,7 +56,7 @@ export const editorTokensProvider: MonacoTokensProvider = {
[/Method./, "red"],
[/mixing bowl/, "green"],
[/baking dish/, "blue"],
[/\d/, "sepia"],
[/\d(st|nd|rd|th)?/, "sepia"],
],
},
defaultToken: "plain",