Gre7g Luterman <[EMAIL PROTECTED]> writes: > On 02 Dec 2002 22:51:17 -0600, Tim Legant > <[EMAIL PROTECTED]> wrote: > > > No back jumping in this forum. > > Hey, if you've ever suggested anything even remotely radical on lists > like djbdns then you can understand my hesitancy. They would make you > wish you had never been born.
Yeah, I know. I would like to think both Jason and I encourage ineteresting new ideas by respect for the submitter, even if they turn out not to be where we (most particularly Jason) want TMDA to go. Some of the best ideas come from lame suggestions with a core of value that gets developed. Damning the original suggester for idiocy would have lost that idea. > Okay, then let me suggest this in a slightly different way... > > We want to take a configuration file in some format and turn it into > something easily executed by a filter program. That gives us: > > Config file -> Intermediate format -> Parser program > > What the intermediate format is, isn't critically important to most > users. I guess at the moment it's a list of dictionaries or > something? At the moment it's a list of tuples where each tuple contains all the data for one rule. It's a list because that way the order of the rules in the file is maintained. We search it sequentially in FilterParser.firstmatch(). > Or perhaps it is more proceedural and isn't easily represented as > data. No matter. I've been thinking about it being objects -- each rule gets turned into a Python object as it is parsed. ToFromFile, ToFromCDB, etc. Each of those objects is, again, in a list and the list can be pickled to disk. It's an intermediate format, however, it's not really editable. > Let's further suppose that the config file is exactly as it is now, > but we choose to make the intermediate format Python code instead of > data. I'm going to guess that it would not take an amazingly > sophisticated piece of code to convert one into the other. What I'm pursuing right now is a lex and yacc-like system for Python. I wanted to learn this stuff from the inside out, so I've begun writing these. The interesting thing is that the intermediate format can be pretty easily changed when these types of tools are used, which would not be true if we wrote another hard-coded parser that could only spit out Python. So we could generate objects (my first idea) or we could write Python code to disk. We could probably do both and play with it a bit. > Now we're precompiling config files into executable code. The user > is none-the-wiser. Right. In no case should they ever have to know how we handle this behind the scenes, as long as they can easily config their system. Tim _________________________________________________ tmda-workers mailing list ([EMAIL PROTECTED]) http://tmda.net/lists/listinfo/tmda-workers
