in reply to Re: Can I get some rules help with PARSE::RECDESCENT
in thread Can I get some rules help with PARSE::RECDESCENT

ikegami, thank you for your response. I will try to answer your questions.

I am sorry my code did not work for you. I diffed it against the code on my system and it is working for me. I can offer no explanation for this behavior.

I apologize for not being more forthcoming with my requirements. I had hoped that the example I provided would be enough. This is essentially an “order of operations” problem. The three operations I have are And, Or, and Not. And I basically want to build a tree that will let me handle the terms in order based on the precedence provided by parenthesis with the And and Or at the same level and Not being a little higher. (I know Not is not in my original code, but I was starting small) Take the below generic statement.

(term1) and (term2) and ((term3) or (term4)) and not (term5))

I would like to boil this down into an array I can traverse bottom up getting to the innermost terms first.

So first resolve term3 or term 4

Then resolve the results vs. not term5

Then resolve the results vs term 2 and term 1

I figured traversing a tree structure would be the fastest way to do this but I am open to suggestions.

  • Comment on Re^2: Can I get some rules help with PARSE::RECDESCENT

Replies are listed 'Best First'.
Re^3: Can I get some rules help with PARSE::RECDESCENT
by ikegami (Patriarch) on Mar 12, 2018 at 19:03 UTC

    You said this is your desired output:

    $VAR1 = { { 'cvtype=\'problem\'' } { and } { problem_description match \'*\' } };

    Your desired output makes no sense. It doesn't even compile.

    syntax error at a.pl line 5, near "{" Can't find string terminator "'" anywhere before EOF at a.pl line 9.

    Please fix.


    I would like to boil this down into an array

    Really? An array of what? Parsers normally produce trees.

      My apologies.

      My studies led me to believe that the presentation of a Tree in PERL is actually a Multi-dimensional array. Where the bottom of the tree is actually the furthest out array elements. Kind of turns a tree on it's side. If I am wrong that put's a whole new spin on what I am trying to do.

      Thank You

      DevM