fix: lint, type errors

test: specify types for path checks in interpreter tests

test: add optional chaining in lexer tests to prevent errors

test: add optional chaining in parser tests to prevent errors

fix: clean up whitespace and formatting in AST and lexer files

feat: enhance CLI with improved error handling and user prompts

fix: update index and interpreter files for better type handling

fix: clean up parser code for better readability and error handling

build: enable minification in tsdown configuration
This commit is contained in:
2025-09-01 02:44:45 +07:00
parent eb357ef703
commit 13d79e37bb
14 changed files with 279 additions and 248 deletions

View File

@@ -1,7 +1,7 @@
import type { QuestProgram } from './ast';
import { QuestInterpreter } from './interpreter';
import { Lexer } from './lexer';
import { Parser } from './parser';
import { QuestInterpreter } from './interpreter';
import type { QuestProgram } from './ast';
/**
* Main QuestLang processor
@@ -13,7 +13,7 @@ export class QuestLang {
public static parse(source: string): QuestProgram {
const lexer = new Lexer(source);
const tokens = lexer.tokenize();
const parser = new Parser(tokens);
return parser.parse();
}
@@ -33,18 +33,17 @@ export class QuestLang {
try {
const interpreter = this.interpret(source);
return interpreter.validate();
} catch (error) {
}
catch (error) {
return {
isValid: false,
errors: [error instanceof Error ? error.message : 'Unknown parsing error']
errors: [error instanceof Error ? error.message : 'Unknown parsing error'],
};
}
}
}
// Re-export main classes
export * from './ast';
export { QuestInterpreter } from './interpreter';
export { Lexer } from './lexer';
export { Parser } from './parser';
export { QuestInterpreter } from './interpreter';
export * from './ast';
export * from './types';