CWEB

From ConTeXt wiki

< The ConTeXt Way | Modules | Bugs and workarounds >

Currenlty m-cweb seems to be broken. Take the wc.tex from the example directory from the cweb distribution (made with cweave wc.w) and you should be able to use it like this:

\usemodule [cweb]

\starttext

\title {Contents} \processCWEBcontents wc \page
\title {Sections} \processCWEBsections wc \page
\title {Sources}  \processCWEBsource   wc \page
\title {Index}    \processCWEBindex    wc \page

\stoptext

but ConTeXt is in an endless loop at:

This is pdfeTeXk, Version 3.141592-1.11a-2.1 (Web2C 7.5.2)
 \write18 enabled.
 %&-line parsing enabled.
 (/opt/texlive/8/texmf/web2c/cp8bit.tcx)
entering extended mode

...

system         : macros of module cweb loaded
(/opt/context/2004.6.26/texmf/tex/context/base/m-cweb.tex
system         : mark CWEBfilename defined [CWEBfilename]
system         : mark CWEBsectiontitle defined [CWEBsectiontitle]
system         : mark CWEBsectionnumber defined [CWEBsectionnumber]
system         : mark CWEBsectiondepth defined [CWEBsectiondepth]
)
fonts          : needs map file: ec-public-lm.map
fonts          : needs map file: original-base.map
systems        : begin file main at line 3
title          : - Contents

What is wrong here?


With the help of Luigi Scarso and Aditya Mahajan I was able to get ConTeXt to compile a file generated with cweave. Here are the steps that I used ---

1. Place the following lines at the beginning of the web file:

   \input m-cweb
   \activateCWEB
   \setupinteraction[state=start]
   \starttext
   

2. Place the following line at the end of the web file:

   
   \stoptext
   

3. Run cweave

4. Remove the line that inputs "cwebmac" (TEXFILENAME is the name of the TeX file generated by cweave)

  There should be a much better way to remove or disable cwebmac but this was quick ;-)
  
  perl -p -i~ -e  'goto LINE if m(\input cwebmac)' TEXFILENAME
  

5. Run ConTeXt with command line (TEXFILENAME is the name of the TeX file generated by cweave)

  texexec --pdf TEXFILENAME

Here is a short example file ---

\input m-cweb
\activateCWEB
\setupinteraction[state=start]
\starttext

@** Hello World.

@c
@
@; int main(void) { printf("Hello World.\n"); return(0); } @** Header Files. @
+= #include @ The end. \stoptext