I want to make an advanced search form, with search by syntax. I've already found a github repository with an implementation very similar to what I want, but I can't understand the implementation so I can't adapt it to my needs. The search I'm trying to accomplish is the one that scryfall uses to search mtg cards. Here is a list of tests in python for a better idea of what I mean:
'c:bm' => '((id IN (SELECT card_id FROM card_color WHERE color_id = 3)) AND (id IN (SELECT card_id FROM card_color GROUP BY card_id HAVING COUNT(card_id) > 1)))'
'c:u OR (c:g AND NOT tou>3)' => "(id IN (SELECT card_id FROM card_color WHERE color_id = 2)) OR ((id IN (SELECT card_id FROM card_color WHERE color_id = 5)) AND NOT (toughness IS NOT NULL AND toughness <> '' AND CAST(toughness AS REAL) > 3))"
I can't find any resources explaining how this is done. What I need is an overview of how it's done so I could do it myself. There's an answer with code here but I wouldn't be able to write that myself. I need to understand it so I could adapt the code that I've found for my needs.