diff --git a/pddl/parser/domain.lark b/pddl/parser/domain.lark index 0b1f558..55e42fa 100644 --- a/pddl/parser/domain.lark +++ b/pddl/parser/domain.lark @@ -54,18 +54,18 @@ atomic_formula_term: LPAR predicate term* RPAR ?predicate: NAME constant: NAME -binary_comp: GREATER_OP - | LESSER_OP - | EQUAL_OP - | GREATER_EQUAL_OP - | LESSER_EQUAL_OP +?binary_comp: GREATER_OP + | LESSER_OP + | EQUAL_OP + | GREATER_EQUAL_OP + | LESSER_EQUAL_OP -assign_op: INCREASE - | DECREASE +?assign_op: INCREASE + | DECREASE -f_exp: NUMBER +?f_exp: NUMBER | f_head -?f_head: NAME +f_head: NAME | LPAR NAME term* RPAR typed_list_variable: variable* diff --git a/pddl/parser/domain.py b/pddl/parser/domain.py index c195c1c..c7c3867 100644 --- a/pddl/parser/domain.py +++ b/pddl/parser/domain.py @@ -29,6 +29,8 @@ GreaterThan, LesserEqualThan, LesserThan, + Increase, + Decrease, ) from pddl.logic.predicates import DerivedPredicate, EqualTo, Predicate from pddl.logic.terms import Constant, Variable @@ -282,6 +284,16 @@ def cond_effect(self, args): assert_(len(args) == 1) return args[0] + def num_effect(self, args): + """Process the 'num_effect' rule.""" + function = args[2] + value = args[3] + if args[1] == Symbols.INCREASE.value: + return Increase(function, value) + if args[1] == Symbols.DECREASE.value: + return Decrease(function, value) + raise PDDLParsingError("Assign operator not recognized") + def atomic_formula_term(self, args): """Process the 'atomic_formula_term' rule.""" @@ -331,6 +343,14 @@ def atomic_function_skeleton(self, args): variables = self._formula_skeleton(args) return Function(function_name, *variables) + def f_head(self, args): + """Process the 'f_head' rule.""" + if len(args) == 1: + return args[0] + function_name = args[1] + variables = [Variable(x, {}) for x in args[2:-1]] + return Function(function_name, *variables) + def typed_list_name(self, args) -> Dict[name, Optional[name]]: """Process the 'typed_list_name' rule.""" try: