Replies: 5 comments 2 replies
-
I think your best bet might be to try to find an existing Antlr grammar for soql and use that for parsing, then you just need to build the logic to visit the code and generate a data structure of your choosing. |
Beta Was this translation helpful? Give feedback.
-
I'm currently using pyparsing but coming up against my intellectual limits when I try to expand what it can already do. I've only got it supporting fairly basic queries at the moment. Perhaps I should try another library. Would you entertain using a tool like jsii for this library? https://github.com/aws/jsii/ It works well with cdk. Since I ultimately want a soql-parser for my unit tests, speed isn't a concern to me. |
Beta Was this translation helpful? Give feedback.
-
@brno32 - I take a few minutes looking into jsii and I think it might take some working with to figure out how to make this work. It looks like the required typescript options are a bit stricter than I have implemented, so it will require some minor tweaks to accommodate. I will try to spend more time investigating to see if this is a valid option and hopefully it is. |
Beta Was this translation helpful? Give feedback.
-
Great to hear. Happy to help if possible! |
Beta Was this translation helpful? Give feedback.
-
@brno32 - jsii adds too many restrictions to what is allowed in Typescript and it would be a significant amount of effort and refactoring just to get the codebase compatible. I did just release a new version that includes a CLI, so that could be a potentially option for you - but it will require that you have the node runtime installed, then you could use something like toolshed_shell to run the cli. Check out the readme for some examples. Example (might be outdated): http://sweetme.at/2014/02/17/a-simple-approach-to-execute-a-node.js-script-from-python/ I hope this is a viable option based on your environment. The other option would be to spin up a node API server and validate over http, but that would be really slow and could be error prone - but would be fairly trivial to setup as long as you had somewhere to host it. |
Beta Was this translation helpful? Give feedback.
-
I wrote https://github.com/Kicksaw-Consulting/python-soql-parser but it's not very good, has a lot limits, and the code sucks. I'm ashamed of it.
I'm looking for someone who can help me rewrite it, hopefully taking inspiration from this library. If a rewrite is not possible, is there a feasible way to transpile this lib to python code, or run it from within python using something like https://github.com/PiotrDabkowski/Js2Py?
Hoping to start a good discussion here! Thanks for putting this library out there.
Beta Was this translation helpful? Give feedback.
All reactions