meander

All things about https://github.com/noprompt/meander Need help and no one responded? Feel free to ping @U5K8NTHEZ
nlessa 2020-04-28T16:28:49.149800Z

Hi! I am not understanding why something like this works

(ms/rewrite
  (me/with [%e-entidade (me/or (= e (me/pred symbol? ?e))
                               (= (me/pred symbol? ?e) e))
            %a-atributo (me/or (= a (me/pred keyword? ?a))
                               (= (me/pred keyword? ?a) a))
            %v-valor (me/or (= v (me/pred symbol? ?v))
                            (= (me/pred symbol? ?v) v))
            %v-args (me/or (me/pred symbol? ?v)) 
            %v-teste-unario ((me/pred function? !funcao-unaria) !param-function-unaria)
            %operador-binario (me/pred #{'< '> '<= '>= 'not=} !funcao-binaria)
            %v-teste-binario (%operador-binario %v-args !param-function-binaria)
            %v-teste-funcao (me/or %v-teste-unario %v-teste-binario)
            %v-expression (me/or %v-valor %v-teste-unario %v-teste-binario)]
           [%e-entidade %a-atributo %v-valor . %v-teste-funcao ..1]) :ok)
but if I add any other params in the the (me/or of %v-args, eg,
%v-args (me/or (me/pred symbol? ?v) a-symbol) 
I get an Unable to resolve symbol: ?v in this context What am I missing? Thanks in advance!

jimmy 2020-04-28T16:58:31.150200Z

@nlessa Definitely looks like a bug. Will try to find some time today to dig into it.

jimmy 2020-04-28T17:01:16.150800Z

I am a little confused as to what you are trying to accomplish though. Do you have an example of the data your are matching on?

jimmy 2020-04-28T17:01:36.151400Z

Those = signs are not going to be doing what I think you want them to do.

jimmy 2020-04-28T17:01:55.151900Z

So while I might be able to find the bug, I want to make sure you can accomplish your task as well.

nlessa 2020-04-28T17:18:48.157500Z

Thanks, @jimmy! The symbols = appears in the grammar that is being rewrited. It's been working fine, only with this little problem with the me/or. The use case I am working is a transformation from rules expressed in Clara Rules to datalog clauses. Meander worked very well! I faced only this and another strange problem (but with workaround) . I will post later here the other problem I found.

jimmy 2020-04-28T17:19:44.158200Z

Okay, cool. Just wanted to make sure that the = signs were meant to be literals.

jimmy 2020-04-28T17:22:48.159200Z

Also great to hear that it is working for you. Interesting to see a transformation from clara to datalog. Hopefully we can help fix those remaining issues.

jimmy 2020-04-28T17:25:16.160100Z

Okay so the fact that you get the error you do is a bug. But for %v-args (me/or (me/pred symbol? ?v)) if you want something else in the or you need to make sure it has ?v in it.

👍 1
jimmy 2020-04-28T17:25:46.160800Z

If you add a pattern that includes ?v there you should be fine. We are clearly failing to detect that problem correctly though and so we generate bad code.

nlessa 2020-04-28T17:33:07.161600Z

Ah, ok, understood!

jimmy 2020-04-28T17:43:02.163200Z

@noprompt Just fyi. Looks like we consider ?v bound already because of %v-valor and so argument-lvrs is empty. https://github.com/noprompt/meander/blob/b2a6ab1135f3bf3be3abf2f113930c4ffec71f04/src/meander/match/check/epsilon.cljc#L154-L187

noprompt 2020-04-28T17:52:32.164900Z

@jimmy Thanks for taking a look. Do you have a patch in mind or did you want me to take it from here?

noprompt 2020-04-28T17:52:56.165600Z

I’m sure fixing this will probably fix other instances of this problem.

noprompt 2020-04-28T17:53:20.166300Z

(I’ve encountered it once in the last couple months but didn’t have a chance to properly look into it.)

jimmy 2020-04-28T17:53:37.166600Z

I haven't had a chance to think of a fix. Need to familiarize myself with that code. Just wanted to dump the little bit I found here.

noprompt 2020-04-28T17:54:04.167100Z

Okay, cool. This is perfect. It saves a ton of time. 🙂