ros-infrastructure / catkin_pkg

Standalone Python library for the catkin build system.
https://github.com/ros/catkin
Other
47 stars 89 forks source link

use parse actions to evaluate conditions #283

Closed MatthijsBurgh closed 4 years ago

MatthijsBurgh commented 4 years ago

Inspired by https://github.com/pyparsing/pyparsing/blob/master/examples/simpleBool.py With the use of ParseActions, the result are specific classes in which better use is made of the results of the operatorPrecedence.

I wanted to use bool with an extra argument, but that isn't allowed, therefore I chose to implement __call__ for all the classes.

Fixes #277, #281, improvement of #279

MatthijsBurgh commented 4 years ago

@dirk-thomas I created this before I found out that a fix was already implemented in master, but not yet released.

I think this is a more elegant solution as we don't abuse _evaluate to be a recursive function which handles all cases all parts of the solution. Instead create different classes with each handling there part of the solution.

Please let me know what you think of it.

dirk-thomas commented 4 years ago

Thanks for this improvement.

I updated the title to reflect the actual content of the patch. I also added some commits to mainly keep the diff more readable / minimal. I hope they make sense to you.

MatthijsBurgh commented 4 years ago

@dirk-thomas looks good!