After i discovered that you could define operators i built a combinatorial parser, something akin to https://hackage.haskell.org/package/parsec (of course nowhere as powerful) with similar syntax and do notation. https://gist.github.com/ga2arch/e8904177f722c6560e37
And i didn't have to define backtracking because it is handled by prolog itself.