mirror of
https://github.com/robonen/questlang.git
synced 2026-03-20 19:04:47 +00:00
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:
17
src/index.ts
17
src/index.ts
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user