Skip to content

Commit

Permalink
Remove unused parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
garritfra committed Aug 19, 2024
1 parent 8358bb3 commit b3e8e52
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 73 deletions.
1 change: 0 additions & 1 deletion src/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ pub type SymbolTable = HashMap<String, Option<Type>>;

#[derive(Debug, Clone)]
pub struct Module {
pub path: String,
pub imports: HashSet<String>,
pub func: Vec<Function>,
pub structs: Vec<StructDef>,
Expand Down
5 changes: 2 additions & 3 deletions src/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ impl Builder {
let tokens = lexer::tokenize(&contents)?;
let module = parser::parse(
tokens,
Some(contents),
resolved_file_path.display().to_string(),
Some(contents)
)?;
for import in &module.imports {
// Prevent circular imports
Expand Down Expand Up @@ -160,7 +159,7 @@ impl Builder {
let stblib_str =
std::str::from_utf8(&stdlib_raw).expect("Could not interpret standard library.");
let stdlib_tokens = lexer::tokenize(stblib_str)?;
let module = parser::parse(stdlib_tokens, Some(stblib_str.into()), file.to_string())
let module = parser::parse(stdlib_tokens, Some(stblib_str.into()))
.expect("Could not parse stdlib");
self.modules.push(module);
}
Expand Down
1 change: 0 additions & 1 deletion src/generator/x86.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ impl X86Generator {
func,
globals,
structs: _,
path: _,
imports: _,
} = prog;

Expand Down
4 changes: 2 additions & 2 deletions src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use crate::lexer::Token;
#[cfg(test)]
mod tests;

pub fn parse(tokens: Vec<Token>, raw: Option<String>, path: String) -> Result<Module, String> {
let mut parser = parser::Parser::new(tokens, raw, path);
pub fn parse(tokens: Vec<Token>, raw: Option<String>) -> Result<Module, String> {
let mut parser = parser::Parser::new(tokens, raw);
parser.parse()
}
4 changes: 1 addition & 3 deletions src/parser/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ use std::iter::Peekable;
use std::vec::IntoIter;

pub struct Parser {
pub path: String,
tokens: Peekable<IntoIter<Token>>,
peeked: Vec<Token>,
current: Option<Token>,
Expand All @@ -34,13 +33,12 @@ pub struct Parser {

impl Parser {
#[allow(clippy::needless_collect)] // TODO
pub fn new(tokens: Vec<Token>, raw: Option<String>, file_name: String) -> Parser {
pub fn new(tokens: Vec<Token>, raw: Option<String>) -> Parser {
let tokens_without_whitespace: Vec<Token> = tokens
.into_iter()
.filter(|token| token.kind != TokenKind::Whitespace && token.kind != TokenKind::Comment)
.collect();
Parser {
path: file_name,
tokens: tokens_without_whitespace.into_iter().peekable(),
peeked: vec![],
current: None,
Expand Down
1 change: 0 additions & 1 deletion src/parser/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ impl Parser {
func: functions,
structs,
globals,
path: self.path.clone(),
imports,
})
}
Expand Down
Loading

0 comments on commit b3e8e52

Please sign in to comment.