Compare commits
2 Commits
b805d9b48f
...
33ad996f0f
Author | SHA1 | Date | |
---|---|---|---|
33ad996f0f | |||
fb565d64ad |
14
deno.lock
generated
14
deno.lock
generated
@ -33,5 +33,19 @@
|
|||||||
"source-map-generator@0.8.0": {
|
"source-map-generator@0.8.0": {
|
||||||
"integrity": "sha512-psgxdGMwl5MZM9S3FWee4EgsEaIjahYV5AzGnwUvPhWeITz/j6rKpysQHlQ4USdxvINlb8lKfWGIXwfkrgtqkA=="
|
"integrity": "sha512-psgxdGMwl5MZM9S3FWee4EgsEaIjahYV5AzGnwUvPhWeITz/j6rKpysQHlQ4USdxvINlb8lKfWGIXwfkrgtqkA=="
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"remote": {
|
||||||
|
"https://raw.githubusercontent.com/camper0008/cjsongen/refs/heads/main/assert.ts": "4a54f8579508401784d2f73e36bb8c877ff0e0ecd3abd58cab30e25f7f32ed73",
|
||||||
|
"https://raw.githubusercontent.com/camper0008/cjsongen/refs/heads/main/gen/common.ts": "7d84fecc3514ee88c6011bd2e0d49836a64a5370c6444f720a79f20f4da1b6da",
|
||||||
|
"https://raw.githubusercontent.com/camper0008/cjsongen/refs/heads/main/gen/json/mod.ts": "c877192ee6d9c06daf1354c0ae4c4a5bdef4b939473e59a3c93f93d09dac0098",
|
||||||
|
"https://raw.githubusercontent.com/camper0008/cjsongen/refs/heads/main/gen/json/ser.ts": "bed61f8b9fd63ff1de0c450376747ec11d48ff2ca254ac2f1b7897ea90e19948",
|
||||||
|
"https://raw.githubusercontent.com/camper0008/cjsongen/refs/heads/main/gen/mod.ts": "c76da4b63b7d6dafc5538bf069a6d5578b7b7174c1081d8acc5ee2758a454c08",
|
||||||
|
"https://raw.githubusercontent.com/camper0008/cjsongen/refs/heads/main/gen/typedef.ts": "582f7edebcf56354a1256b4e03b05e9bc5b72d934cad04b422e78b0743c8837c",
|
||||||
|
"https://raw.githubusercontent.com/camper0008/cjsongen/refs/heads/main/mod.ts": "b233ee0f643f2af5aad4a6464eff02e7465c6c6851b4bab80861a351c9815962",
|
||||||
|
"https://raw.githubusercontent.com/camper0008/cjsongen/refs/heads/main/repr/hir.ts": "0a12a18d29919512ff725fe0c3eeddf5fa8c79752c2b32b0c05bde859051651d",
|
||||||
|
"https://raw.githubusercontent.com/camper0008/cjsongen/refs/heads/main/repr/mir.ts": "0807554f8a7598e17dcf8204ba4daff31d22bd6c59beaa461771f0070ea1a546",
|
||||||
|
"https://raw.githubusercontent.com/camper0008/cjsongen/refs/heads/main/repr/mod.ts": "ebbee03923a8182d9e7c6e388cdc7e28ceecae8ae56560206d6b903dcb498624",
|
||||||
|
"https://raw.githubusercontent.com/camper0008/cjsongen/refs/heads/main/repr/node.ts": "0b0f390a4e45108ffcdcd6cc30a8e603e8145f8f58715e541684d4983fc0417c",
|
||||||
|
"https://raw.githubusercontent.com/camper0008/cjsongen/refs/heads/main/repr/primitives.ts": "3ac29c80ef54c2f789fc539218d18da502d9ac0563a7a9e065a6df4a04380be5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
26
main.ts
26
main.ts
@ -1,6 +1,7 @@
|
|||||||
import * as parser from "./parser.out.js";
|
import * as parser from "./parser.out.js";
|
||||||
import * as yaml from "jsr:@std/yaml";
|
import * as yaml from "jsr:@std/yaml";
|
||||||
import * as ast from "./ast.ts";
|
import * as ast from "./ast.ts";
|
||||||
|
import * as cjg from "https://raw.githubusercontent.com/camper0008/cjsongen/refs/heads/main/mod.ts";
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const filename = Deno.args[0];
|
const filename = Deno.args[0];
|
||||||
@ -40,6 +41,22 @@ async function main() {
|
|||||||
if (rep.errorOccured) {
|
if (rep.errorOccured) {
|
||||||
console.log("Errors occured. Stopping...");
|
console.log("Errors occured. Stopping...");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// const hir: cjg.repr.hir.Struct = {
|
||||||
|
// name: "Product",
|
||||||
|
// values: {
|
||||||
|
// value: "int",
|
||||||
|
// },
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// const mir = cjg.repr.mir.fromHir(hir);
|
||||||
|
// const nodes = cjg.repr.fromMir(mir);
|
||||||
|
// const structDefCode = cjg.gen.typedef.structDef(nodes);
|
||||||
|
// const serDefCode = cjg.gen.json.serializerDef(nodes);
|
||||||
|
// const serImplCode = cjg.gen.json.serializerImpl(nodes);
|
||||||
|
// console.log(structDefCode);
|
||||||
|
// console.log(serDefCode);
|
||||||
|
// console.log(serImplCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
type MonoUnit = {
|
type MonoUnit = {
|
||||||
@ -397,27 +414,28 @@ class Reporter {
|
|||||||
|
|
||||||
public info(msg: string, loc?: ast.Loc) {
|
public info(msg: string, loc?: ast.Loc) {
|
||||||
console.error(
|
console.error(
|
||||||
`%cerror%c: ${msg}%c`,
|
`%cinfo%c: ${msg}%c`,
|
||||||
"color: cyan; font-weight: bold",
|
"color: cyan; font-weight: bold",
|
||||||
"font-weight: bold",
|
"font-weight: bold",
|
||||||
"",
|
"",
|
||||||
);
|
);
|
||||||
if (loc) {
|
if (loc) {
|
||||||
this.printLoc(loc);
|
this.printLoc(loc, "cyan");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private printLoc(loc: ast.Loc) {
|
private printLoc(loc: ast.Loc, caretColor = "red") {
|
||||||
const line = this.text.split("\n")[loc.start.line - 1];
|
const line = this.text.split("\n")[loc.start.line - 1];
|
||||||
const posPad = " ".repeat(loc.start.column - 1);
|
const posPad = " ".repeat(loc.start.column - 1);
|
||||||
const lineNr = loc.start.line.toString().padStart(3, " ");
|
const lineNr = loc.start.line.toString().padStart(3, " ");
|
||||||
const lPad = " ".repeat(lineNr.length + 1);
|
const lPad = " ".repeat(lineNr.length + 1);
|
||||||
const pos = `./${loc.source}:${loc.start.line}:${loc.start.column}`;
|
const pos = `./${loc.source}:${loc.start.line}:${loc.start.column}`;
|
||||||
console.error(
|
console.error(
|
||||||
`%c --> ${pos}\n${lPad}|\n${lineNr} |%c${line}%c\n${lPad}|${posPad}^%c`,
|
`%c --> ${pos}\n${lPad}|\n${lineNr} |%c${line}%c\n${lPad}|${posPad}%c^%c`,
|
||||||
"color: gray",
|
"color: gray",
|
||||||
"color: lightgray",
|
"color: lightgray",
|
||||||
"color: gray",
|
"color: gray",
|
||||||
|
`color: ${caretColor}; font-weight: bold`,
|
||||||
"",
|
"",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user