Today's Page Hits: 92
I have more hair and it isn't so grey. :->
This page validates as XHTML 1.0, and will look much better in a browser that supports web standards, but it is accessible to any browser or Internet device. It was created using techniques detailed at glish.com/css/.
Okay, the amount of delta turns out to be small to getting working code. I spent more time thinking about things. I tried putting the '(' code handling into the RHS and struggled with what node do I attach it to? I understood why for the LHS case it went to si, but after I created some new storage, I could not figure out how I knew si already had 2 children allocated.
Consider (path == /db) && (ext == jpg). From just doing the '(' code from the LHS, I knew there was no way that I had a correct si to attach the LHS ((ext == jpg)). Which is when I looked for where I had the correct code, which was in the get_compound state. And once I realized that, I realized I could keep the get_lhs focused on just handling data. The changes I had to make were in the OP code:
case ('|') :
/*
* Rewind so that the compound operator can handle this correctly.
*/
if (*expression-- != '|') {
fprintf(stderr,
...
}
goto get_compound;
case ('&') :
/*
* Rewind so that the compound operator can handle this correctly.
*/
if (*expression-- != '&') {
..
}
goto get_compound;
This also means that I only have to worry about '!' and '(' in the get_lhs state. This code may not be what a generator would have produced and it may make me groan when I come back to it, but it works.
Anyway, the current set of tests pass:
1, 16, 64000 (path == /db) 2, 16, 64000 !(path == /db) 3, 16, 64000 path == /db && ext == jpg 4, 16, 64000 path == /db && ext == jpg || ext == jpeg 5, 16, 64000 (path == /db && ext == jpg) || ext == jpeg 6, 16, 64000 path == /db && (ext == jpg || ext == jpeg) 7, 16, 64000 path == /db 8, 16, 64000 (path == /db && ext == jpg) || (path != /db && ext == jpeg) 9, 16, 32000 (path == /db && ext == jpg) 10, 16, 32000 !(path == /db && ext == jpg) % cat tests/parens.txt 1, 16, 64k, (path == /db) 2, 16, 64k, !(path == /db) 3, 16, 64k, path == /db && ext == jpg 4, 16, 64k, path == /db && ext == jpg || ext == jpeg 5, 16, 64k, (path == /db && ext == jpg) || ext == jpeg 6, 16, 64k, path == /db && (ext == jpg || ext == jpeg) 7, 16, 64k, path == /db 8, 16, 64k, (path == /db && ext == jpg) || (path != /db && ext == jpeg) 9, 16, 32k, (path == /db && ext == jpg) 10, 16, 32k, !(path == /db && ext == jpg)
I need to go back and strip out all of the debug printfs, fix the storage of data in the get_rhs state, finish off the command line processing, etc. All of which needs to be done before I write the evaluation code. And that will be the real test case. I also need to add a new command line option to just verify the input. I've basically done that with the attribute-expression parsing, but I'd like a mode which does not load into the "global" set of policies. Note, I am thinking about the final product here.
Also, the code assumes that all id's are unique. If I were to have multiple ids in my rules-files, they would just load. BTW: I need to start calling it my policies-file. I think what I want to do in the final product is treat the loading of a policies-file to be atomic. To that end, they would load into a local list (which now has to become a parameter) and a warning would be spit out if there were duplicate ids. Only when the policies are all loaded correctly would the local copy be merged with the global one. And at that point, there would be no warnings about duplicates.
The latest code is at: speadm.c and speadm.h.