From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26784 invoked from network); 3 Jan 2002 06:50:41 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 3 Jan 2002 06:50:41 -0000 Received: (qmail 16361 invoked by alias); 3 Jan 2002 06:50:31 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 16394 Received: (qmail 16350 invoked from network); 3 Jan 2002 06:50:30 -0000 Message-ID: <20020103065028.92120.qmail@web10402.mail.yahoo.com> Date: Wed, 2 Jan 2002 22:50:28 -0800 (PST) From: Felix Rosencrantz Subject: Zsh Completion function generation via XML To: zsh-workers MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii I've progressed a little with the XML to completion function generation. I've written a perl script that parses command help output, and converts that to a simple XML format. (At least simpler than I described before.) This simple format can then be converted to the longer XML format. I've already posted XSLT code to convert that longer format to a completion function. For example, here is a reduced version of help output for GNU troff clone, groff. usage: groff [-abeghilpstvzCENRSUVXZ] [-Fdir] [-mname] [-Tdev] [-ffam] [-wname] [-Wname] [-Mdir] [-dcs] [-rcn] [-nnum] [-olist] [-Parg] [-Larg] [-Idir] [files...] -h print this message -t preprocess with tbl -p preprocess with pic -s preprocess with soelim -Tdev use device dev -mname read macros tmac.name -dcs define a string c as s -rcn define a number register c as n -nnum number first page n -olist output only pages in list -ffam use fam as the default font family -Fdir search dir for device directories -Mdir search dir for macro files -v print version number -z suppress formatted output -Z don't postprocess -a produce ASCII description of output -wname enable warning name -Wname inhibit warning name -E inhibit all errors -V print commands on stdout instead of running them -Parg pass arg to the postprocessor -Larg pass arg to the spooler -U enable unsafe mode -Idir search dir for soelim. Implies -s Using help2simple.pl, you get this simple XML version. The actual command line is part of the output, at the end. (The arguments supplied to help2simple.pl -S -- All single dash flags are single letter flags. -n -- Add flag name to arg, to make argnames unique. -M -- Flags are allowed multiple times on the command line. (comma list) -a -- Says what the normal arguments are. ) And here is the function that was generated. There is definitely a problem with automatic generation of actions, this will require improvement. Currently the way these scripts work is that the flag args are converted into tags that are found in the groff_defines.xml file, which has to be hand-edited. Also, the regular arguments are not handled well. (I didn't add the files arguments.) #compdef groff #Generated by # help2simple.pl -c groff -S -n -M -I -a _files # simple2long.xsl # args.xsl # For details see: # http://www.geocities.com/f_rosencrantz/xml_completion.htm local context state line typeset -A opt_args _arguments \ '-h[print this message]' \ '-t[preprocess with tbl]' \ '-p[preprocess with pic]' \ '-s[preprocess with soelim]' \ '-T-:use device dev:->dev-T' \ '-m-:read macros tmac.name:->name-m' \ '-d-:define a string c as s:->cs-d' \ '-r-:define a number register c as n:->cn-r' \ '-n-:number first page n:->num-n' \ '-o-:output only pages in list:->list-o' \ '-f-:use fam as the default font family:->fam-f' \ '-F-:search dir for device directories:->dir-F' \ '-M-:search dir for macro files:->dir-M' \ '-v[print version number]' \ '-z[suppress formatted output]' \ "-Z[don't postprocess]" \ '-a[produce ASCII description of output]' \ '-w-:enable warning name:->name-w' \ '-W-:inhibit warning name:->name-W' \ '-E[inhibit all errors]' \ '-V[print commands on stdout instead of running them]' \ '-P-:pass arg to the postprocessor:->arg-P' \ '-L-:pass arg to the spooler:->arg-L' \ '-U[enable unsafe mode]' \ '*-I-:search dir for soelim. Implies -s:->dir-I' \ '*:Handling Tag _files:->_files' case $state in "_files");; "arg-L");; "arg-P");; "cn-r");; "cs-d");; "dev-T");; "dir-F");; "dir-I");; "dir-M");; "fam-f");; "list-o");; "name-m");; "name-w");; "name-W");; "num-n");; esac I talk about the steps used to create a function on the web page. http://www.geocities.com/f_rosencrantz/help2simple.htm and more general stuff http://www.geocities.com/f_rosencrantz/xml_completion.htm -FR. __________________________________________________ Do You Yahoo!? Send your FREE holiday greetings online! http://greetings.yahoo.com