Re: Include system
- Posted by Chris Bensler <bensler at nt.net> Dec 13, 2006
- 1105 views
Robert Craig wrote: > > I have no objections in principle to this change. > If you (Chris Bensler) would like to do it, I can give you > developer permissions on SourceForge. Maybe you should > let other people on EUforum comment on it first before > you proceed. You might also want to be more specific about the > algorithm before coding it. Since this is a front-end only issue, > someone could make this change without any knowledge > of the C backend. This would be a good exercise for someone > who wants to get familiar with modifying Euphoria under > SVN (subversion) control on SoureForge. > > Regards, > Rob Craig > Rapid Deployment Software > <a href="http://www.RapidEuphoria.com">http://www.RapidEuphoria.com</a> If I were any good at explaining things clearly, I probably wouldn't feel like I have Cassandra Syndrome ;) In my preprocessor, I've implemented the include path search in a fairly different way than the Eu front end is doing it, so my description may not be entirely applicable. Instead of building candidate paths to test if a file will open, as the front end does, my preprocessor pushes and pops the current directory, which makes the actual search algorithm much simpler although admittedly probably slower and more prone to error. I can try though: On program entry, a variable: PROGRAM_PATH stores the program path as described by the second subscript of command_line(). The current directory should not be modified or it will affect CLI/drag 'n drop applications. Another variable: ACTIVE_PATH stores the path to the file that is currently being included. Initially it will be the same as PROGRAM_PATH. 1. When an include file is encountered, build the full path to the file being included. Determine if an absolute path is specified. An absolute path begins with a drive letter designation or a SLASH. Technically, I think it should/could begin with a URL moniker (C:\ , ftp:\\, http:\\, svn:\\, etc) or a SLASH, but Eu doesn't support networked projects. If it is absolute path, then no further searching is needed. Just attempt to open the file, fail if it can't. Proceed to step 2. If it's not an absolute path, then each directory in the include search path must be tried in the following order until the file is successfully opened. (note that I've assumed EUINC is a preparsed list of paths) A) ACTIVE_PATH & SLASH & INCLUDE_FILE B) PROGRAM_PATH & SLASH & INCLUDE_FILE C) EUINC[i] & SLASH & INCLUDE_FILE D) EUDIR & SLASH & include & SLASH & INCLUDE_FILE 2. push the ACTIVE_PATH onto an include_path stack 3. update ACTIVE_PATH to the path we just resolved for the included file. 4. When an include file is finished being processed and is closed, ACTIVE_PATH is popped from the include_path stack, restoring the previously active include directory. Hopefully that covers it. ---- I have to say Rob, I've noticed a change in your disposition/attitude lately since Eu is opensource (as have others) and I like it. I hope you will find that mine has too. Chris Bensler ~ The difference between ordinary and extraordinary is that little extra ~ http://empire.iwireweb.com - Empire for Euphoria