> Thanks for the feedback. The parser really does need to refer to > large strings, these are descriptions of very large biological > networks with motifs that include thousands of genes, with > potentially tens of thousands total. The parser then turns them into > Systems Biology Markup Language (see http://range.sf.net for code). > But I didn't know that the string could be a file, can you give me a > pointer to some documentation for that?
I did read your follow-up message, and yes, you can use a pointer. The problem is, for each symbol, you will have a different pointer. If you don't allocate memory for it and dereference it, you will certainly get incorrect results and probably a segmentation fault. I can understand that the code in your actions would need to refer to long strings, either in buffers (`char' arrays, C-style strings, C++ `strings', or whatever), but I can't think of any reason why the semantic value of the symbols in your grammar would need to be of any of these types. If there is some reason, a possibility you might want to consider is to use `FILE*' or a pointer to a file descriptor as the semantic value of your symbols. I strongly suspect that a better approach would be to pass an object as a parameter to `yylex' and `yyparse' which contains pointers that reference the files or buffers containing the strings. This is documented in the Bison manual and I have described ways to use it many times on this list, if you want to have a search through. This parameter is passed to `yylex' and `yyparse' in the form of a pointer to `void' and must be cast to the correct type in the actions or in any functions called in the actions. In GNU 3DLDF, I use a type called `Scanner_Type', whereby I usually refer to the "type" `Scanner_Node', which is simply a "typedef" for `Scanner_Type*'. I call the parameter `parameter'. You can find many examples of it's use in my sources: http://www.gnu.org/software/3dldf/LDF.html#Sources I use a `class' type, since I use C++, though I do not generate a C++ parser. I simply generate a C parser and compile using `g++'. If you're using C, you could use a `struct'. You could then use an array, a linked list, a binary tree, or some other data structure to hold the pointers to your character buffers, files, or whatever. Laurence Finston _______________________________________________ help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison