I am in the process of implementing a program that applies some transformations to SQL code. When it comes to parsing said code, I thought about two approaches.
- Implementing a "standard" parser using ordinary functions
- Implementing a Reader macro that does such interpretation at read-time.
I'd like to know if implementing a reader macro is valid for this case or I'm better off writing it with usual functions and avoid killing a insect with a bazooka.
(select (foo bar (named average-baz (/ (sum baz) (count baz)))) :from (join things bits :on bit-id :kind :left) :group-by wazoo :sort-by (:ascending bing) :where (> quality 7)), or even some representation that is easier for you. If you want to read sql then you should write a proper parser. You say “killing an insect with a bazooker” but in fact reader macros are often painful and weak parsers best suited to simple tasks.