-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.ts
More file actions
27 lines (23 loc) · 780 Bytes
/
example.ts
File metadata and controls
27 lines (23 loc) · 780 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { loadOhmGrammar } from "./src/codepath-ohm.ts";
import { Codepath } from "./mod.ts";
// Generate a codepath for this call site and verify it matches the DSL grammar
function myFn() {
const codepath = new Codepath();
const grammar = loadOhmGrammar();
const match = grammar.match(`${codepath}`);
if (match.succeeded()) {
console.log("✓ Valid codepath DSL");
} else {
console.error(`✗ Invalid codepath DSL: ${match.message}`);
Deno.exit(1);
}
return codepath;
}
// deno-lint-ignore no-constant-condition
if (true) {
const codepath = myFn();
// Show platform-specific URLs
console.log("Codepath:", codepath.toString());
console.log("VSCode URL:", codepath.toScheme("vscode"));
console.log("File URL:", codepath.toScheme("file"));
}