Skip to content

Commit

Permalink
Added ignore dead code to github workflow and readme bagde
Browse files Browse the repository at this point in the history
  • Loading branch information
Hexorg committed Oct 22, 2023
1 parent 3021ff9 commit 56be58e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 21 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ jobs:
toolchain: stable
components: rustfmt, clippy
- name: Run cargo build
run: cargo build --release
run: RUSTFLAGS="$RUSTFLAGS -A dead_code" cargo build --release
- name: Run cargo test
run: cargo test --release --all-features
run: RUSTFLAGS="$RUSTFLAGS -A dead_code" cargo test --release --all-features
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[![Build status](https://github.com/Hexorg/pddl_rs/actions/workflows/workflow.yml/badge.svg)(https://github.com/Hexorg/pddl_rs/actions/workflows/workflow.yml)]

# pddl_rs

PDDL Parsing library based on [Daniel L. Kovacs' BNF definition](http://pddl4j.imag.fr/repository/wiki/BNF-PDDL-3.1.pdf) BNF Definition of PDDL. Future plans include adding planning algorithms to reflect [PDDL4J library](https://github.com/pellierd/pddl4j)
Expand Down
11 changes: 4 additions & 7 deletions src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub trait Runnable {
}

impl Runnable for Vec<Instruction> {
fn run(&self, state:&[bool], functions:&[i64]) -> bool {
fn run(&self, state:&[bool], _:&[i64]) -> bool {
let mut stack = Vec::<Value>::with_capacity(512);
for instruction in self {
match instruction {
Expand Down Expand Up @@ -295,7 +295,7 @@ fn compile_term_atomic_formula<'src>(compiler:&CompilerData<'src>, af:&AtomicFor
}
call_vec.push(name.1);
},
Function(func) => todo!()
Function(_) => todo!()
}
}
if let Some(offset) = compiler.predicate_memory_map.get(&call_vec) {
Expand Down Expand Up @@ -372,7 +372,7 @@ fn compile_name_negative_formula<'src>(compiler:&CompilerData<'src>, formula:&Ne
}
}

fn compile_fexp<'src>(compiler:&CompilerData<'src>, fexp:&FluentExpression<'src>, instructions: &mut Vec<Instruction>) -> Result<(), Error<'src>> {
fn compile_fexp<'src>(_:&CompilerData<'src>, fexp:&FluentExpression<'src>, instructions: &mut Vec<Instruction>) -> Result<(), Error<'src>> {
match fexp {
FluentExpression::Number(n) => instructions.push(Instruction::Push(*n)),
FluentExpression::Subtract(_) => todo!(),
Expand All @@ -387,7 +387,6 @@ fn compile_fexp<'src>(compiler:&CompilerData<'src>, fexp:&FluentExpression<'src>

enum SupportedFunctionOp {
INC,
DEC
}
fn function_op<'src>(compiler:&CompilerData<'src>, function:&FunctionTerm<'src>, fexp:&FluentExpression<'src>, op:SupportedFunctionOp, instructions: &mut Vec<Instruction>) -> Result<(), Error<'src>> {
compile_fexp(compiler, fexp, instructions)?;
Expand All @@ -396,7 +395,6 @@ fn function_op<'src>(compiler:&CompilerData<'src>, function:&FunctionTerm<'src>,
instructions.push(Instruction::ReadFunction(0)); // todo! map functions
match op {
INC => instructions.push(Instruction::Add),
DEC => instructions.push(Instruction::Sub),
}
instructions.push(Instruction::SetFunction(0));
Ok(())
Expand Down Expand Up @@ -522,8 +520,7 @@ fn map_objects<'src>(domain:&Domain<'src>, problem:&Problem<'src>) -> Result<Com

#[cfg(test)]
pub mod tests {
use std::fs;
use crate::{parser::{parse_domain, parse_problem}, compiler::{compile_problem, CompiledProblem, Instruction, CompiledAction}, search::a_star};
use crate::{parser::{parse_domain, parse_problem}, compiler::{compile_problem, Instruction, CompiledAction}};

use super::*;

Expand Down
26 changes: 14 additions & 12 deletions src/search.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{collections::{BinaryHeap, HashMap}, fs, hash::Hash};
use std::{collections::{BinaryHeap, HashMap}, hash::Hash};
pub mod routing;
use crate::compiler::{CompiledProblem, Runnable};

Expand Down Expand Up @@ -123,31 +123,33 @@ mod test {

#[test]
#[ignore = "takes too long without optimizations"]
fn barman_pddl_search() {
let solution = full_search("sample_problems/barman/domain.pddl", "sample_problems/barman/problem_5_10_7.pddl");
assert_eq!(solution, vec![182, 6, 404])
fn barman_pddl_search() -> std::io::Result<()> {
let solution = full_search("sample_problems/barman/domain.pddl", "sample_problems/barman/problem_5_10_7.pddl")?;
assert_eq!(solution, vec![182, 6, 404]);
Ok(())
}

#[test]
fn simple_pddl_search() {
let solution = full_search("sample_problems/simple_domain.pddl", "sample_problems/simple_problem.pddl");
assert_eq!(solution, vec![182, 219, 6, 404])
fn simple_pddl_search() -> std::io::Result<()>{
let solution = full_search("sample_problems/simple_domain.pddl", "sample_problems/simple_problem.pddl")?;
assert_eq!(solution, vec![182, 219, 6, 404]);
Ok(())
}

fn full_search(domain_filename:&'static str, problem_filename:&'static str) -> Vec<usize> {
fn full_search(domain_filename:&'static str, problem_filename:&'static str) -> std::io::Result<Vec<usize>> {
use std::fs;
let domain_src = fs::read_to_string(domain_filename).unwrap();
let domain = match parse_domain(&domain_src) {
Err(e) => {e.report(domain_filename).eprint((domain_filename, ariadne::Source::from(&domain_src))); panic!() },
Err(e) => {e.report(domain_filename).eprint((domain_filename, ariadne::Source::from(&domain_src)))?; panic!() },
Ok(d) => d,
};
let problem_src = fs::read_to_string(problem_filename).unwrap();
let problem = match parse_problem(&problem_src, domain.requirements) {
Err(e) => {e.report(problem_filename).eprint((problem_filename, ariadne::Source::from(&problem_src))); panic!() },
Err(e) => {e.report(problem_filename).eprint((problem_filename, ariadne::Source::from(&problem_src)))?; panic!() },
Ok(p) => p
};
let c_problem = match compile_problem(&domain, &problem) {
Err(e) => {e.report(problem_filename).eprint((problem_filename, ariadne::Source::from(&problem_src))); panic!() },
Err(e) => {e.report(problem_filename).eprint((problem_filename, ariadne::Source::from(&problem_src)))?; panic!() },
Ok(cd) => cd,
};
println!("Compiled problem needs {} bits of memory and uses {} actions.", c_problem.memory_size, c_problem.actions.len());
Expand All @@ -157,6 +159,6 @@ mod test {
let action = c_problem.actions.get(*action_id).unwrap();
println!("\t{}{:?}", action.name.1, action.args.iter().map(|(_, s)| *s).collect::<Vec<&str>>());
}
solution
Ok(solution)
}
}

0 comments on commit 56be58e

Please sign in to comment.