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


LANGUAGES

@FWEB{} has the ability to work with more than one source 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 (deliberately) 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 the option `-ltext', 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
  • An example of a command with the optional text field is `@n/'. By definition, this is equivalent to `@n[-n/]'. Thus, it both sets the language and invokes a command-line option.

    As another example, `@n9' really means `@n[-n9]'. Thus the language is first set to FORTRAN, then reset to FORTRAN-90. One doesn't need to worry about this detail.

    @n9[-n&]
    

    means set the language to FORTRAN--90 and use free-form syntax with the ampersand as the continuation character. (This construction is now @FWEB{}'s default.)

    The brackets may contain more than one space-delimited option.

    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. For historical reasons, the default language is FORTRAN-77, but do not rely on this; always include a language command.

    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'. Particularly note that one did not need an `@c' command in the last section because the language was C when `@<C@>' was first encountered.

    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. This restriction is not necessarily in accord with the syntaxes of the various source languages. 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

    Items for both FORTRAN-77 and FORTRAN-90

    Items specific to FORTRAN-77 and fixed-form FORTRAN-90

    Items specific to FORTRAN-90

    (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

    Unfortunately, the VERBATIM language is not fully debugged. Therefore, it is not recommended for general use. (To be completed.)


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