Add the start of a hindley-milner typechecker
The beginning of a parse-don't-validate-based hindley-milner typechecker, which returns on success an IR where every AST node trivially knows its own type, and using those types to determine LLVM types in codegen.
This commit is contained in:
parent
f8beda81fb
commit
32a5c0ff0f
20 changed files with 980 additions and 78 deletions
|
|
@ -8,7 +8,7 @@ use test_strategy::Arbitrary;
|
|||
|
||||
use crate::codegen::{self, Codegen};
|
||||
use crate::common::Result;
|
||||
use crate::parser;
|
||||
use crate::{parser, tc};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Arbitrary)]
|
||||
pub enum OutputFormat {
|
||||
|
|
@ -55,6 +55,8 @@ pub struct CompilerOptions {
|
|||
pub fn compile_file(input: &Path, output: &Path, options: &CompilerOptions) -> Result<()> {
|
||||
let src = fs::read_to_string(input)?;
|
||||
let (_, decls) = parser::toplevel(&src)?; // TODO: statements
|
||||
let decls = tc::typecheck_toplevel(decls)?;
|
||||
|
||||
let context = codegen::Context::create();
|
||||
let mut codegen = Codegen::new(
|
||||
&context,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue