From 69d5f38ea143d33954a02df86f8d4c07f37d8898 Mon Sep 17 00:00:00 2001 From: greg Date: Mon, 30 Oct 2017 22:18:02 -0700 Subject: [PATCH] Refactor into libs part II woo it compiles --- schala-lib/src/lib.rs | 8 ++++---- src/maaru_lang/compilation.rs | 4 ++-- src/maaru_lang/mod.rs | 2 +- src/maaru_lang/tokenizer.rs | 2 +- src/main.rs | 3 +-- src/robo_lang/mod.rs | 2 +- src/schala_lang/mod.rs | 2 +- 7 files changed, 11 insertions(+), 12 deletions(-) diff --git a/schala-lib/src/lib.rs b/schala-lib/src/lib.rs index 12bc6d8..21a5b55 100644 --- a/schala-lib/src/lib.rs +++ b/schala-lib/src/lib.rs @@ -23,16 +23,16 @@ use std::io::{Read, Write}; use std::process::exit; use std::default::Default; -mod language; +pub mod language; use language::{ProgrammingLanguageInterface, EvalOptions, LLVMCodeString}; mod webapp; -mod llvm_wrap; +pub mod llvm_wrap; include!(concat!(env!("OUT_DIR"), "/static.rs")); -type PLIGenerator = Box Box + Send + Sync>; +pub type PLIGenerator = Box Box + Send + Sync>; -fn schala_main(generators: Vec) { +pub fn schala_main(generators: Vec) { let languages: Vec> = generators.iter().map(|x| x()).collect(); let option_matches = program_options().parse(std::env::args()).unwrap_or_else(|e| { diff --git a/src/maaru_lang/compilation.rs b/src/maaru_lang/compilation.rs index b28fe5c..75d2bf8 100644 --- a/src/maaru_lang/compilation.rs +++ b/src/maaru_lang/compilation.rs @@ -6,9 +6,9 @@ use self::llvm_sys::prelude::*; use self::llvm_sys::{LLVMIntPredicate}; use maaru_lang::parser::{AST, Statement, Function, Prototype, Expression, BinOp}; -use language::LLVMCodeString; +use schala_lib::language::LLVMCodeString; -use llvm_wrap as LLVMWrap; +use schala_lib::llvm_wrap as LLVMWrap; type VariableMap = HashMap; diff --git a/src/maaru_lang/mod.rs b/src/maaru_lang/mod.rs index 4ab810d..65be02f 100644 --- a/src/maaru_lang/mod.rs +++ b/src/maaru_lang/mod.rs @@ -3,7 +3,7 @@ pub mod parser; pub mod eval; pub mod compilation; -use language::{ProgrammingLanguageInterface, EvalOptions, ReplOutput, TraceArtifact, LLVMCodeString}; +use schala_lib::language::{ProgrammingLanguageInterface, EvalOptions, ReplOutput, TraceArtifact, LLVMCodeString}; pub use self::eval::Evaluator as MaaruEvaluator; diff --git a/src/maaru_lang/tokenizer.rs b/src/maaru_lang/tokenizer.rs index ad979e1..7c11fd4 100644 --- a/src/maaru_lang/tokenizer.rs +++ b/src/maaru_lang/tokenizer.rs @@ -5,7 +5,7 @@ use std::str::Chars; use self::itertools::Itertools; use std::rc::Rc; -use language::TokenError; +use schala_lib::language::TokenError; #[derive(Debug, Clone, PartialEq)] pub enum Token { diff --git a/src/main.rs b/src/main.rs index dd2a392..f5f5cd3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,6 +29,7 @@ mod robo_lang; extern crate schala_lib; use schala_lib::{PLIGenerator, schala_main}; +use schala_lib::language::ProgrammingLanguageInterface; #[link_args="-ltinfo"] extern { } @@ -39,8 +40,6 @@ fn main() { Box::new(|| { let x: Box = Box::new(maaru_lang::Maaru::new()); x }), Box::new(|| { let x: Box = Box::new(robo_lang::Robo::new()); x }), ]; - schala_main(generators); } - diff --git a/src/robo_lang/mod.rs b/src/robo_lang/mod.rs index 1092155..969e714 100644 --- a/src/robo_lang/mod.rs +++ b/src/robo_lang/mod.rs @@ -1,6 +1,6 @@ use itertools::Itertools; -use language::{ProgrammingLanguageInterface, EvalOptions, ReplOutput, TokenError}; +use schala_lib::language::{ProgrammingLanguageInterface, EvalOptions, ReplOutput, TokenError}; pub struct Robo { } diff --git a/src/schala_lang/mod.rs b/src/schala_lang/mod.rs index 7dff4d1..0c61a20 100644 --- a/src/schala_lang/mod.rs +++ b/src/schala_lang/mod.rs @@ -1,5 +1,5 @@ use itertools::Itertools; -use language::{ProgrammingLanguageInterface, EvalOptions, TraceArtifact, ReplOutput}; +use schala_lib::language::{ProgrammingLanguageInterface, EvalOptions, TraceArtifact, ReplOutput}; mod parsing; mod type_check;