finished move to rust

This commit is contained in:
Andrew Segavac
2021-09-12 15:00:03 -06:00
parent 8c131c035b
commit 170176bc3e
18 changed files with 5 additions and 1424 deletions

View File

@@ -1,4 +1,3 @@
use std::str::FromStr;
use crate::ast;
grammar(id_generator: &ast::IdGenerator);

View File

@@ -9,9 +9,7 @@ extern crate lalrpop_util;
lalrpop_mod!(pub grammar); // synthesized by LALRPOP
use std::fs;
use std::io::Write;
// mod compiler;
// use inkwell::context::Context;
extern crate clap;
use clap::{App, Arg};
@@ -49,7 +47,7 @@ fn main() {
.last()
.unwrap()
.clone();
let output = matches.value_of("OUTPUT").unwrap_or(default_output);
let _output = matches.value_of("OUTPUT").unwrap_or(default_output);
let contents = fs::read_to_string(input).expect("input file not found");
let unknown_id_gen = ast::IdGenerator::new();

View File

@@ -148,15 +148,6 @@ impl Context {
return ctx;
}
fn add_type(&self, name: String, type_decl: &ast::TypeDeclaration) -> Context {
let mut ctx = self.clone();
ctx.environment.insert(
name.to_string(),
NamedEntity::TypeDeclaration(type_decl.clone()),
);
return ctx;
}
fn set_current_function_return(&self, function: &ast::TypeUsage) -> Context {
let mut ctx = self.clone();
ctx.current_function_return = Some(function.clone());
@@ -183,7 +174,7 @@ fn type_exists(ctx: &Context, type_: &ast::TypeUsage) -> Result<()> {
}
}
}
ast::TypeUsage::Unknown(unknown) => {} // do nothing
ast::TypeUsage::Unknown(_) => {} // do nothing
ast::TypeUsage::Function(function) => {
let mut errs = vec![];
for arg in function.arguments.iter() {