So what I've been doing isn't working. I have no idea how to handle this; what an incredibly frustrating situation. I know exactly where the problem is, but I have no workaround. No, that's false; I have a way to deal with the problem, but it's ugly and long-winded. Also, I feel like I'm a bad partner for being unable to get this done. These are the four test cases I'm trying to make our code work with:
>>> string_to_tree('(0***.1)')
DotNode(StarNode(StarNode(StarNode(RegexTreeNode(0, [])))), RegexTreeNode(1, []))
>>> string_to_tree('(0|(0.1***))')
BarNode(RegexTreeNode(0, []), DotNode(RegexTreeNode(0, []), StarNode(StarNode(StarNode(RegexTreeNode(1, []))))))
>>> string_to_tree('(0***.1***)')
DotNode(StarNode(StarNode(StarNode(RegexTreeNode(0, [])))), StarNode(StarNode(StarNode(RegexTreeNode(1, [])))))
>>> string_to_tree('(0|(0.1)***)')
BarNode(RegexTreeNode(0, []), StarNode(StarNode(StarNode(DotNode(RegexTreeNode(0, []), RegexTreeNode(1, []))))))
Unfortunately for me, it just won't happen. The first case is the simplest that we're trying to make work. Then the nested scenario. Then multiple instances of nested StarNodes, then one in which the StarNode applies to another BinaryNode. It works if the string were, say, '(0|(((0.1)*)*)*)', but trying to construct a new string has been an exercise in, if not futility, than absolute madness. I'm not too sure what else to do, though. Creating a new string with brackets around the designated areas is difficult, but trying to fix the current mutually recursive helper functions is also ridiculously difficult, too. What a pain.
No comments:
Post a Comment