From 144b615f6e38626a72479a26bd62bdfeac3fa5b1 Mon Sep 17 00:00:00 2001 From: Francesco Fuggitti Date: Sun, 15 Oct 2023 16:25:15 -0400 Subject: [PATCH] address some of the review comments on the PR --- pddl/_validation.py | 84 ++--------------------------------------- pddl/parser/common.lark | 2 +- pddl/parser/domain.py | 1 + 3 files changed, 6 insertions(+), 81 deletions(-) diff --git a/pddl/_validation.py b/pddl/_validation.py index 3137990..bc96fe5 100644 --- a/pddl/_validation.py +++ b/pddl/_validation.py @@ -25,22 +25,11 @@ from pddl.logic import Predicate from pddl.logic.base import BinaryOp, QuantifiedCondition, UnaryOp from pddl.logic.effects import AndEffect, Forall, When -from pddl.logic.functions import Assign, Decrease, Divide -from pddl.logic.functions import EqualTo as FunctionEqualTo from pddl.logic.functions import ( + BinaryFunction, FunctionExpression, - GreaterEqualThan, - GreaterThan, - Increase, - LesserEqualThan, - LesserThan, - Minus, NumericFunction, NumericValue, - Plus, - ScaleDown, - ScaleUp, - Times, ) from pddl.logic.predicates import DerivedPredicate, EqualTo from pddl.logic.terms import Term @@ -263,74 +252,9 @@ def _(self, _: NumericValue) -> None: return None @check_type.register - def _(self, equal_to: FunctionEqualTo) -> None: - """Check types annotations of a PDDL numeric equal to operator.""" - self.check_type(equal_to.operands) - - @check_type.register - def _(self, lesser: LesserThan) -> None: - """Check types annotations of a PDDL numeric lesser operator.""" - self.check_type(lesser.operands) - - @check_type.register - def _(self, lesser_equal: LesserEqualThan) -> None: - """Check types annotations of a PDDL numeric lesser or equal operator.""" - self.check_type(lesser_equal.operands) - - @check_type.register - def _(self, greater: GreaterThan) -> None: - """Check types annotations of a PDDL numeric greater operator.""" - self.check_type(greater.operands) - - @check_type.register - def _(self, greater_equal: GreaterEqualThan) -> None: - """Check types annotations of a PDDL numeric greater or equal to.""" - self.check_type(greater_equal.operands) - - @check_type.register - def _(self, assign: Assign) -> None: - """Check types annotations of a PDDL numeric assign to.""" - self.check_type(assign.operands) - - @check_type.register - def _(self, scale_up: ScaleUp) -> None: - """Check types annotations of a PDDL numeric assign to.""" - self.check_type(scale_up.operands) - - @check_type.register - def _(self, scale_down: ScaleDown) -> None: - """Check types annotations of a PDDL numeric assign to.""" - self.check_type(scale_down.operands) - - @check_type.register - def _(self, increase: Increase) -> None: - """Check types annotations of a PDDL numeric increase to.""" - self.check_type(increase.operands) - - @check_type.register - def _(self, decrease: Decrease) -> None: - """Check types annotations of a PDDL numeric decrease operator.""" - self.check_type(decrease.operands) - - @check_type.register - def _(self, minus: Minus) -> None: - """Check types annotations of a PDDL numeric minus operator.""" - self.check_type(minus.operands) - - @check_type.register - def _(self, plus: Plus) -> None: - """Check types annotations of a PDDL numeric plus operator.""" - self.check_type(plus.operands) - - @check_type.register - def _(self, times: Times) -> None: - """Check types annotations of a PDDL numeric times operator.""" - self.check_type(times.operands) - - @check_type.register - def _(self, divide: Divide) -> None: - """Check types annotations of a PDDL numeric divide operator.""" - self.check_type(divide.operands) + def _(self, binary_function: BinaryFunction) -> None: + """Check types annotations of a PDDL numeric binary operator.""" + self.check_type(binary_function.operands) @check_type.register def _(self, equal_to: EqualTo) -> None: diff --git a/pddl/parser/common.lark b/pddl/parser/common.lark index 64513f0..17f209d 100644 --- a/pddl/parser/common.lark +++ b/pddl/parser/common.lark @@ -58,7 +58,7 @@ DECREASE: "decrease" MAXIMIZE: "maximize" MINIMIZE: "minimize" TOTAL_COST: "total-cost" -NUMBER: /[0-9]+/ +NUMBER: /[0-9]+(.[0-9]+)*/ // available requirements STRIPS: ":strips" diff --git a/pddl/parser/domain.py b/pddl/parser/domain.py index dd600df..e08bfdd 100644 --- a/pddl/parser/domain.py +++ b/pddl/parser/domain.py @@ -119,6 +119,7 @@ def predicates(self, args): def functions(self, args): """Process the 'functions' rule.""" function_definition = args[2] + # arg[2] is a dict with NumericFunction as keys and types as values, e.g., {(fuel ?l): number, (cost): number} return dict(functions=function_definition) def action_def(self, args):