You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.2 KiB
TypeScript

import { evaluate } from './interpreter'
import type { AST } from './ast'
import type { Env } from './env'
import { tokenize } from './lexer'
import { Parser } from './parser'
const ast: AST = {
kind: 'binaryop',
operator: '+',
left: {
kind: 'literal',
value: { kind: 'int', value: 1 }
},
right: {
kind: 'binaryop',
operator: '*',
left: {
kind: 'literal',
value: { kind: 'int', value: 2 }
},
right: {
kind: 'literal',
value: { kind: 'int', value: 3 }
}
}
};
const env: Env = new Map();
// const res = evaluate(ast, env);
// console.log(res);
const str = `
# This is a comment
double = x \\ x * 2
read_line! : Unit \\ String
`;
console.log(tokenize(str));
// const tokens = tokenize("x");
// const p = new Parser(tokens);
// console.log(p.parse());
/*
const tokens2 = tokenize("let x = (y) => 5 + y in x(3)");
// const tokens2 = tokenize("let x = 5 in x * 4");
// const tokens2 = tokenize("(x, y) => x + y");
const p2 = new Parser(tokens2);
const ast3 = p2.parse();
const env3: Env = new Map();
console.log(ast3);
console.log(evaluate(ast3, env3));
*/