Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ProblemParser cannot handle numerics with arguments in goal #99

Closed
MichaelJFishman opened this issue Dec 17, 2023 · 2 comments
Closed

Comments

@MichaelJFishman
Copy link
Contributor

Subject of the issue

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]*')
@haz
Copy link
Contributor

haz commented Dec 29, 2023

Fixed with #103

@MichaelJFishman
Copy link
Contributor Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants