Go to the first, previous, next, last section, table of contents.
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.
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'.
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.
(To be completed.)
template <class Type> class A { private: Type *p; }In order that the class definition be typeset correctly, `Type' must be understood to be a reserved word like int, and that is correctly figured out by the first class command. However, according to C++, the scope of `Type' is local to the class definition; however, FWEAVE does not respect that locality and will always treat `Type' as an int from the point of the `class Type' construction to the end of the source code. Thus, one should use `Type' only as a formal template parameter, never as an ordinary variable.
@n @ @m EXIT #:0 @m ABORT #:0 @a . . ABORT: continue . . EXIT: continue . .
\llap
'd from the body of the
statement. With this convention, long labels can extend too far into
the left margin. Instead, try the command-line option `-n:'
(see section `-n:': Put statement label on separate line [FORTRAN]), which puts them on a separate line. Alternatively, one
can redefine the macro \Wlbl
, found with some discussion in
`fwebmac.sty'.
IOSTAT
. The lower-case
forms are not recognized by default. To permit lower case, use
`-k'. See section `-k': Recognize lower-case forms of keywords.
x += y
into x = x + (y)
. To turn off this
feature, use the option `-+'. See section `-+': Don't interpret compound assignment operators.
Notice that in FORTRAN-90 `/=' is a token for "not equal",
so if you want to use that you must use `-+'. This is unnecessary,
however, because in FWEB you can always use `!=' instead.
(To be completed.)
For some warnings about RATFOR, see section Caveats about RATFOR.
`@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 remarks. (To be completed.)
Go to the first, previous, next, last section, table of contents.