Comparing version 0.1.0 to 0.2.0
@@ -16,3 +16,3 @@ import { Token } from './token.js'; | ||
kind: "literal"; | ||
value: null | number | string; | ||
value: boolean | null | number | string; | ||
} | ||
@@ -19,0 +19,0 @@ interface Unary { |
@@ -0,1 +1,4 @@ | ||
import { Token } from './token.js'; | ||
import './token-type.js'; | ||
declare function add(a: number, b: number): number; | ||
@@ -5,4 +8,5 @@ declare function runFile(path: string): Promise<void>; | ||
declare function error(line: number, message: string): void; | ||
declare function errorOnToken(token: Token, message: string): void; | ||
declare function main(): Promise<void>; | ||
export { add, error, main, runFile, runPrompt }; | ||
export { add, error, errorOnToken, main, runFile, runPrompt }; |
import * as fs from "node:fs/promises"; | ||
import { createInterface } from "node:readline"; | ||
import { visitExpr } from "./ast.js"; | ||
import { astPrinter } from "./ast-printer.js"; | ||
import { parse } from "./parser.js"; | ||
import { Scanner } from "./scanner.js"; | ||
@@ -23,2 +26,9 @@ function add(a, b) { | ||
} | ||
function errorOnToken(token, message) { | ||
if (token.type === "eof") { | ||
report(token.line, " at end", message); | ||
} else { | ||
report(token.line, ` at '${token.lexeme}'`, message); | ||
} | ||
} | ||
function report(line, where, message) { | ||
@@ -30,3 +40,7 @@ console.error(`[line ${line}] Error${where}: ${message}`); | ||
const tokens = scanner.scanTokens(); | ||
console.log(tokens); | ||
const expr = parse(tokens); | ||
if (hadError || !expr) { | ||
return; | ||
} | ||
console.log(visitExpr(expr, astPrinter)); | ||
} | ||
@@ -50,2 +64,3 @@ async function main() { | ||
error, | ||
errorOnToken, | ||
main, | ||
@@ -52,0 +67,0 @@ runFile, |
{ | ||
"name": "gravlax", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "A Lox interpreter with tasty TypeScript seasoning", | ||
@@ -57,2 +57,3 @@ "repository": { | ||
"eslint-plugin-n": "^16.6.1", | ||
"eslint-plugin-no-autofix": "^1.2.3", | ||
"eslint-plugin-no-only-tests": "^3.1.0", | ||
@@ -59,0 +60,0 @@ "eslint-plugin-perfectionist": "^2.5.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41477
27
492
40