So far my parser looks like this.
const parser = peg.generate(`
eq
= left:attribute "=" right:value { return left == right; }
and
= left:eq "AND" right:eq { return left && right; }
It is able to read queries like id = 2 AND createdOn = 193242
. I want to be able to read id = 2 AND secondId = 444 AND createdOn = 193242
and so on... (Any number of "AND"s). How can I achieve this via PEG.js?
This should do it:
Generic solution for any number of operators with any precedence (creates AST):