On Nov 19, 2008, at 12:24 PM, Matthew Woehlke wrote:
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.
I can do the initial writing if you want. I have everything in place
to add another generator to the code.
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.
I guess I wasn't really clear. My current code only has an expat and
boost dependency. I took at look at Qt 4.4 and it seems to have the
same type of parser (SAX) that I would need. I can probably replace
the boost string algorithms with something from Qt along with the sort
algorithms. I was going this direction because the generator could be
built/run from a larger build phase of KDE (which I thought was
supposed to compile on windows also) which is why I was trying to stay
as platform agnostic as possible.
I guess my end goal would be for the actual CMake build to
optionally generate these components and maybe host them for downloads
on the CMake web site. This would give the impression that these are
"official" language syntax files produced by CMake. I know the
TextMate is pretty much plug-and-play. The Eclipse XML code may be the
same way although I would need to look into that.
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.
Sorry again. Not Clear. What I _really_ meant to say was that Boost
may have more interest in the future in editors that have good CMake
support as their build system moves toward CMake and away from BJam
(if that ever completely occurs).
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?
Sure. You can post the script on the CMake Wiki or post it here and
I'll get it up on the Wiki really soon. I am going to try and
integrate your sed search algorithms into my generator and see what
happens. I'll also take a look at the Kate syntax xml file and add
that also. I don't have a linux box currently so I'll have to just
validate the xml. Some one else will have to test it.
Unless you have Kate running on OS X...
--
Matthew
Please do not quote my e-mail address unobfuscated in message bodies.
_________________________________________________________
Mike Jackson [EMAIL PROTECTED]
www.bluequartz.net
_______________________________________________
CMake mailing list
[email protected]
http://www.cmake.org/mailman/listinfo/cmake