Michael Jackson wrote:
I am parsing the $CMAKE_BUILD/Docs/cmake.docbook file. There is just
enough information with the tags to parse out all the commands,
variables and properties. What _is not_ in that file are the "reserved
words" or "special arguments" in any _easy_ tags. I can parse the usage
tags and do something like you are doing with the sed scripts and pull
those special words out. (I have to admit that I have only a passing
clue what is going on in those sed statements).
Ah, yes, I see. Looks about equally reliable compared to what I am
doing, perhaps slightly more so due to better separation of the usage
sections, but I'm betting the text help comes from the markup anyway, so
the style of parsing I'm doing is probably pretty safe.
Not that I can think of any drawbacks to your approach either, except
that it would be harder for me to write (having not written SAX parsers
before ;-) ). In a nutshell though, we seem to have similar approaches.
To elaborate on the sed... basically, what I'm doing is extracting
patterns that look like '<command>[(].*[)]' where '<command>' is the
command whose help I am looking at, and the '.*' portion is permitted to
contain newlines. I then split the internal '.*' portion into words,
remove any '][' characters, and extract keywords from the resulting
list, where a "keyword" matches '[[:upper:][:digit:]_]+' (that is,
consists entirely of upper-case letters, digits, and '_', in any
combination).
The XML parser that I wrote is a SAX type (based on Expat) and some
boost stuff for the string processing. If we can convert it to something
that does not depend on the whole of KDE that would probably help us
both, which is what I am interested in.
I'm not sure what KDE dependencies you have; my script needs only: bash,
sed, awk, wc, and cmake (and rm is nice but not strictly required). IOW,
other than cmake itself, it needs no libraries, no compiler, and nothing
a non-broken Linux system would be without, and would probably be fine
on any reasonable POSIX system with bash and GNU sed.
As I said before, if my code proves useful I would be happy to give it
to the KDE project for their use. The Boost project will also want to
use it as I am brining the CMake build system up to date for that
project also.
Ah, competing code :-). I could also donate my script; part of it is
devoted to extracting and replacing the lists in cmake.xml, but the
parts that generate the lists output simple line-delineated text files.
I think it would be beneficial to work together on this. My only
comment on a shell script is that it wouldn't work directly on windows
without MSys or Cygwin installed.
True, but I'm not sure an XML-parsing library is a "lighter" dependency
than bash. Besides, you don't need to /run/ it on Windows anyway :-).
Should I post the whole script?
--
Matthew
Please do not quote my e-mail address unobfuscated in message bodies.
--
Sendmail administration is not black magic. There are legitimate
technical reasons why it requires the sacrifice of a live chicken.
-- Unknown
_______________________________________________
CMake mailing list
[email protected]
http://www.cmake.org/mailman/listinfo/cmake