From: William D. <wdo...@us...> - 2006-09-12 18:05:49
|
Update of /cvsroot/flexml/flexml In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv30895 Modified Files: flexml.pl skel Log Message: Add code and tests that allow a user to specify a header file on the flexml command line, using -h, to be included in the %{...%} section of the generated .l file. Closes sourceforge bug #1526054. Index: skel =================================================================== RCS file: /cvsroot/flexml/flexml/skel,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- skel 29 Aug 2006 21:54:37 -0000 1.37 +++ skel 12 Sep 2006 18:05:45 -0000 1.38 @@ -153,6 +153,9 @@ #define ENTITYTEXT(T) \ { char *s = (T), *e = s+strlen(s);\ while (--e >= s) { unput(*e); }} + +FLEXML_INCLUDE_INIT_HEADER + %} /* Flex standard options. */ Index: flexml.pl =================================================================== RCS file: /cvsroot/flexml/flexml/flexml.pl,v retrieving revision 1.59 retrieving revision 1.60 diff -u -d -r1.59 -r1.60 --- flexml.pl 30 Aug 2006 14:37:02 -0000 1.59 +++ flexml.pl 12 Sep 2006 18:05:45 -0000 1.60 @@ -59,6 +59,7 @@ my $stacksize=100000; # -b option flag my $tagprefix=""; # -P option flag my $actbin="./flexml-act"; # -T option content +my $init_header=""; # -i option string my $header; # -H option flag/content my $dummy; # -D option flag/content @@ -519,8 +520,9 @@ # Parse options. -$Use = "Usage: flexml [-ASHDvdqnLXV] [-s skel] [-T actbin] [--sysid sysid] [-p pubid] [-u uri]\n" - . " [-b stack_increment] [-r roottags] [-a actions] [-P prefix] name[.dtd]"; +$Use = "Usage: flexml [-ASHDvdqnLXV] [-s skel] [-T actbin] [--sysid sysid] " + . "[-p pubid] [-u uri] [-i init_header]\n" + . " [-b stack_increment] [-r roottags] [-a actions] [-P prefix] name[.dtd]"; sub show_version { @@ -571,6 +573,9 @@ "pubid|p=s" => \$pubid, "sysid=s" => \$sysid, + # name of header file to be included in initial section of generated .l file + "init_header|i=s" => \$init_header, + # What to generate "header|H:s" => sub { $header = $_[1] || 'true' }, "dummy|D:s" => sub { $dummy = $_[1] || 'true' }, @@ -1257,6 +1262,13 @@ } } + elsif ( /^FLEXML_INCLUDE_INIT_HEADER$/ ) { + if ($init_header) { + print "/* User-supplied header */\n"; + print "#include \"$init_header\"\n"; + } + } + elsif ( /^FLEXML_FLEX_OPTIONS$/ ) { print "%option yylineno\n" if $lineno; @@ -1738,6 +1750,7 @@ [B<-ASHDvdnLXV>] [B<-s>I<skel>] [B<-p>I<pubid>] +[B<-i>I<init_header>] [B<-u>I<uri>] [B<-r>I<rootags>] [B<-a>I<actions>] @@ -1839,6 +1852,12 @@ Sets the document type to be C<PUBLIC> with the identifier I<pubid> instead of C<SYSTEM>, the default. +=item B<--init_header> I<init_header>, B<-i> I<init_header> + +Puts a line containing C<#include "init_header"> in the C<%{...%}> section +at the top of the generated .l file. This may be useful for making various +flex C<#define>s, for example C<YY_INPUT> or C<YY_DECL>. + =item B<--sysid>=I<sysid> Overrides the C<SYSTEM> id of the accepted DTD. Sometimes usefull when your |