Perfectly on topic. Made me wonder whether this was really
comp.programming.literate. Anyhow:
> I'm relatively new to the literate-programming scene, but I am very
> pleased to have found it. `Hey, I didn't know other people thought like m=
e!'
> Anyway, I'm using CWEB (e.g. This is CTANGLE (Version 3.3 [p11])), and
> there are some things that I'd like all yous guys expertise on (yes
> I have browsed the FAQ, if it was there, I apologize).
>
> =09- How can I easily (without webbifying it) include header files
> =09 in my prints? Nicely formatted, but without using something
> =09 like c2latex because I want it to be formatted just like
> =09 the rest of the source.
CWEB can output to different file, I believe, by specifying chunks
like
@(filename.h>=3D
something...
Note that this is an opening paren, and a closing angle. Pretty.
(Perhaps they by now allow closing parens as well, but I won't
guarantee it).
> =09- How can I easily include yacc and lex sources? I'm currently
> =09 working on a project that involves web, yacc and lex sources
> =09 (everything is in C yet there is no .c file in the tree :)),
> =09 and I'd like to do yacc and lex in the same way. I realize
> =09 I'll probably have to use a completely different system (not
> =09 CWEB, but e.g. YWEB if it exists :)), which I presume exists,
> =09 but how can I make this look just like the rest of the sources?
> =09 i.e. I want the nice sectioning, the same formatting etc.
> =09 as I have with the rest.
You might just try it. If %% and similar throws CWEAVE off the track,
remember that chunks are formatted individually, so you can put just
the barest necessities in the %% chunks, and the C code in other
chunks. There are possibilities of hiding things from the CWEAVE
parser as well, I believe.
Personally, I prefer using language-independent LP variants like
noweb, as they allow me to mix shell scripts, C yacc and whatever in
the documentation of one project. I usually indent my source code
understandably, anyhow, and having to fight the pretty-printer until
he comes up with something I can tolerate is wasted time unless you
happen to want to *publish* your results and *want* that particular
look for them.
--
David Kastrup Phone: +49-234-700-5570
Email: d...@neuroinformatik.ruhr-uni-bochum.de Fax: +49-234-709-4209
Institut f=FCr Neuroinformatik, Universit=E4tsstr. 150, 44780 Bochum, Germa=
ny
> - How can I easily (without webbifying it) include header files
> in my prints? Nicely formatted, but without using something
> like c2latex because I want it to be formatted just like
> the rest of the source.
I don't think I've really understood that problem here.
> - How can I easily include yacc and lex sources? I'm currently
> working on a project that involves web, yacc and lex sources
> (everything is in C yet there is no .c file in the tree :)),
> and I'd like to do yacc and lex in the same way. I realize
> I'll probably have to use a completely different system (not
> CWEB, but e.g. YWEB if it exists :)), which I presume exists,
> but how can I make this look just like the rest of the sources?
> i.e. I want the nice sectioning, the same formatting etc.
> as I have with the rest.
Use noweb or nuweb. They are language-independent and their output
looks somewhat different than plain (c)web, but they should solve your
problems.
I personally use noweb. While it won't do any fancy syntax
highlighting, but then it allows to use a source level debugger on the
noweb files directly. And of course, both noweb and nuweb are
language independent.
Ben
--
Ben(edikt)? Stockebrand Runaway ping.de Admin---Never Ever Trust Old Friends
My name and email address are not to be added to any list used for advertising
purposes. Any sender of unsolicited advertisement e-mail to this address im-
plicitly agrees to pay a DM 500 fee to the recipient for proofreading services.
: > - How can I easily (without webbifying it) include header files
: > in my prints? Nicely formatted, but without using something
: > like c2latex because I want it to be formatted just like
: > the rest of the source.
: I don't think I've really understood that problem here.
: > - How can I easily include yacc and lex sources? I'm currently
: > working on a project that involves web, yacc and lex sources
: > (everything is in C yet there is no .c file in the tree :)),
: > and I'd like to do yacc and lex in the same way. I realize
: > I'll probably have to use a completely different system (not
: > CWEB, but e.g. YWEB if it exists :)), which I presume exists,
: > but how can I make this look just like the rest of the sources?
: > i.e. I want the nice sectioning, the same formatting etc.
: > as I have with the rest.
: Use noweb or nuweb. They are language-independent and their output
: looks somewhat different than plain (c)web, but they should solve your
: problems.
You cold also use fweb which has modes for C, fortran, and verbatim
(i.e. language independet) code. That might fit all bills.
Of course, nuweb is smaller and closer to latex in a way, but you loose
pretty printing and indexing of source code. Stefan
: I personally use noweb. While it won't do any fancy syntax
: highlighting, but then it allows to use a source level debugger on the
: noweb files directly. And of course, both noweb and nuweb are
: language independent.
: Ben
: --
: Ben(edikt)? Stockebrand Runaway ping.de Admin---Never Ever Trust Old Friends
: My name and email address are not to be added to any list used for advertising
: purposes. Any sender of unsolicited advertisement e-mail to this address im-
: plicitly agrees to pay a DM 500 fee to the recipient for proofreading services.
--
==========================================================================
Stefan A. Deutscher, s...@utk.edu, (001)-423-[522-7845|974-7838|574-5897]
home^ UTK^ ORNL^
==========================================================================
If there is software you'd like to have in a native OS/2 version, visit
the: OS/2 E-mail Campaign Page http://www.andrews.edu/~boyko/email.html
--------------------------------------------------------------------------
|> ... I'm using CWEB (e.g. This is CTANGLE (Version 3.3 [p11])), ...
|>
|> - How can I easily (without webbifying it) include header files
|> in my prints? Nicely formatted, but without using something
|> like c2latex because I want it to be formatted just like
|> the rest of the source.
You can't prettyprint the header file without passing it through CWEAVE.
The standard solution would be to generate the header file from a CWEB file,
either a separate one or (preferably) the same file that generates the
actual implementation. I guess that is what you call webbifying. It is not a
difficult task; take an existing header file, add `@ @c' or maybe better
something like `@ @( header.h @>=' as a first line, and basically you should
be done. In practice there may be a bit more work: very large header files
might break CWEAVE's memory limits unless you intersperse a few more such
lines to bound the size of individual sections; if there are comments in the
header file they might need some adaptation to prevent TeX from choking; and
while webbifying you might want to take the opportunity to actually add some
explanation to the header file. But all in all the effort should be small.
If you really want to retain the header file exactly as it is, you could
take a copy, pass it through CWEAVE after the mentioned adaptations, then
edit the resulting TeX file to allow for inclusion by \input into some part
of your other web files. You would have to strip a few things at the
beginning and end, and take some measures to prevent a conflict of section
numbers (which CWEAVE hard codes in its output). I would not advise this
approach, which is more work and only has drawbacks w.r.t. the one above.
|> - How can I easily include yacc and lex sources? I'm currently
|> working on a project that involves web, yacc and lex sources
|> (everything is in C yet there is no .c file in the tree :)),
|> and I'd like to do yacc and lex in the same way. I realize
|> I'll probably have to use a completely different system (not
|> CWEB, but e.g. YWEB if it exists :)), which I presume exists,
|> but how can I make this look just like the rest of the sources?
|> i.e. I want the nice sectioning, the same formatting etc.
|> as I have with the rest.
There is no tool like YWEB, yet, but I agree that there should, and maybe
someday, if I can find the time, I shall write one (by adapting CWEBx),
because I have a need for it on several projects. The output will never look
entirely similar to CWEB, because grammar rules are simply different, but for
the C-code of actions one would of course want the same formatting. The
reason I have never done a quick-and-dirty implementation (which would not
be very hard) is that I believe it deserves some special design, particular
to the fact that yacc-files give a specification on two different levels:
the grammar itself and the actions attached to it. A good system should
allow you to specify and document the grammar separately, without
interference of any actions, and then attach actions to them elsewhere.
Inserting module references like @< Action for rule such-and-so @> into the
grammar part is not an ideal solution, because then the rule itself will be
out of sight where the action is specified. My idea is that rules have a
function similar to that of module names in ordinary CWEB, in that they
provide information that provides a bridge between (at least) two locations
in the source file, and they should be fully expanded and identical in both
places. A difference is that module names only serve to enlighten humans,
and are never seen by the compiler, whereas `yacc' does have to see the
grammar rules; therefore some newly designed functionality is needed, and
simply using some existing (language independent) LP-tool will not give this
to you.
As for `lex', I don't care, because I never use it. Hand-writing a lexical
analyser gives you much more flexibility in designing and documenting it
then you would ever get using `lex', and with hardly any more effort
(especially if you have an existing basic analyser to start from, providing
such functionality as recognising and hashing identifiers that is almost
always needed). In any case the problem is similar to that that of `yacc'
(except that non-trivial regular expressions will remain unreadable, no
matter what kind of formatting is used); I would encourage anybody
willing to write LEXWEB to do so.
While no LP-tool designed for parser generators exists, I use the following
practical solution: I try to make each action as small as possible,
preferably no more than one line, in order to keep the grammar as clean as
possible, so that it will be fairly readable without any special formatting.
This does require lots of functions (local to the parser) to perform any
non-trivial actions. Those functions can be written and documented in a
separate CWEB file, whose .c output is not separately compiled, but rather
#include-d in the heading part of the yacc file. If the grammar is not
self-evident, and requires a literate explanation (as is often the case),
then a language independent LP-tool can be used to produce it.
Marc van Leeuwen
CWI, Amsterdam | What hath man wrought
http://www.cwi.nl/~maavl/ | for the year naughty-naught?
> - How can I easily (without webbifying it) include header files
> in my prints? Nicely formatted, but without using something
> like c2latex because I want it to be formatted just like
> the rest of the source.
You can have multiple output files (e.g. foo.c and foo.h) from one
web-file. So instead of including your header-files into the
web-file, you write them using web. As for existing header files:
there is c2cweb (or somesuch) for webbifying --- I don't think you
could do without.
> - How can I easily include yacc and lex sources? I'm currently
> working on a project that involves web, yacc and lex sources
> (everything is in C yet there is no .c file in the tree :)),
> and I'd like to do yacc and lex in the same way. I realize
> I'll probably have to use a completely different system (not
> CWEB, but e.g. YWEB if it exists :)),
Close. FWEB (currently 1.53, I think) could do the trick --- it comes
with modes for several different languages (FORTRAN, RATFOR, C, C++,
TeX) and also with a language-independent mode for all other languages
(you obviously wont get pretty-printing on your lex and yacc code, but
at least the C-code will be typeset nicely).
Or you could use one of the many language independent tools, most
prominently among them noweb and nuweb. They can handle pretty much
any language, but your loosing on things like automatic index
generation and pretty-printing (well, this isn't strictly true for
noweb, but that's a different story).
I personally use FWEB, but would go for noweb if I didn't.
> Thanks for any answers, having prints without big chunks of the rest of
> the system isn't very complete :). (And including them unformatted, or
> differently formatted, is worse than nothing, of course.)
Nah. Documentation is like sex: if it's good, it's really good. If
it's bad, it's better than nothing!
Hope this helped (although I fear it wasn't quite what you wished
for).
Sven
--
_________ ____ /----------------------------------------------------------/
/___ __o/ /_ _/ / Sven Utcke phone +49 40-7718-2181 /
/ / _ // / TU Hamburg-Harburg fax +49 40-7718-2911 /
/ / // // / Technische Informatik I mailto:ut...@tu-harburg.d400.de /
/ / // _//_ / Harburger Schloss-Str.20 http://www.ti1.tu-harburg.de/ /
/_/ // /___/ / D-21079 Hamburg, Germany ------------ ~utcke/utcke.html -/
> I personally use noweb. While it won't do any fancy syntax
> highlighting, but then it allows to use a source level debugger on the
> noweb files directly.
So, of course, do CWEB and FWEB (although apparently with some trouble
if you are programming in FORTRAN).
> And of course, both noweb and nuweb are language independent.
FWEB apparently also has a language independent mode.
Greetings