diff --git a/book.toml b/book.toml index 10f246c..e6b925f 100644 --- a/book.toml +++ b/book.toml @@ -9,7 +9,7 @@ src = "docs" additional-css = ["ok.css"] theme = "docs/theme" default-theme = "dark" -git-repository-url = "https://github.com/oknotokcomputer/roar" +git-repository-url = "https://ok.software/ok/src" preferred-dark-theme = "rust" [preprocessor.svgbob] diff --git a/build.rs b/build.rs index 655367e..bfa9546 100644 --- a/build.rs +++ b/build.rs @@ -1,7 +1,7 @@ use core::panic; use std::fmt::Write as _; use std::fs::File; -use std::io::{BufRead, BufReader, BufWriter, Write}; +use std::io::{BufRead, BufReader, Write}; use std::path::PathBuf; use tiny_keccak::{Hasher, Sha3}; @@ -77,7 +77,7 @@ fn try_lalrpop(source: &str, target: &str) -> anyhow::Result<()> { let full_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(SOURCE); let path = full_path.to_str().unwrap(); println!("cargo:rerun-if-changed={}", path); - let p = lalrpop::Configuration::new() + lalrpop::Configuration::new() .generate_in_source_tree() .process_file(path).expect("msg"); Ok(()) diff --git a/src/compiler/db.rs b/src/compiler/db.rs index d5ccc76..f3465e5 100644 --- a/src/compiler/db.rs +++ b/src/compiler/db.rs @@ -2,12 +2,9 @@ use std::sync::{Arc, Mutex}; use salsa::DebugWithDb; -use crate::{ - lexer::{self, Lexer, Token}, - Db, -}; -use super::text::SourceProgram; + + #[derive(Default)] #[salsa::db(crate::Jar)] diff --git a/src/compiler/errors.rs b/src/compiler/errors.rs index ae3924a..460ccb3 100644 --- a/src/compiler/errors.rs +++ b/src/compiler/errors.rs @@ -1,8 +1,8 @@ use std::ops::Range; -use crate::Db; -use super::text::SourceProgram; + + pub struct Errors<'a>(Vec, &'a str>>); @@ -27,12 +27,12 @@ impl<'a> IntoIterator for Errors<'a> { .into_iter() .map(|error| match error.error { lalrpop_util::ParseError::InvalidToken { location } => location..location, - lalrpop_util::ParseError::UnrecognizedEof { location, expected } => { + lalrpop_util::ParseError::UnrecognizedEof { location, expected: _ } => { location..location } - lalrpop_util::ParseError::UnrecognizedToken { token, expected } => token.0..token.2, + lalrpop_util::ParseError::UnrecognizedToken { token, expected: _ } => token.0..token.2, lalrpop_util::ParseError::ExtraToken { token } => token.0..token.2, - lalrpop_util::ParseError::User { error } => todo!(), + lalrpop_util::ParseError::User { error: _ } => todo!(), }) .collect::>() .into_iter() @@ -46,8 +46,8 @@ fn handle_errors(errors: Vec todo!(), - lalrpop_util::ParseError::UnrecognizedEof { location, expected } => todo!(), + lalrpop_util::ParseError::InvalidToken { location: _ } => todo!(), + lalrpop_util::ParseError::UnrecognizedEof { location: _, expected: _ } => todo!(), lalrpop_util::ParseError::UnrecognizedToken { token, expected } => { // find the line and column of the start and end tokens, // and print the line with a caret pointing to the error @@ -66,8 +66,8 @@ fn handle_errors(errors: Vec todo!(), - lalrpop_util::ParseError::User { error } => todo!(), + lalrpop_util::ParseError::ExtraToken { token: _ } => todo!(), + lalrpop_util::ParseError::User { error: _ } => todo!(), }; } diff --git a/src/compiler/ir.rs b/src/compiler/ir.rs index 85e3876..ff38d3d 100644 --- a/src/compiler/ir.rs +++ b/src/compiler/ir.rs @@ -1,11 +1,8 @@ #![allow(clippy::needless_borrow)] -use salsa::*; + use std::{ - array::IntoIter, collections::BTreeMap, - path::Iter, - sync::{Arc, Mutex}, }; use crate::{parser::ast}; diff --git a/src/compiler/mod.rs b/src/compiler/mod.rs index 8b8df02..96ad53c 100644 --- a/src/compiler/mod.rs +++ b/src/compiler/mod.rs @@ -1,11 +1,10 @@ use std::{ collections::BTreeMap, - ops::{Range, RangeBounds}, }; use crate::{ - compiler::{errors::Errors, text::{Position, Span, Spanned}}, - parser::ast::{self, EffectDef, Module}, + compiler::{errors::Errors}, + parser::ast::{self}, Db, }; @@ -25,7 +24,7 @@ pub fn compile(db: &dyn Db, src: SourceProgram) -> ir::Program { let t = crate::parser::src::SourceParser::new().parse(&mut errors, wrapper); // let mut errors_in_positions: Vec = vec![]; if !errors.is_empty() { - for error_range in Into::::into(errors) { + for _error_range in Into::::into(errors) { text::to_spans(db, src); } panic!(); @@ -66,7 +65,7 @@ pub fn compile(db: &dyn Db, src: SourceProgram) -> ir::Program { } #[salsa::tracked] -pub fn compile_effect(db: &dyn Db, effect: ir::EffectDef) {} +pub fn compile_effect(_db: &dyn Db, _effect: ir::EffectDef) {} #[salsa::tracked] pub fn add_imports(db: &dyn Db, import: ir::Import) -> Vec { diff --git a/src/compiler/text.rs b/src/compiler/text.rs index 99a3dc1..f1e859d 100644 --- a/src/compiler/text.rs +++ b/src/compiler/text.rs @@ -106,7 +106,7 @@ pub fn to_spans(db: &dyn Db, src: SourceProgram) -> SourceMap { // Lexer tokens have a start and end position, and we want to map these to the line lengths // first we iterate over the lexer tokens for token in lexer { - let size = token.end - token.start; + let _size = token.end - token.start; // then we peek at the first line let mut start: Option<(usize, usize)> = None; loop { diff --git a/src/lexer/lexer_prop_tests.rs b/src/lexer/lexer_prop_tests.rs index 0583499..97aaffc 100644 --- a/src/lexer/lexer_prop_tests.rs +++ b/src/lexer/lexer_prop_tests.rs @@ -1,7 +1,11 @@ -use super::*; -use proptest::{num::i32, prelude::*}; + +use proptest::{prelude::*}; + +#[allow(unused_imports)] +use crate::lexer::{Position, Spanned, Lexer, Token}; proptest! { + #[test] fn test_strings(rnd in ("[a-z]+", 1..10)) { let input = format!(r#"let {} = "{}""#, rnd.0, rnd.1); diff --git a/src/lexer/mod.rs b/src/lexer/mod.rs index bdba109..722bbcb 100644 --- a/src/lexer/mod.rs +++ b/src/lexer/mod.rs @@ -4,12 +4,9 @@ lexer.rs is a lexer for the src language use std::{fmt::Display, iter::Iterator, iter::Peekable, str::Chars}; -use lalrpop_util::{ - lexer::Token as LAToken, - state_machine::{ParserDefinition, TokenTriple}, -}; + use okstd::prelude::*; -use syn::token; + // Identifier #[derive(Debug, PartialEq, Clone, Copy)] @@ -266,7 +263,7 @@ impl<'input> Token<'input> { Token::Equals => "=".chars(), Token::LessThan => "<".chars(), Token::GreaterThan => ">".chars(), - Token::Variable(identifier) => { + Token::Variable(_identifier) => { // Implement the conversion to chars for Variable // based on its fields "".chars() @@ -274,8 +271,8 @@ impl<'input> Token<'input> { Token::Word(word) => word.chars(), Token::String(string) => string.chars(), Token::Comment(comment) => comment.chars(), - Token::Integer(number) => "".chars(), - Token::Float(number) => "".chars(), + Token::Integer(_number) => "".chars(), + Token::Float(_number) => "".chars(), Token::Eof => "".chars(), Token::NewLine => "\n".chars(), Token::LeftParen => "(".chars(), diff --git a/src/lib.rs b/src/lib.rs index 1478685..4a03d11 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,7 +3,7 @@ pub mod parser; pub mod compiler; use compiler::text; -use parser::ast; + use crate::compiler::ir; diff --git a/src/parser/errors.rs b/src/parser/errors.rs index ffaa424..e6f943b 100644 --- a/src/parser/errors.rs +++ b/src/parser/errors.rs @@ -3,8 +3,8 @@ pub fn pretty_errors<'input>(src: &'input str, errors: Vec todo!(), - lalrpop_util::ParseError::UnrecognizedEof { location, expected } => todo!(), + lalrpop_util::ParseError::InvalidToken { location: _ } => todo!(), + lalrpop_util::ParseError::UnrecognizedEof { location: _, expected: _ } => todo!(), lalrpop_util::ParseError::UnrecognizedToken { token, expected } => { // find the line and column of the start and end tokens, // and print the line with a caret pointing to the error @@ -23,8 +23,8 @@ pub fn pretty_errors<'input>(src: &'input str, errors: Vec todo!(), - lalrpop_util::ParseError::User { error } => todo!(), + lalrpop_util::ParseError::ExtraToken { token: _ } => todo!(), + lalrpop_util::ParseError::User { error: _ } => todo!(), }; } diff --git a/src/parser/mod.rs b/src/parser/mod.rs index a500533..3622cad 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -1,4 +1,3 @@ -use lalrpop_util::lalrpop_mod; mod parser_snap_tests; mod string; diff --git a/src/parser/parser_snap_tests.rs b/src/parser/parser_snap_tests.rs index 30cc700..1989073 100644 --- a/src/parser/parser_snap_tests.rs +++ b/src/parser/parser_snap_tests.rs @@ -1,7 +1,7 @@ -use crate::lexer::Lexer; + use crate::parser::errors::pretty_errors; use insta::assert_snapshot; -use okstd::prelude::*; + #[cfg(test)] #[okstd::test] diff --git a/src/parser/src.rs b/src/parser/src.rs index 1287b60..35775c5 100644 --- a/src/parser/src.rs +++ b/src/parser/src.rs @@ -1,10 +1,10 @@ // auto-generated: "lalrpop 0.20.2" // sha3: 58a0b50c7ef28fe4c687287586df7da9739726b0ed43438d355383eb2237332f -use std::str::FromStr; -use crate::parser::string::apply_string_escapes; + + use super::ast::*; -use lalrpop_util::{ErrorRecovery, ParseError}; -use crate::lexer::{Position, Token, Word, Variable}; +use lalrpop_util::{ErrorRecovery}; +use crate::lexer::{Token}; use okstd::prelude::*; #[allow(unused_extern_crates)] extern crate lalrpop_util as __lalrpop_util; diff --git a/src/parser/string.rs b/src/parser/string.rs index 593e8f9..756947d 100644 --- a/src/parser/string.rs +++ b/src/parser/string.rs @@ -1,8 +1,8 @@ -use std::str::Chars; -use stringzilla::{sz, StringZilla}; + + use syn::spanned::Spanned as _; -use crate::lexer::{self, Spanned}; + #[derive(Debug, PartialEq)] pub enum ParseError {