From 5c1b9ec00ec18b30d7e0d95356cd974a8971d23d Mon Sep 17 00:00:00 2001 From: Robert-M-Lucas Date: Wed, 19 Jun 2024 12:56:26 +0100 Subject: [PATCH] Cargo fix --- .idea/workspace.xml | 18 +++-- src/main.rs | 3 - src/root/builtin/functions/exit.rs | 4 +- src/root/builtin/functions/mod.rs | 1 - src/root/builtin/mod.rs | 2 - src/root/builtin/types/bool/printb.rs | 5 +- src/root/builtin/types/int/add.rs | 4 +- src/root/builtin/types/int/div.rs | 4 +- src/root/builtin/types/int/eq.rs | 5 +- src/root/builtin/types/int/modulo.rs | 4 +- src/root/builtin/types/int/mul.rs | 4 +- src/root/builtin/types/int/p_add.rs | 4 +- src/root/builtin/types/int/p_sub.rs | 4 +- src/root/builtin/types/int/printi.rs | 4 +- src/root/builtin/types/int/sub.rs | 4 +- src/root/compiler/assembly/utils.rs | 1 - src/root/compiler/compile_evaluable.rs | 4 +- src/root/compiler/compile_function.rs | 7 +- src/root/compiler/compile_function_call.rs | 5 +- src/root/compiler/local_variable_table.rs | 3 +- src/root/name_resolver/name_resolvers.rs | 12 +--- src/root/name_resolver/resolve_names.rs | 1 - src/root/parser/parse.rs | 2 - src/root/parser/parse_arguments.rs | 2 +- src/root/parser/parse_blocks.rs | 8 +-- src/root/parser/parse_function.rs | 3 +- .../parser/parse_function/parse_assigner.rs | 1 - .../parser/parse_function/parse_assignment.rs | 12 +--- src/root/parser/parse_function/parse_break.rs | 3 +- .../parser/parse_function/parse_evaluable.rs | 3 - src/root/parser/parse_function/parse_line.rs | 4 +- .../parser/parse_function/parse_literal.rs | 2 +- .../parser/parse_function/parse_operator.rs | 1 - src/root/parser/parse_function/parse_while.rs | 3 +- src/root/parser/parse_name_old.rs | 9 --- src/root/parser/parse_parameters.rs | 1 - src/root/parser/parse_toplevel.rs | 6 +- src/root/shared/common.rs | 2 +- src/root/shared/types.rs | 2 +- tests/.gitignore | 1 - tests/inputs/control/If.why | 21 ------ tests/inputs/print/SimplePrint.why | 7 -- tests/outputs/control/If.why | 2 - tests/outputs/print/SimplePrint.why | 4 -- tests/tests.rs | 69 ------------------- 45 files changed, 49 insertions(+), 222 deletions(-) delete mode 100644 tests/.gitignore delete mode 100644 tests/inputs/control/If.why delete mode 100644 tests/inputs/print/SimplePrint.why delete mode 100644 tests/outputs/control/If.why delete mode 100644 tests/outputs/print/SimplePrint.why delete mode 100644 tests/tests.rs diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 3be4475..f3dae5d 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -7,8 +7,9 @@ - + + @@ -213,7 +214,7 @@ - + - @@ -484,7 +493,8 @@ - diff --git a/src/main.rs b/src/main.rs index 6251fa9..4e92c5c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,3 @@ -use std::mem::MaybeUninit; -use std::hint::black_box; -use std::mem; mod root; diff --git a/src/root/builtin/functions/exit.rs b/src/root/builtin/functions/exit.rs index 4355a54..a807b35 100644 --- a/src/root/builtin/functions/exit.rs +++ b/src/root/builtin/functions/exit.rs @@ -1,11 +1,9 @@ use unique_type_id::UniqueTypeId; use crate::root::builtin::{BuiltinInlineFunction, f_id, InlineFunctionGenerator}; use crate::root::builtin::types::int::IntType; -use crate::root::errors::WErr; -use crate::root::name_resolver::name_resolvers::NameResult::Function; use crate::root::name_resolver::resolve_function_signatures::FunctionSignature; -use crate::root::shared::common::{FunctionID, Indirection, LocalAddress, TypeID, TypeRef}; +use crate::root::shared::common::{FunctionID, LocalAddress, TypeID}; #[derive(UniqueTypeId)] #[UniqueTypeIdType = "u16"] diff --git a/src/root/builtin/functions/mod.rs b/src/root/builtin/functions/mod.rs index cd3646e..ae5b9fe 100644 --- a/src/root/builtin/functions/mod.rs +++ b/src/root/builtin/functions/mod.rs @@ -1,6 +1,5 @@ mod exit; -use b_box::b; use crate::root::builtin::functions::exit::ExitFunction; use crate::root::name_resolver::name_resolvers::GlobalDefinitionTable; diff --git a/src/root/builtin/mod.rs b/src/root/builtin/mod.rs index 5ada487..06bec04 100644 --- a/src/root/builtin/mod.rs +++ b/src/root/builtin/mod.rs @@ -5,11 +5,9 @@ use crate::root::builtin::functions::register_functions; use crate::root::builtin::types::bool::register_bool; use crate::root::builtin::types::int::register_int; use crate::root::compiler::global_tracker::GlobalTracker; -use crate::root::errors::WErr; use crate::root::name_resolver::name_resolvers::{GlobalDefinitionTable}; use crate::root::name_resolver::resolve_function_signatures::FunctionSignature; use crate::root::shared::common::{ByteSize, FunctionID, LocalAddress, TypeID}; -use crate::root::shared::types::Type; pub fn register_builtin(global_table: &mut GlobalDefinitionTable) { register_functions(global_table); diff --git a/src/root/builtin/types/bool/printb.rs b/src/root/builtin/types/bool/printb.rs index ccbebcc..9d5e30c 100644 --- a/src/root/builtin/types/bool/printb.rs +++ b/src/root/builtin/types/bool/printb.rs @@ -1,12 +1,9 @@ use unique_type_id::UniqueTypeId; use crate::root::builtin::{BuiltinInlineFunction, f_id, InlineFunctionGenerator}; use crate::root::builtin::types::bool::BoolType; -use crate::root::builtin::types::int::IntType; -use crate::root::errors::WErr; -use crate::root::name_resolver::name_resolvers::NameResult::Function; use crate::root::name_resolver::resolve_function_signatures::FunctionSignature; -use crate::root::shared::common::{FunctionID, Indirection, LocalAddress, TypeID, TypeRef}; +use crate::root::shared::common::{FunctionID, LocalAddress, TypeID}; #[derive(UniqueTypeId)] #[UniqueTypeIdType = "u16"] diff --git a/src/root/builtin/types/int/add.rs b/src/root/builtin/types/int/add.rs index a00bde2..619f548 100644 --- a/src/root/builtin/types/int/add.rs +++ b/src/root/builtin/types/int/add.rs @@ -1,11 +1,9 @@ use unique_type_id::UniqueTypeId; use crate::root::builtin::{BuiltinInlineFunction, InlineFunctionGenerator, f_id}; use crate::root::builtin::types::int::IntType; -use crate::root::errors::WErr; -use crate::root::name_resolver::name_resolvers::NameResult::Function; use crate::root::name_resolver::resolve_function_signatures::FunctionSignature; -use crate::root::shared::common::{FunctionID, Indirection, LocalAddress, TypeID, TypeRef}; +use crate::root::shared::common::{FunctionID, LocalAddress, TypeID}; #[derive(UniqueTypeId)] #[UniqueTypeIdType = "u16"] diff --git a/src/root/builtin/types/int/div.rs b/src/root/builtin/types/int/div.rs index e353d7f..13d8c23 100644 --- a/src/root/builtin/types/int/div.rs +++ b/src/root/builtin/types/int/div.rs @@ -1,11 +1,9 @@ use unique_type_id::UniqueTypeId; use crate::root::builtin::{BuiltinInlineFunction, InlineFunctionGenerator, f_id}; use crate::root::builtin::types::int::IntType; -use crate::root::errors::WErr; -use crate::root::name_resolver::name_resolvers::NameResult::Function; use crate::root::name_resolver::resolve_function_signatures::FunctionSignature; -use crate::root::shared::common::{FunctionID, Indirection, LocalAddress, TypeID, TypeRef}; +use crate::root::shared::common::{FunctionID, LocalAddress, TypeID}; #[derive(UniqueTypeId)] #[UniqueTypeIdType = "u16"] diff --git a/src/root/builtin/types/int/eq.rs b/src/root/builtin/types/int/eq.rs index b1c5573..d9d835e 100644 --- a/src/root/builtin/types/int/eq.rs +++ b/src/root/builtin/types/int/eq.rs @@ -2,12 +2,9 @@ use unique_type_id::UniqueTypeId; use crate::root::builtin::{BuiltinInlineFunction, InlineFunctionGenerator, f_id}; use crate::root::builtin::types::bool::BoolType; use crate::root::builtin::types::int::IntType; -use crate::root::builtin::types::int::printi::PrintI; -use crate::root::errors::WErr; -use crate::root::name_resolver::name_resolvers::NameResult::Function; use crate::root::name_resolver::resolve_function_signatures::FunctionSignature; -use crate::root::shared::common::{FunctionID, Indirection, LocalAddress, TypeID, TypeRef}; +use crate::root::shared::common::{FunctionID, LocalAddress, TypeID}; #[derive(UniqueTypeId)] #[UniqueTypeIdType = "u16"] diff --git a/src/root/builtin/types/int/modulo.rs b/src/root/builtin/types/int/modulo.rs index 75fd3ed..fef58ea 100644 --- a/src/root/builtin/types/int/modulo.rs +++ b/src/root/builtin/types/int/modulo.rs @@ -1,11 +1,9 @@ use unique_type_id::UniqueTypeId; use crate::root::builtin::{BuiltinInlineFunction, InlineFunctionGenerator, f_id}; use crate::root::builtin::types::int::IntType; -use crate::root::errors::WErr; -use crate::root::name_resolver::name_resolvers::NameResult::Function; use crate::root::name_resolver::resolve_function_signatures::FunctionSignature; -use crate::root::shared::common::{FunctionID, Indirection, LocalAddress, TypeID, TypeRef}; +use crate::root::shared::common::{FunctionID, LocalAddress, TypeID}; #[derive(UniqueTypeId)] #[UniqueTypeIdType = "u16"] diff --git a/src/root/builtin/types/int/mul.rs b/src/root/builtin/types/int/mul.rs index 4808bd7..5036695 100644 --- a/src/root/builtin/types/int/mul.rs +++ b/src/root/builtin/types/int/mul.rs @@ -1,11 +1,9 @@ use unique_type_id::UniqueTypeId; use crate::root::builtin::{BuiltinInlineFunction, InlineFunctionGenerator, f_id}; use crate::root::builtin::types::int::IntType; -use crate::root::errors::WErr; -use crate::root::name_resolver::name_resolvers::NameResult::Function; use crate::root::name_resolver::resolve_function_signatures::FunctionSignature; -use crate::root::shared::common::{FunctionID, Indirection, LocalAddress, TypeID, TypeRef}; +use crate::root::shared::common::{FunctionID, LocalAddress, TypeID}; #[derive(UniqueTypeId)] #[UniqueTypeIdType = "u16"] diff --git a/src/root/builtin/types/int/p_add.rs b/src/root/builtin/types/int/p_add.rs index f116368..4dcd3ca 100644 --- a/src/root/builtin/types/int/p_add.rs +++ b/src/root/builtin/types/int/p_add.rs @@ -1,11 +1,9 @@ use unique_type_id::UniqueTypeId; use crate::root::builtin::{BuiltinInlineFunction, f_id, InlineFunctionGenerator}; use crate::root::builtin::types::int::IntType; -use crate::root::errors::WErr; -use crate::root::name_resolver::name_resolvers::NameResult::Function; use crate::root::name_resolver::resolve_function_signatures::FunctionSignature; -use crate::root::shared::common::{FunctionID, Indirection, LocalAddress, TypeID, TypeRef}; +use crate::root::shared::common::{FunctionID, LocalAddress, TypeID}; #[derive(UniqueTypeId)] #[UniqueTypeIdType = "u16"] diff --git a/src/root/builtin/types/int/p_sub.rs b/src/root/builtin/types/int/p_sub.rs index 8682c05..5f388f3 100644 --- a/src/root/builtin/types/int/p_sub.rs +++ b/src/root/builtin/types/int/p_sub.rs @@ -1,11 +1,9 @@ use unique_type_id::UniqueTypeId; use crate::root::builtin::{BuiltinInlineFunction, f_id, InlineFunctionGenerator}; use crate::root::builtin::types::int::IntType; -use crate::root::errors::WErr; -use crate::root::name_resolver::name_resolvers::NameResult::Function; use crate::root::name_resolver::resolve_function_signatures::FunctionSignature; -use crate::root::shared::common::{FunctionID, Indirection, LocalAddress, TypeID, TypeRef}; +use crate::root::shared::common::{FunctionID, LocalAddress, TypeID}; #[derive(UniqueTypeId)] #[UniqueTypeIdType = "u16"] diff --git a/src/root/builtin/types/int/printi.rs b/src/root/builtin/types/int/printi.rs index 6c87709..fd1b349 100644 --- a/src/root/builtin/types/int/printi.rs +++ b/src/root/builtin/types/int/printi.rs @@ -1,11 +1,9 @@ use unique_type_id::UniqueTypeId; use crate::root::builtin::{BuiltinInlineFunction, f_id, InlineFunctionGenerator}; use crate::root::builtin::types::int::IntType; -use crate::root::errors::WErr; -use crate::root::name_resolver::name_resolvers::NameResult::Function; use crate::root::name_resolver::resolve_function_signatures::FunctionSignature; -use crate::root::shared::common::{FunctionID, Indirection, LocalAddress, TypeID, TypeRef}; +use crate::root::shared::common::{FunctionID, LocalAddress, TypeID}; #[derive(UniqueTypeId)] #[UniqueTypeIdType = "u16"] diff --git a/src/root/builtin/types/int/sub.rs b/src/root/builtin/types/int/sub.rs index 9634cfa..4acebaf 100644 --- a/src/root/builtin/types/int/sub.rs +++ b/src/root/builtin/types/int/sub.rs @@ -1,11 +1,9 @@ use unique_type_id::UniqueTypeId; use crate::root::builtin::{BuiltinInlineFunction, InlineFunctionGenerator, f_id}; use crate::root::builtin::types::int::IntType; -use crate::root::errors::WErr; -use crate::root::name_resolver::name_resolvers::NameResult::Function; use crate::root::name_resolver::resolve_function_signatures::FunctionSignature; -use crate::root::shared::common::{FunctionID, Indirection, LocalAddress, TypeID, TypeRef}; +use crate::root::shared::common::{FunctionID, LocalAddress, TypeID}; #[derive(UniqueTypeId)] #[UniqueTypeIdType = "u16"] diff --git a/src/root/compiler/assembly/utils.rs b/src/root/compiler/assembly/utils.rs index f75a17f..eecd4f3 100644 --- a/src/root/compiler/assembly/utils.rs +++ b/src/root/compiler/assembly/utils.rs @@ -1,4 +1,3 @@ -use std::fmt::format; use crate::root::assembler::assembly_builder::AssemblyBuilder; use crate::root::shared::common::{ByteSize, FunctionID, LocalAddress}; diff --git a/src/root/compiler/compile_evaluable.rs b/src/root/compiler/compile_evaluable.rs index e677290..f5bc3da 100644 --- a/src/root/compiler/compile_evaluable.rs +++ b/src/root/compiler/compile_evaluable.rs @@ -1,8 +1,6 @@ use std::any::Any; -use std::collections::HashSet; use either::{Left, Right}; use itertools::Itertools; -use crate::root::assembler::assembly_builder::AssemblyBuilder; use crate::root::compiler::assembly::utils::copy; use crate::root::compiler::compile_function_call::call_function; use crate::root::compiler::global_tracker::GlobalTracker; @@ -14,7 +12,7 @@ use crate::root::errors::WErr; use crate::root::name_resolver::name_resolvers::{GlobalDefinitionTable, NameResult}; use crate::root::parser::parse_function::parse_evaluable::{EvaluableToken, EvaluableTokens}; use crate::root::parser::parse_function::parse_operator::{OperatorTokens, PrefixOrInfixEx}; -use crate::root::shared::common::{FunctionID, Indirection, LocalAddress, TypeRef}; +use crate::root::shared::common::{FunctionID, Indirection, TypeRef}; use crate::root::shared::common::AddressedTypeRef; fn expect_addr(r: (String, Option)) -> Result<(String, AddressedTypeRef), WErr> { diff --git a/src/root/compiler/compile_function.rs b/src/root/compiler/compile_function.rs index 0a107a2..9da6566 100644 --- a/src/root/compiler/compile_function.rs +++ b/src/root/compiler/compile_function.rs @@ -1,10 +1,7 @@ -use std::collections::HashSet; -use std::fmt::format; use crate::root::assembler::assembly_builder::AssemblyBuilder; use crate::root::builtin::types::bool::BoolType; use crate::root::builtin::types::int::IntType; -use crate::root::compiler::assembly::utils::{align_16_bytes, align_16_bytes_plus_8}; -use crate::root::compiler::compile_evaluable::{compile_evaluable, compile_evaluable_into, compile_evaluable_reference}; +use crate::root::compiler::compile_evaluable::{compile_evaluable_into, compile_evaluable_reference}; use crate::root::compiler::global_tracker::GlobalTracker; use crate::root::compiler::local_variable_table::LocalVariableTable; use crate::root::errors::WErr; @@ -50,7 +47,7 @@ pub fn compile_function(fid: FunctionID, function: FunctionToken, global_table: // let stack_size = local_variables.stack_size(); - let mut final_contents = format!( + let final_contents = format!( "{}: push rbp mov rbp, rsp diff --git a/src/root/compiler/compile_function_call.rs b/src/root/compiler/compile_function_call.rs index fd1887e..8977030 100644 --- a/src/root/compiler/compile_function_call.rs +++ b/src/root/compiler/compile_function_call.rs @@ -1,15 +1,14 @@ -use std::collections::HashSet; use either::Either; use itertools::Itertools; use crate::root::assembler::assembly_builder::AssemblyBuilder; use crate::root::compiler::assembly::utils::{align_16_bytes, align_16_bytes_plus_8, copy}; -use crate::root::compiler::compile_evaluable::{compile_evaluable, compile_evaluable_into}; +use crate::root::compiler::compile_evaluable::compile_evaluable_into; use crate::root::compiler::global_tracker::GlobalTracker; use crate::root::compiler::local_variable_table::LocalVariableTable; use crate::root::errors::WErr; use crate::root::name_resolver::name_resolvers::GlobalDefinitionTable; use crate::root::parser::parse_function::parse_evaluable::EvaluableToken; -use crate::root::shared::common::{AddressedTypeRef, ByteSize, FunctionID, LocalAddress, TypeRef}; +use crate::root::shared::common::{AddressedTypeRef, ByteSize, FunctionID}; use crate::root::utils::warn; diff --git a/src/root/compiler/local_variable_table.rs b/src/root/compiler/local_variable_table.rs index 6e826fb..f1db00a 100644 --- a/src/root/compiler/local_variable_table.rs +++ b/src/root/compiler/local_variable_table.rs @@ -1,6 +1,5 @@ use std::collections::HashMap; -use crate::root::shared::common::{AddressedTypeRef, ByteSize, LocalAddress, TypeID, TypeRef}; -use crate::root::shared::types::Type; +use crate::root::shared::common::{AddressedTypeRef, ByteSize, LocalAddress}; /// Function-local table of defined variables. Only used within function processing pub struct LocalVariableTable { diff --git a/src/root/name_resolver/name_resolvers.rs b/src/root/name_resolver/name_resolvers.rs index ccef90c..6c675b7 100644 --- a/src/root/name_resolver/name_resolvers.rs +++ b/src/root/name_resolver/name_resolvers.rs @@ -1,29 +1,21 @@ -use std::borrow::Cow; -use std::collections::hash_map::{Iter, IterMut}; use std::collections::HashMap; use std::path::PathBuf; use std::rc::Rc; -use derive_getters::Getters; -use either::{Either, Left, Right}; use crate::root::builtin::{BuiltinInlineFunction, InlineFunctionGenerator}; -use crate::root::compiler::compile_function_call::call_function; -use crate::root::compiler::global_tracker::GlobalTracker; use crate::root::compiler::local_variable_table::LocalVariableTable; use crate::root::errors::name_resolver_errors::NRErrors; -use crate::root::errors::name_resolver_errors::NRErrors::IdentifierNotFound; use crate::root::errors::WErr; -use crate::root::name_resolver::name_resolvers::NameResult::Function; use crate::root::name_resolver::resolve_function_signatures::FunctionSignature; use crate::root::ob::OB; use crate::root::parser::parse::Location; use crate::root::shared::types::Type; use crate::root::parser::parse_function::FunctionToken; use crate::root::parser::parse_function::parse_evaluable::{FullNameToken, FullNameTokens, FullNameWithIndirectionToken}; -use crate::root::parser::parse_function::parse_operator::{OperatorToken, OperatorTokens, PrefixOrInfixEx}; +use crate::root::parser::parse_function::parse_operator::{OperatorToken, PrefixOrInfixEx}; use crate::root::parser::parse_name::SimpleNameToken; use crate::root::parser::parse_struct::StructToken; use crate::root::POINTER_SIZE; -use crate::root::shared::common::{AddressedTypeRef, ByteSize, FunctionID, Indirection, LocalAddress, TypeID, TypeRef}; +use crate::root::shared::common::{AddressedTypeRef, ByteSize, FunctionID, TypeID, TypeRef}; #[derive(Debug)] enum NameTreeEntry { diff --git a/src/root/name_resolver/resolve_names.rs b/src/root/name_resolver/resolve_names.rs index 9f4d8ef..5d17175 100644 --- a/src/root/name_resolver/resolve_names.rs +++ b/src/root/name_resolver/resolve_names.rs @@ -2,7 +2,6 @@ use std::any::Any; use std::collections::HashMap; use derive_getters::Getters; -use itertools::Itertools; use crate::root::errors::name_resolver_errors::NRErrors; use crate::root::errors::WErr; diff --git a/src/root/parser/parse.rs b/src/root/parser/parse.rs index 6535d2e..2fc14b9 100644 --- a/src/root/parser/parse.rs +++ b/src/root/parser/parse.rs @@ -9,9 +9,7 @@ use std::fs; use std::path::PathBuf; use std::rc::Rc; use color_print::cformat; -use derive_getters::Getters; use lazy_static::lazy_static; -use nom_supreme::final_parser::ExtractContext; use crate::root::errors::parser_errors::ParseError; use crate::root::errors::WErr; use crate::root::parser::parse_toplevel::TopLevelTokens; diff --git a/src/root/parser/parse_arguments.rs b/src/root/parser/parse_arguments.rs index a2699c9..de2b6ad 100644 --- a/src/root/parser/parse_arguments.rs +++ b/src/root/parser/parse_arguments.rs @@ -1,4 +1,4 @@ -use nom::bytes::complete::{take_until, take_until1}; +use nom::bytes::complete::take_until; use nom::InputTake; use crate::root::parser::parse::{ErrorTree, ParseResult, Span}; use crate::root::parser::parse_function::parse_evaluable::{EvaluableToken, parse_evaluable}; diff --git a/src/root/parser/parse_blocks.rs b/src/root/parser/parse_blocks.rs index 0795129..028e32d 100644 --- a/src/root/parser/parse_blocks.rs +++ b/src/root/parser/parse_blocks.rs @@ -1,13 +1,9 @@ -use std::collections::HashMap; use itertools::Itertools; use crate::root::parser::parse::{ErrorTree, ParseResult, Span}; -use nom::bytes::complete::take_until; use nom::character::complete::{anychar, char as nchar}; use nom::Err::Error; -use nom::error::{ErrorKind, ParseError}; -use nom::{InputIter, InputTake, Offset}; -use nom::sequence::Tuple; -use nom_supreme::tag::complete::tag; +use nom::error::ParseError; +use nom::{InputTake, Offset}; use crate::root::parser::parse_util::discard_ignored; // ! BROKEN diff --git a/src/root/parser/parse_function.rs b/src/root/parser/parse_function.rs index 61e747b..7c64a64 100644 --- a/src/root/parser/parse_function.rs +++ b/src/root/parser/parse_function.rs @@ -1,8 +1,7 @@ use derive_getters::{Dissolve, Getters}; use nom::sequence::Tuple; -use nom::{Offset, Parser}; +use nom::Parser; use nom_supreme::tag::complete::tag; -use substring::Substring; use crate::root::parser::parse::{ErrorTree, Location, ParseResult, Span}; use crate::root::parser::parse_blocks::default_section; use crate::root::parser::parse_function::parse_evaluable::{FullNameWithIndirectionToken, parse_full_name}; diff --git a/src/root/parser/parse_function/parse_assigner.rs b/src/root/parser/parse_function/parse_assigner.rs index 4a13847..301287c 100644 --- a/src/root/parser/parse_function/parse_assigner.rs +++ b/src/root/parser/parse_function/parse_assigner.rs @@ -2,7 +2,6 @@ use crate::root::parser::parse::{Location, ParseResult, Span}; use crate::root::parser::parse_function::parse_operator::OperatorTokens; use crate::root::parser::parse_util::alt_many; use clap::builder::TypedValueParser; -use nom::branch::alt; use nom::bytes::complete::tag; use nom::Parser; diff --git a/src/root/parser/parse_function/parse_assignment.rs b/src/root/parser/parse_function/parse_assignment.rs index 4884a28..5c21b7d 100644 --- a/src/root/parser/parse_function/parse_assignment.rs +++ b/src/root/parser/parse_function/parse_assignment.rs @@ -1,13 +1,7 @@ use derive_getters::Getters; -use nom::sequence::Tuple; -use nom_supreme::tag::complete::tag; -use crate::root::parser::parse::{Location, ParseResult, Span}; -use crate::root::parser::parse_function::parse_assigner::{AssignmentOperatorToken, parse_assigner}; -use crate::root::parser::parse_function::parse_evaluable::{EvaluableToken, FullNameWithIndirectionToken, parse_evaluable, parse_full_name}; -use crate::root::parser::parse_function::parse_initialisation::parse_initialisation; -use crate::root::parser::parse_function::parse_line::{LineTestFn, LineTokens}; -use crate::root::parser::parse_name::SimpleNameToken; -use crate::root::parser::parse_util::discard_ignored; +use crate::root::parser::parse::Location; +use crate::root::parser::parse_function::parse_assigner::AssignmentOperatorToken; +use crate::root::parser::parse_function::parse_evaluable::{EvaluableToken, FullNameWithIndirectionToken}; #[derive(Debug, Getters)] pub struct AssignmentToken { diff --git a/src/root/parser/parse_function/parse_break.rs b/src/root/parser/parse_function/parse_break.rs index be22dd0..3f9e393 100644 --- a/src/root/parser/parse_function/parse_break.rs +++ b/src/root/parser/parse_function/parse_break.rs @@ -1,11 +1,10 @@ use nom::character::complete::{char}; -use nom::sequence::Tuple; use nom::Parser; use nom_supreme::tag::complete::tag; use crate::root::parser::parse::{Location, ParseResult, Span}; use crate::root::parser::parse_function::parse_line::{LineTestFn, LineTokens}; -use crate::root::parser::parse_util::{discard_ignored, require_ignored}; +use crate::root::parser::parse_util::discard_ignored; #[derive(Debug)] pub struct BreakToken { diff --git a/src/root/parser/parse_function/parse_evaluable.rs b/src/root/parser/parse_function/parse_evaluable.rs index 214485d..2f5b964 100644 --- a/src/root/parser/parse_function/parse_evaluable.rs +++ b/src/root/parser/parse_function/parse_evaluable.rs @@ -1,4 +1,3 @@ -use nom::Err; use crate::root::parser::parse::{ErrorTree, Location, ParseResult, Span}; use crate::root::parser::parse_function::parse_literal::{ LiteralToken, parse_literal, @@ -6,14 +5,12 @@ use crate::root::parser::parse_function::parse_literal::{ use crate::root::parser::parse_function::parse_operator::{OperatorToken, parse_operator}; use b_box::b; use derive_getters::Getters; -use either::{Either, Left, Right}; use nom::branch::alt; use nom::bytes::complete::tag; use nom::character::complete::char; use crate::root::parser::parse_arguments::parse_arguments; use crate::root::parser::parse_name::{SimpleNameToken, parse_simple_name}; use crate::root::parser::parse_blocks::default_section; -use crate::root::parser::parse_function::parse_assignment::AssignmentToken; use crate::root::parser::parse_util::discard_ignored; use crate::root::shared::common::Indirection; diff --git a/src/root/parser/parse_function/parse_line.rs b/src/root/parser/parse_function/parse_line.rs index c315989..c1d1e41 100644 --- a/src/root/parser/parse_function/parse_line.rs +++ b/src/root/parser/parse_function/parse_line.rs @@ -1,6 +1,4 @@ -use itertools::Itertools; -use crate::root::parser::parse::{ErrorTree, ParseResult, Span}; -use crate::root::parser::parse_function::parse_assignment::{AssignmentToken}; +use crate::root::parser::parse::{ParseResult, Span}; use crate::root::parser::parse_function::parse_break::{test_parse_break, BreakToken}; use crate::root::parser::parse_function::parse_evaluable::{parse_evaluable, EvaluableToken}; use crate::root::parser::parse_function::parse_if::{test_parse_if, IfToken}; diff --git a/src/root/parser/parse_function/parse_literal.rs b/src/root/parser/parse_function/parse_literal.rs index a50665b..bf00076 100644 --- a/src/root/parser/parse_function/parse_literal.rs +++ b/src/root/parser/parse_function/parse_literal.rs @@ -4,7 +4,7 @@ use nom::branch::alt; use nom::bytes::complete::tag; use crate::root::builtin::types::int::IntType; use crate::root::parser::parse_util::discard_ignored; -use crate::root::shared::common::{Indirection, TypeID, TypeRef}; +use crate::root::shared::common::TypeID; use crate::root::shared::types::Type; #[derive(Debug, Dissolve, Getters)] diff --git a/src/root/parser/parse_function/parse_operator.rs b/src/root/parser/parse_function/parse_operator.rs index af56a1d..e4c346a 100644 --- a/src/root/parser/parse_function/parse_operator.rs +++ b/src/root/parser/parse_function/parse_operator.rs @@ -1,6 +1,5 @@ use crate::root::parser::parse::{ErrorTree, Location, ParseResult, Span}; use derive_getters::Getters; -use nom::error::{ErrorKind, ParseError}; use nom::Err::Error; use nom::Parser; use nom_supreme::error::GenericErrorTree; diff --git a/src/root/parser/parse_function/parse_while.rs b/src/root/parser/parse_function/parse_while.rs index 12a3fc1..7c89269 100644 --- a/src/root/parser/parse_function/parse_while.rs +++ b/src/root/parser/parse_function/parse_while.rs @@ -1,10 +1,9 @@ use derive_getters::Getters; -use nom::character::complete::{satisfy}; use nom::sequence::Tuple; use nom::Parser; use nom_supreme::tag::complete::tag; -use crate::root::parser::parse::{ErrorTree, Location, ParseResult, Span}; +use crate::root::parser::parse::{Location, ParseResult, Span}; use crate::root::parser::parse_blocks::default_section; use crate::root::parser::parse_function::parse_evaluable::{parse_evaluable, EvaluableToken,}; use crate::root::parser::parse_function::parse_line::{parse_lines, LineTestFn, LineTokens}; diff --git a/src/root/parser/parse_name_old.rs b/src/root/parser/parse_name_old.rs index 7fe73ea..1f7bde3 100644 --- a/src/root/parser/parse_name_old.rs +++ b/src/root/parser/parse_name_old.rs @@ -1,12 +1,3 @@ -use crate::root::parser::parse::{Location, ParseResult, Span}; -use crate::root::parser::parse_function::parse_evaluable::EvaluableToken; -use derive_getters::{Dissolve, Getters}; -use nom::InputTake; -use crate::root::parser::parse_arguments::parse_arguments; -use crate::root::parser::parse_blocks::default_section; -use crate::root::parser::parse_name; -use crate::root::parser::parse_util::discard_ignored; -use crate::root::shared::common::Indirection; // #[derive(Debug)] // pub enum NameConnectors { diff --git a/src/root/parser/parse_parameters.rs b/src/root/parser/parse_parameters.rs index a4799dc..6d66729 100644 --- a/src/root/parser/parse_parameters.rs +++ b/src/root/parser/parse_parameters.rs @@ -1,6 +1,5 @@ use crate::root::parser::parse::{Location, ParseResult, Span}; use nom::character::complete::char; -use crate::root::name_resolver::name_resolvers::NameResult; use crate::root::parser::parse_function::parse_evaluable::{FullNameWithIndirectionToken, parse_full_name}; use crate::root::parser::parse_name::{parse_simple_name, SimpleNameToken}; use crate::root::parser::parse_util::discard_ignored; diff --git a/src/root/parser/parse_toplevel.rs b/src/root/parser/parse_toplevel.rs index 923ed25..2481742 100644 --- a/src/root/parser/parse_toplevel.rs +++ b/src/root/parser/parse_toplevel.rs @@ -1,7 +1,7 @@ use crate::root::parser::parse::{ParseResult, Span}; -use crate::root::parser::parse_function::{parse_function, test_parse_function, FunctionToken}; -use crate::root::parser::parse_impl::{parse_impl, test_parse_impl, ImplToken}; -use crate::root::parser::parse_struct::{parse_struct, test_parse_struct, StructToken}; +use crate::root::parser::parse_function::{test_parse_function, FunctionToken}; +use crate::root::parser::parse_impl::{test_parse_impl, ImplToken}; +use crate::root::parser::parse_struct::{test_parse_struct, StructToken}; use nom::branch::alt; use nom::Parser; use crate::root::parser::parse_util::discard_ignored; diff --git a/src/root/shared/common.rs b/src/root/shared/common.rs index 7f296cb..943751e 100644 --- a/src/root/shared/common.rs +++ b/src/root/shared/common.rs @@ -1,4 +1,4 @@ -use std::fmt::{Display, Formatter, write}; +use std::fmt::{Display, Formatter}; use derive_more::{Add, AddAssign, Display, Sub, SubAssign}; use derive_getters::{Dissolve, Getters}; diff --git a/src/root/shared/types.rs b/src/root/shared/types.rs index 3f113e1..bf98d1c 100644 --- a/src/root/shared/types.rs +++ b/src/root/shared/types.rs @@ -1,6 +1,6 @@ use crate::root::errors::WErr; use crate::root::parser::parse_function::parse_literal::LiteralToken; -use crate::root::shared::common::{AddressedTypeRef, ByteSize, FunctionID, LocalAddress, TypeID}; +use crate::root::shared::common::{ByteSize, LocalAddress, TypeID}; pub trait Type { fn id(&self) -> TypeID; diff --git a/tests/.gitignore b/tests/.gitignore deleted file mode 100644 index 3602361..0000000 --- a/tests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -temp \ No newline at end of file diff --git a/tests/inputs/control/If.why b/tests/inputs/control/If.why deleted file mode 100644 index ae3e653..0000000 --- a/tests/inputs/control/If.why +++ /dev/null @@ -1,21 +0,0 @@ -fn main() ~ int { - let a: bool = true; - - if (a) { - printi(7); - } - else { - printi(9); - }; - - let b: bool = false; - - if (b) { - printi(7); - } - else { - printi(9); - }; - - return 0; -} \ No newline at end of file diff --git a/tests/inputs/print/SimplePrint.why b/tests/inputs/print/SimplePrint.why deleted file mode 100644 index 996fe13..0000000 --- a/tests/inputs/print/SimplePrint.why +++ /dev/null @@ -1,7 +0,0 @@ -fn main() ~ int { - printi(121); - printi(-1121); - printb(true); - printb(false); - return 0; -} \ No newline at end of file diff --git a/tests/outputs/control/If.why b/tests/outputs/control/If.why deleted file mode 100644 index 78bd770..0000000 --- a/tests/outputs/control/If.why +++ /dev/null @@ -1,2 +0,0 @@ -7 -9 \ No newline at end of file diff --git a/tests/outputs/print/SimplePrint.why b/tests/outputs/print/SimplePrint.why deleted file mode 100644 index b967b12..0000000 --- a/tests/outputs/print/SimplePrint.why +++ /dev/null @@ -1,4 +0,0 @@ -121 --1121 -true -false \ No newline at end of file diff --git a/tests/tests.rs b/tests/tests.rs deleted file mode 100644 index dfae54b..0000000 --- a/tests/tests.rs +++ /dev/null @@ -1,69 +0,0 @@ -use std::fs; -use std::path::PathBuf; -use std::process::Command; -use whython_7::root::main_args; -use whython_7::root::Args; - -#[test] -fn tests() { - fs::create_dir_all("tests/temp").unwrap(); - - for entry in get_files(PathBuf::from("tests/inputs")) { - let in_path = PathBuf::from("tests/inputs").join(entry.clone()); - - let out_path = PathBuf::from("tests/outputs").join(entry); - - compare( - in_path.into_os_string().into_string().unwrap(), - out_path.into_os_string().into_string().unwrap(), - ); - } -} - -fn get_files(base_dir: PathBuf) -> Vec { - let mut out = Vec::new(); - walk_dir(&base_dir, PathBuf::new(), &mut out); - out -} - -fn walk_dir(base_dir: &PathBuf, prefix: PathBuf, out: &mut Vec) { - for entry in base_dir.join(prefix.clone()).read_dir().unwrap() { - let entry = entry.unwrap(); - let path = entry.path(); - let emit = prefix.clone().join(path.file_name().unwrap()); - if path.is_dir() { - walk_dir(base_dir, emit, out); - continue; - } - - out.push(emit); - } -} - -fn compare(in_path: String, out_path: String) { - println!("Testing `{}`", in_path); - - assert!(main_args(Args { - input: in_path, - output: String::from("tests/temp/out"), - build: true - }) - .is_ok()); - - let result = Command::new("tests/temp/out.exe").output().unwrap(); - - assert!(result.status.success()); - - let result = String::from_utf8(result.stdout) - .unwrap() - .replace('\0', "") - .replace("\r\n", "\n"); - - assert_eq!( - result.trim(), - fs::read_to_string(out_path) - .unwrap() - .replace("\r\n", "\n") - .trim() - ); -}