summaryrefslogtreecommitdiff
path: root/xml2ag/xmlopts.def
diff options
context:
space:
mode:
Diffstat (limited to 'xml2ag/xmlopts.def')
-rw-r--r--xml2ag/xmlopts.def180
1 files changed, 180 insertions, 0 deletions
diff --git a/xml2ag/xmlopts.def b/xml2ag/xmlopts.def
new file mode 100644
index 0000000..242a874
--- /dev/null
+++ b/xml2ag/xmlopts.def
@@ -0,0 +1,180 @@
+/* -*- Mode: conf -*- */
+
+autogen definitions options;
+
+// Time-stamp: "2012-04-07 09:05:33 bkorb"
+
+/*
+ * This file is part of AutoGen.
+ * AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
+ *
+ * AutoGen is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * AutoGen is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+export = <<- EOExport
+ #include <sys/types.h>
+ #include <sys/stat.h>
+
+ #ifndef __USE_POSIX
+ # define __USE_POSIX /* for glib's pedantic needs */
+ #endif
+ #ifndef __USE_XOPEN_EXTENDED
+ # define __USE_XOPEN_EXTENDED /* ditto */
+ #endif
+ #include <stdio.h>
+ #include <ctype.h>
+ #include <errno.h>
+ #include <fcntl.h>
+ #include <limits.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <unistd.h>
+
+ #include <libxml/parser.h>
+ #include <libxml/tree.h>
+
+ extern FILE* outFp;
+ #ifndef NUL
+ # define NUL '\0'
+ #endif
+ extern void forkAutogen( char const* pzInput );
+ EOExport;
+
+flag = {
+ name = the-xml2ag-option;
+ documentation;
+ descrip = 'All other options are derived from autogen';
+};
+
+flag = {
+ name = output;
+ value = O;
+ arg-type = string;
+ arg-name = file;
+ descrip = "Output file in lieu of AutoGen processing";
+ doc =
+ "By default, the output is handed to an AutoGen for processing.\n"
+ "However, you may save the definitions to a file instead.";
+
+ flag_code = <<- FLAG_CODE_END
+ if (strcmp(pOptDesc->optArg.argString, "-") == 0)
+ return;
+
+ if (freopen(pOptDesc->optArg.argString, "w", stdout) == NULL) {
+ fprintf(stderr, "Error %d (%s) opening `%s' for output",
+ errno, strerror(errno), pOptDesc->optArg.argString);
+ exit(EXIT_FAILURE);
+ }
+ FLAG_CODE_END ;
+};
+
+flag = {
+ name = autogen-options;
+ documentation = <<- _EODoc_
+ These options are @i{mostly} just passed throug to @code{autogen}.
+ The one exception is @code{--override-tpl} which replaces the
+ default template in the output definitions. It does not get passed
+ through on the command line.
+ _EODoc_;
+
+ descrip = 'All other options';
+};
+
+#define XML2AG
+#option templ-dir $top_srcdir/agen5
+#option templ-dir $top_srcdir/autoopts
+#include opts.def
+
+explain = <<- END_EXPLAIN
+ This program will convert any arbitrary XML file into equivalent
+ AutoGen definitions, and invoke AutoGen.
+ END_EXPLAIN ;
+
+detail = <<- END_DETAIL
+ The template will be derived from either:
+ * the ``--override-tpl'' command line option
+ * a top level XML attribute named, "template"
+
+ The ``base-name'' for the output will similarly be either:
+ * the ``--base-name'' command line option
+ * the base name of the .xml file
+ END_DETAIL ;
+
+prog-man-descrip = <<- END_DETAIL
+ The template will be derived from either:
+ .br
+ * the \fB--override-tpl\fP command line option
+ .br
+ * a top level XML attribute named, "template"
+ .br
+ One or the other \fBmust\fP be provided, or the program will
+ exit with a failure message.
+ .sp 1
+ The ``base-name'' for the output will similarly be either:
+ .br
+ * the \fB--base-name\fP command line option
+ .br
+ * the base name of the .xml file
+ END_DETAIL ;
+
+prog-info-descrip = <<- END_DETAIL
+ The template used will be derived from either:
+ @itemize @bullet
+ @item
+ The @strong{--override-tpl} command line option
+ @item
+ A top level XML attribute named, "@code{template}"
+ @end itemize
+ @noindent
+ One or the other @strong{must} be provided, or the program will
+ exit with a failure message.
+
+ The @emph{base-name} for the output will similarly be either:
+ @itemize @bullet
+ @item
+ The @strong{--base-name} command line option.
+ @item
+ The base name of the @file{.xml} file.
+ @end itemize
+
+ The definitions derived from XML generally have an extra layer
+ of definition. Specifically, this XML input:
+ @example
+ <mumble attr="foo">
+ mumble-1
+ <grumble>
+ grumble, grumble, grumble.
+ </grumble>mumble, mumble
+ </mumble>
+ @end example
+ Will get converted into this:
+ @example
+ mumble = @{
+ grumble = @{
+ text = 'grumble, grumble, grumble';
+ @};
+ text = 'mumble-1';
+ text = 'mumble, mumble';
+ @};
+ @end example
+ Please notice that some information is lost. AutoGen cannot tell that
+ "grumble" used to lie between the mumble texts. Also please note that
+ you cannot assign:
+ @example
+ grumble = 'grumble, grumble, grumble.';
+ @end example
+ because if another "grumble" has an attribute or multiple texts,
+ it becomes impossible to have the definitions be the same type
+ (compound or text values).
+ END_DETAIL ;
+/* end of opts.def */