Re: [Parser-devel] [token.c] A new functionality
Status: Beta
Brought to you by:
jineshkj
From: Jinesh K J <jin...@gm...> - 2006-10-10 04:37:36
|
> > I feel like this it too much functionality to be putting into gettoken. > It's true I don't really have much of the big picture, ie how these > functions are going to be used in the library, but I think that > splitting tokens should be a separate task from interpreting those tokens. This is how I thought is gonna work these functions for the library: 1. All the lines in the file will converted to an array of strings 2. cutcomment() operates on a line and extracts/removes the comment part 3. getgroup() checks and extracts the group name if the line represents a group declaration. 4. Lastly, gettoken() will extract each token from the line(if step 3 is failed) till the end of line is reached. All the information obtained is stored in the internal structure called 'entry'. The ability of gettoken() to identify the '=' connected data items together as key/value pair will help very much in reducing the complexity of the function transform() in transform.c. Introducing the additional test for checking the key/value pair is better not to be placed in transform(). So, it need to be done in some other function - if not gettoken(), then something else. I thought since gettoken() has done some much for us, may be we can get this one also be done by it. > > That's what it looks like to me, anyway. I think we can proceed either of two ways: 1. Modify gettoken() as I had mentioned previously to get the key/value pairs too. 2. Write another function getkeyval() that utilise gettoken() to do our job. The prototype I suggested remains the same. Any other option do you think there is? |