There's already available - its name is tcl-parser and tcl-compiler.
But you forget, that tcl is dynamical language, so some things to be
evaluated (and parsed) only at execution time. And sometimes the
compiling/parsing takes place on demand and not necessarily in expr, if,
etc.
Whats about:
if {[[$obj exec [build {
select * from [$orm getTable {$FIELD == "TEST"}]
where ...
}]] == "0"} {...}
What do you see here? What is {$field == "test"}, but especially what
returns "$obj exec"? It is always a number?
Why it would be wanted behavior? (hint: empty for NULL, empty for not
found, and many many other things).
What occurs if we'll change or extend it tomorrow, so the class of $obj
becomes tomorrow other engine-possibility with similar interface, but
returns numbers here (but the original engine returns as before string
or vice versa).
Or something like sqlite in tcl:
$db eval {.. very large and complex statement ... $A == {...} ... }
What do you see here? It is some prepro (aka prepared args)? Or "$db
eval" does "subst" internally? Or it's a part that will be LEGAL
COMPILED INTERNALLY (TRANSIENT ON DEMAND) TO SOME LEGAL TCL-EXPRESSION?
Or someone have defined own operand "==" in own sql-syntax (or it is
even nosql-syntax).
Just another one:
set expr1 {$A $OP $B}; ... ; myEvaluate $expr1 $op $a $b
AND ESPECIALLY - HOW YOU WANT GENERALLY TO DIFFERENTIATE BETWEEN TCL AND
NOT TCL, namely SQL, NoSQL with expr-support, Tcl+Other mix,
pre-processors, that will be executed before tcl (and not with Tcl), on
demand compilation to expression or dynamically scripts, etc?
If you can use such parser, good luck... BUT I AND MY COLLEAGUES CAN
NOT.
Regards,
sebres.
Am 01.02.2017 18:48, schrieb Peter S:
> A simple "operator validator" program, nothing serious, done in 20 minutes...
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Tcl-Core mailing list
Tcl-...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tcl-core