Hello everyone
If I wanted to introduce new syntax in my groovy script, how would I go about
doing it? I want to embed custom syntax directly into the groovy file and have
it be parsed into my custom AST nodes. An example would be
myFunction() {
List<MyTableValues> tableValues = select value from mySQLTable where (select
tableName from myTableNames where user = $userName)
... Use table Values
}
I want to enable a few behaviors
a) Check for syntax correctness (which is why I want to parse using antlr
grammar)
b) Check for semantic correctness (I suppose if I parsed this into my custom
AST nodes, that takes care of that. I could make an SQLExpressionASTNode and
validate things there)
c) Enable a debug experience where I am able to see the result of the inner SQL
first and then see it move to the outer SQL (this would be super awesome, but I
realize this is in the purview of the groovy IDE plugin. I am asking here to
see if I can get any pointers)
My limited ideas so far are to annotate the List declaration with @SQL, hook
into the semantic phase to translate the select clause (embedded in a gstring)
into a validated, redirect into a custom function call.
so if I see
@SQL List<MyTableValues> tableValues = "select ...."
I'll convert it to
@SQL List<MyTableValues> tableValues = sqlRunner.run("select ...")
This does not get me debuggability though and it feels contrived
regards
Saravanan