Skip to content

Commit

Permalink
refactor: main.ts -> kin.ts && parsing source codes
Browse files Browse the repository at this point in the history
  • Loading branch information
pacifiquem committed Jan 31, 2024
1 parent ebd1ab5 commit 3c63000
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/kin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,15 @@ if (file) {
}

async function run(filename: string): Promise<void> {
const input: string = readFileSync(filename, 'utf-8');
const parser = new Parser();
LogMessage(parser.produceAST(input));
try {
const input: string = readFileSync(filename, 'utf-8');
const parser = new Parser();
LogMessage(parser.produceAST(input));
} catch (error) {
const err = error as Error;
LogError(err);
process.exit(1);
}
}

async function repl() {
Expand All @@ -40,15 +46,16 @@ async function repl() {

// check for no user input or exit keyword.
if (input === '.exit' || input === '.quit' || input === '.q') {
process.exit(1);
process.exit(0);
}

try {
const parser = new Parser();
LogMessage(parser.produceAST(input));
} catch (error: unknown) {
const err = error as Error;
LogError(err.message);
LogError(err);
process.exit(1);
}
}
}

0 comments on commit 3c63000

Please sign in to comment.