The FWEB processors perform their work in several distinct phases. (The following is somewhat technical. Scan it, then use it for reference later if necessary.)
FTANGLE has two phases. In phase 1, the source file is read; in phase 2, compilable code is written out in the order specified by the web.
More specifically, phase 1
- discards TeX documentation;
- tokenizes the source;
- expands FWEB preprocessor commands such as ‘@#if’ (see Preprocessing);
- expands ‘@'...'’ (see Conversion to ASCII), ‘@"..."’ (see ‘@"’: Convert string to ASCII), and the binary notation ‘0b...’ (see Special considerations for C) [in FORTRAN, also the octal notation ‘0...’ and the hexadecimal notation ‘0x...’];
- stores code text in appropriate modules;
- memorizes macro definitions (‘@d’ and ‘@m’) (see ‘@d’: Define outer macro, and mark and ‘@m’: Define FWEB macro, and mark).
Phase 2
- outputs outer macro definitions (‘@d’);
- outputs the unnamed module (‘@a’);
- expands FWEB macros (‘@m’);
- expands built-in macros such as ‘$IF’ or ‘$PI’ (see Built-in functions);
- translates RATFOR statements (see RATFOR).
FWEAVE has three phases. In phase 1, the source file is read and cross-reference information is collected. In phase 2, the source file is read again, then pretty-printed with some cross-reference information. (For discussion of pretty-printing, see Pretty-printing.) In phase 3, an automatically-generated Index, List of Modules, and Table of Contents are written.
More specifically, phase 1
- tokenizes and stores identifiers and module names;
- collects cross-reference information (including, in C and C++, the scanning of ‘#include’ files for ‘typedef’ and/or ‘class’ declarations (see ‘-H’: Scan C/C++ include files (FWEAVE));
- stores limbo text definitions made with ‘@l’ (see ‘@l’: Specify limbo text);
- collects information about overloaded operators (‘@v’) and identifiers (‘@W’). See ‘@v’: Overload operator and ‘@W’: Overload identifier.
Phase 2
- outputs limbo text;
- outputs special TeX macros for overloaded operators;
- copies TeX material directly to output;
- treats material between vertical bars (‘|...|’) as code to be typeset;
- tokenizes and stores contents of each code section;
- analyzes code syntax and converts it to appropriate TeX macros.
Phase 3 writes out cross-reference information. (To eliminate some of that, see ‘-x’: Eliminate or reduce cross-reference information (FWEAVE)..) Specifically, it
- writes out the Index (INDEX.tex by default, but see Output files and Customizing FWEAVE’s index);
- writes out a list of named modules (MODULES.tex by default, but see Output files and Customizing the module list);
- writes out macros to generate the Table of Contents. (Table of Contents information is actually processed by LaTeX, not FWEAVE. The information is written to the aux file.)