On Wed, Jun 3, 2009 at 7:56 PM, erik quanstrom<quans...@quanstro.net> wrote: > "structural awk" is still a tempting idea. but why not > just go wild and implement a shell with sres?
For my final project in the compilers course I took, I had this idea to take structural regular expressions and use them to match patterns against the parse trees generated by a compiler frontend. The intent was to be able to detect "unsafe" code at compile time via pattern matching; I then implemented a small awk-like language that contained syntax for doing the matching and a few primitives for doing things like printing compiler errors or warnings (hooking into the facilities provided by the compiler). We linked it into lcc; it was kind of neat. You could define a 'program' that the compiler interpreted as it compiled a source file that could contain a library of additional errors and warnings that were specific to your problem domain (for instance, I wrote code to detect calls to 'gets' and error out). Of course, it broke down somewhat because the language of strings necessarily all that well suited to describing trees whose elements come from a completely different domain, but I still think the idea has some merit. This was in 2003; I gather things like that are now beginning to become somewhat common elsewhere. - Dan C.