Closed Torlos closed 5 years ago
Ugh. module box(brim = abs(min(chamferHeight2, 0)) + 1)
is a really ugly method signature. I don't know how I feel about supporting that kind of extra complexity in a signature.
But... as currently written, you're right that SolidPython will definitely crash on that one.
Without spending a while running through the regex, I'm not sure what your edit does. Can you describe what you're accomplishing, and give some examples of strings that would match the regex and which would not? Or even better, insert comments in the regex?
Thank you for your attention.
I have update my regular expression for more cases of use.
But for recursion parsing and and balanced brackets I use the python module regex
(pip install regex
) which is more complete. So in file solidpython.py
:
import regex as re
You cas see the difference between old ann nex regular expression
With
(?mxs)(?P<arg_name>\w+)(?:\s*=\s*(?P<default_val>[\w.-]+|\[.*\]))?(?:,|$)
Only expressions 1 to 9 matched
var5,
var2=78,
var_true = true,
var_true = false,
var_int = 5,
var_negative = -5,
var_float = 5.5,
var_number = -5e89,
var_empty_vector = [],
var_simple_string = "simple string",
var_complexe_string = "a \"complexe\"\tstring with a\\",
var_vector = [5454445, 565, [44545]],
var_complexe_vector = [545 + 4445, 565, [cos(75) + len("yes", 45)]],
var_vector = [5, 6, "string\twith\ttab"],
var_range = [0:10e10],
var_range_step = [-10:0.5:10],
var_with_arithmetic = 8 * 9 - 1 + 89 / 15,
var_with_parentheses = 8 * ((9 - 1) + 89) / 15,
var_with_functions = abs(min(chamferHeight2, 0)) */-+ 1,
var_with_conditionnal_assignement = mytest ? 45 : yop,
with
(?mxs)(?P<arg_name>\w+)(?:\s*=\s*(?P<default_val>([\w.\"\s\?:\-+\\\/*]+|\((?>[^()]|(?2))*\)|\[(?>[^\[\]]|(?2))*\])+))?(?:,|$)
PS: I agree with you, it's a really ugly method signature.
That's a really great set of examples, Torlos. Thanks for putting those together. I'm incorporating the change and the extra dependency and I'll make a new release in the next few days when that's all done. Cheers!
Hello,
When I "use" Chamfers-for-OpenSCAD, this error is raised :
The scad modul code :
The generated python code is :
I propose this modification like this :
Torlos