On 5 May 12, at 14:20, Mattias Gaertner wrote: > On Sat, 5 May 2012 14:07:01 +0200 (CEST) > "Tomas Hajny" <xhaj...@hajny.biz> wrote: > > > On Fri, May 4, 2012 21:58, Marco van de Voort wrote: > > > In our previous episode, Tomas Hajny said: > > >> 1) Find the first alphabetic character after the first line (which is > > >> already processed/skipped by InstantFPC anyway) while ignoring all > > >> whitespaces and possible comments (in all allowed formats, i.e. > > >> including > > >> (* *) ) - the only small complexity here are nested comments, but even > > >> that is not so difficult to handle. > > >> > > >> 2) If there is the 'program' keyword, find the semicolon and continue > > >> searching for the next alphabetic character while still ignoring > > >> comments > > >> and whitespaces (to skip possible global compiler directives). > > >> > > >> 3) Write down 'const InstantFPCScriptName = ...;' + LineEnding > > >> immediately > > >> before the found alphabetic character (there should be no need to parse > > >> it). > > > > > > Will cause some "misplaced global compiler switch" if after the program > > > came > > > an {$mode originally. > > > > I don't think so. That's why I suggested skipping all comments in point 1 > > (before 'program') and also point 2 (after 'program' but before anything > > else) above and also mentioned global compiler directives explicitly > > ($mode is obviously one of them). > > You also have to skip the uses section.
Yes, of course, I forgot that one, but that alone wouldn't change it much. > And what about ifdefs? Well, right, ifdefs might make it fairly complex indeed. :-( The proposal from Jonas (temporary unit with -Fa) is obviously a better solution. Tomas _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal