[Cobolforgcc-devel] MOVE within UNSTRING
Status: Pre-Alpha
Brought to you by:
timjosling
|
From: Steven O. E. <so...@so...> - 2001-08-26 20:12:20
|
Tim, I set up several designs for test cases and coded a few of them. Then I decided to go back and actually start coding the UNSTRING routine. Whew! Nontrivial. The problem lies in preventing excessive looping when the user (COBOL programmer) specifies several, long delimiters. There is a risk of having to set up the problem all over again, one byte at a time, when several delimiters are matching up to a point and then failing, causing the algorithm has to have to backtrack over and over. In order to handle this, I am exploring the Knuth-Morris-Pratt algorithm as discussed in "Introduction to Algorithms", by Cormen, Leiserson, and Rivest (c) 1990 MIT. I have this coded but not yet tested. A slight modification to the KMP algorithm would seem to allow the delimiter-check to ride along the source field in a linear fashion, without backtracking, even with multiple length delimiters. This brings up a few questions. I have no compiler-writing training, and I'm not familiar with your overall design, so perhaps we can discuss this. We talked about MOVE awhile back but I don't think I ever directly asked this: can UNSTRING call the MOVE routine, or must it be coded within UNSTRING itself? If MOVE has been coded and is available, I would like to have the source and headers. If not coded but the call is OK, I will put in a temporary function. If the call is not OK, I will code the move into the UNSTRING function itself. Speaking of function calls, is UNSTRING allowed to call another function at all? The KMP algorithm is best implemented as two functions. One I am coding into UNSTRING itself, but the initial setup should be done by a function called by UNSTRING. Is this OK? If it is OK to use a separate function for setting up the algorithm, then I have another question about how the compiler deals with this, but I'll wait until I hear back from you. Steven |