Go to the first, previous, next, last section, table of contents.


LANGUAGES

FWEB has the ability to work with more than one language during a single run. The language in effect at the beginning of the first section defines the global language. Further language changes within a section have scope local to that section.

Usually, `language' means a compiler language like FORTRAN or C. These languages will be "pretty-printed" by FWEAVE. Pretty-printing can be inhibited by turning on the N mode (globally, with the command-line option `-N'; locally, with `@N') or by selecting the VERBATIM `language'; in both of these cases, the input text is echoed literally to the output of both FTANGLE and FWEAVE.

`Language' is a stronger concept than `mode'. For example, when a language is selected, the extension of the tangled output file is changed appropriately--for example, if `test.web' contains C code (that is, contains the command `@c'), `test.web' tangles into `test.c' (compressing blanks and otherwise making the tangled output relatively unreadable) and FWEAVE pretty-prints using the C syntax. Turning on the N mode does not affect the language; FTANGLE copies the source code literally into `test.c' (no blank compression or other modifications), and FWEAVE typesets the source code within a verbatim environment (no pretty-printing). When the VERBATIM language is selected, the N mode is turned on automatically, but FTANGLE writes its output to a file with a special default extension that can be customized in the style file. See section Miscellaneous style-file parameters.

Setting the language

The most general form of a language command is

@[L]ltext[options]

where l is a language symbol, text is converted into a hyphenated option, and options have the same syntax as on the command line. The language symbols must be in lower case; they are

C          -- c
C++        -- c++
Fortran-77 -- n
Fortran-90 -- n9
Ratfor-77  -- r
Ratfor-90  -- r9
TeX        -- x
VERBATIM   -- v

Thus, for example,

@n9[-n&]

means set the language to FORTRAN--90 and use free-form syntax with the ampersand as the continuation character.

A language command should appear somewhere in limbo, before the start of the first section. The language in effect at the beginning of the first section defines the global language.

Language commands may be used within sections, but the new language remains in force only for that section. The language of a named module is inherited from the language in effect at the time the name is first used. Thus, in the following example, the global language is FORTRAN--77, but an arbitrary number of C functions can be placed into a C-language module with just one `@c' language-changing command.

@n
@ 
@a
        program main
        end

@c
@<C@>@;

@ 
@<C@>=
int fcn()
{}

FTANGLE will write two output files for this example--e.g., `test.f' and `test.c'.

Special hints and considerations for each language

One important thing to keep in mind is that in FWEB an identifier may have, for each language, precisely one meaning throughout the document. See, for example, the discussions in section Special considerations for C++ and section Special considerations for FORTRAN.

Special considerations for C

(To be completed.)

Special considerations for C++

Special considerations for FORTRAN

(To be completed.)

Special considerations for RATFOR

For some warnings about RATFOR, see section Caveats about RATFOR.

Special considerations for TeX

`@Lx' is supported only to the extent that fwebmac.sty can be generated correctly from fwebmac.web. You are welcome to experiment, but you may encounter difficulties (which you should report; see section SUPPORT).

(To be completed.)

Special considerations for the VERBATIM language

Special remarks. (To be completed.)


Go to the first, previous, next, last section, table of contents.