![]() Scalar's GP-TRICKS Homepage
A Cross-Referencing Tool for Borland Pascal 7.0I didn't find anything like this for Pascal, though. If you know me and my programming history, you know that this had to be reason enough for me to try and write one. Fortunately, I ran across a discussion of hashing algorithms, either in the DDJ or the CUJ, I don't remember anymore, which presented an excellent hashing method developed by Bob Jenkins. I do not want to discuss my cross-referencer ("CAXREF" for Chaotic Arts Cross Referencer) in depth, because I neither have the time to do it nor the patience to go through my code right now. I will go over the basic structure, though. First of all, the program initializes and checks command line parameters. Then it starts reading the input file. It reads line by line, keeping track of how many are already read. This information, of course, is needed to pinpoint identifiers in the cross-reference to be generated. It splits the lines into individual words, checking for beginnings and endings of either strings (enclosed by apostrophes) or comments (enclosed either by curly braces or by (* *) pairs). If it is in one of these sections, all words found are ignored, just like the Pascal compiler would. The program also ignores Pascal's reserved words; I decided to do so because the main interest in a cross-reference is on variables and types, not on all those "BEGIN"s and "END"s. If, however, a non-reserved word is found that is not inside a string or a comment, the program tries to find it in the hash table. If it is found, the new occurance is added, and the line number and type of usage (declaration, incrementation, assignment, etc.) is stored. If it is not found, a new entry is initialized. Sooner or later, the end of the source file is reached and it is closed. The program then walks through the hash table and writes all the pieces of information that were gathered into the output file. I have included the full source code. Note that the program has to be compiled in DPMI mode, because the memory requirements are huge. You can use the program CAXREF in whatever way you want. I do not assume responsibility for any damage it may cause.
| ||||||