The problem parser seems unable to parse goals which use numerics with arguments.
Your environment
OS: Ubuntu
Python version: 3.10.10
Package Version 0.4.0
Steps to reproduce
with open("my_problem.pddl", "r") as f:
problem = ProblemParser()(f.read())
Where my_problem.pddl holds hello-world-functions/p0.pddl, modified to use an argument for the numeric:
(define (problem hello-3-times)
(:domain hello-world-functions)
(:init
; if this was undefined, some planners would not assumed `0`
(= (hello_counter jimmy) 0)
)
(:goal
(>= (hello_counter jimmy) 3)
)
)
Expected behaviour
The problem should be parsed.
Actual behaviour
I get this error:
Traceback (most recent call last):
File "/home/username/mambaforge/envs/env_name/lib/python3.10/site-packages/lark/visitors.py", line 124, in _call_userfunc
return f(children)
File "/home/pddl/pddl/parser/problem.py", line 199, in f_head
return self._domain_transformer.f_head(args)
File "/home/pddl/pddl/parser/domain.py", line 389, in f_head
variables = [Variable(x, {}) for x in args[2:-1]]
File "/home/pddl/pddl/parser/domain.py", line 389, in <listcomp>
variables = [Variable(x, {}) for x in args[2:-1]]
File "/home/pddl/pddl/logic/terms.py", line 126, in __init__
super().__init__(name, type_tags=type_tags)
File "/home/pddl/pddl/logic/terms.py", line 45, in __init__
self._name = parse_name(term_name)
File "/home/pddl/pddl/custom_types.py", line 62, in parse_name
return name(s)
File "/home/pddl/pddl/helpers/base.py", line 163, in __init__
self._handle_no_match()
File "/home/pddl/pddl/helpers/base.py", line 166, in _handle_no_match
raise ValueError(
ValueError: Value 'Tree('domain__constant', [Token('domain__NAME', 'jimmy')])' does not match the regular expression re.compile('[A-Za-z][-_A-Za-z0-9]*')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
<redacted>
File "/home/pddl/pddl/parser/problem.py", line 250, in __call__
formula = self._transformer.transform(tree)
File "/home/username/mambaforge/envs/env_name/lib/python3.10/site-packages/lark/visitors.py", line 161, in transform
return self._transform_tree(tree)
File "/home/username/mambaforge/envs/env_name/lib/python3.10/site-packages/lark/visitors.py", line 156, in _transform_tree
children = list(self._transform_children(tree.children))
File "/home/username/mambaforge/envs/env_name/lib/python3.10/site-packages/lark/visitors.py", line 146, in _transform_children
res = self._transform_tree(c)
File "/home/username/mambaforge/envs/env_name/lib/python3.10/site-packages/lark/visitors.py", line 156, in _transform_tree
children = list(self._transform_children(tree.children))
File "/home/username/mambaforge/envs/env_name/lib/python3.10/site-packages/lark/visitors.py", line 146, in _transform_children
res = self._transform_tree(c)
File "/home/username/mambaforge/envs/env_name/lib/python3.10/site-packages/lark/visitors.py", line 156, in _transform_tree
children = list(self._transform_children(tree.children))
File "/home/username/mambaforge/envs/env_name/lib/python3.10/site-packages/lark/visitors.py", line 146, in _transform_children
res = self._transform_tree(c)
File "/home/username/mambaforge/envs/env_name/lib/python3.10/site-packages/lark/visitors.py", line 156, in _transform_tree
children = list(self._transform_children(tree.children))
File "/home/username/mambaforge/envs/env_name/lib/python3.10/site-packages/lark/visitors.py", line 146, in _transform_children
res = self._transform_tree(c)
File "/home/username/mambaforge/envs/env_name/lib/python3.10/site-packages/lark/visitors.py", line 156, in _transform_tree
children = list(self._transform_children(tree.children))
File "/home/username/mambaforge/envs/env_name/lib/python3.10/site-packages/lark/visitors.py", line 146, in _transform_children
res = self._transform_tree(c)
File "/home/username/mambaforge/envs/env_name/lib/python3.10/site-packages/lark/visitors.py", line 157, in _transform_tree
return self._call_userfunc(tree, children)
File "/home/username/mambaforge/envs/env_name/lib/python3.10/site-packages/lark/visitors.py", line 128, in _call_userfunc
raise VisitError(tree.data, tree, e)
lark.exceptions.VisitError: Error trying to process rule "f_head":
Value 'Tree('domain__constant', [Token('domain__NAME', 'jimmy')])' does not match the regular expression re.compile('[A-Za-z][-_A-Za-z0-9]*')
Subject of the issue
The problem parser seems unable to parse goals which use numerics with arguments.
Your environment
Steps to reproduce
Where
my_problem.pddl
holdshello-world-functions/p0.pddl
, modified to use an argument for the numeric:Expected behaviour
The problem should be parsed.
Actual behaviour
I get this error: