From: Etienne G. <et...@is...> - 2002-04-23 20:31:00
|
<only Paul> Hi Paul <only Ben> Hi Ben <only sf> Hi Octave-Smiths </only> I've worked a little bit on "some sort of a preprocessor" that allows to maintain many .m files with a single template. The idea is that many functions with different synopsis and nearly the same internals would be easier to maintain : >From pki...@ja... Fri Apr 19 19:36:53 2002 # Maybe we could have three separate internal routines, one for each case? # If you want to go that route, I suggest keeping a single source file with # some sort of preprocessor markup and use make to generate the actual # functions that get installed. I don't think we can use the C preprocessor # because it needs to understand identifiers and strings, so we would have to # invent our own. I know people have done matlab preprocessors in the past # (me included) but I can't find any links at the moment. The preprocessor, called 'fsplit' (you suggest a better name if you like) is really simple. If you put this mail run in a file foo.tpl and and do fsplit foo.tpl it will produce files 'foo_Paul.txt', 'foo_Ben.txt' and 'foo_sf.txt'. When it finds a tag <only sf> All that follows (until the next <only> or </only> tag) goes into the file foo_sf.txt. <only Ben, Paul> Now, this will go to 'foo_Paul.txt' and 'foo_Ben.txt'. </only> And this will go to all files. The name of the input file is trimmed by removing the old suffix, which is indicated by <oldsuffix tpl> The suffix of the new files is indicated by the <newsuffix> tag, like <newsuffix txt> Now, of course, for .m files, one will want <newsuffix m>. Note that tags that are not at the beginning of the line are ignored, so that I can write <newsuffix whatever_I_like>, the suffix is still .txt. And that's it. Does this sound like useful stuff? Etienne PS : I could add some options to facilitate maintainance. I have in mind : fsplit --clean foo.tpl Which only removes the created templates. -- Etienne Grossmann ------ http://www.isr.ist.utl.pt/~etienne |