Background
Currently I'm using C++ MySQL connector to communicate with a database, and sometimes I need to send hardcoded commands through connection. As did many times, I make errors/typos and whatnot. This is for a very basic Database Systems class, so no industry involved.
Question
Is is possible to implement constexpr
compiler for another language that would just run lexical, syntax, and semantic analyzis and report errors if it found them? Or maybe some additional compilation step?
Example
Lets suppose I wanted to send this command:
SELECT * FROM Persons
but instead, I forgot to type M
:
SELECT * FRO Persons
I'd discover the problem at runtime, which could be caught by the compiler if it knew the language. My only idea to solve this is preprocessor madness.
From C++, I would call it like this:
auto statement = sql_parse("...");
and hopefully it should cause compilation error if something is wrong.