mirror of
https://github.com/Noratrieb/riverdelta.git
synced 2026-01-15 00:45:04 +01:00
parser
This commit is contained in:
parent
91b183c002
commit
4e95bc05a3
9 changed files with 640 additions and 132 deletions
16
src/index.ts
16
src/index.ts
|
|
@ -1,18 +1,30 @@
|
|||
import { withErrorHandler } from "./error";
|
||||
import { tokenize } from "./lexer";
|
||||
import { parse } from "./parser";
|
||||
import { printAst } from "./printer";
|
||||
|
||||
const input = `
|
||||
function hello() {}
|
||||
function main() = (
|
||||
print("Hello, world!");
|
||||
"uwu";
|
||||
);
|
||||
`;
|
||||
|
||||
function main() {
|
||||
withErrorHandler(input, () => {
|
||||
const tokens = tokenize(input);
|
||||
console.log("-----TOKENS---");
|
||||
console.log(tokens);
|
||||
|
||||
const ast = parse(tokens);
|
||||
console.log(ast);
|
||||
console.log("-----AST------");
|
||||
|
||||
console.dir(ast, { depth: 10 });
|
||||
|
||||
const printed = printAst(ast);
|
||||
console.log("-----AST pretty------");
|
||||
console.log(printed);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue