3
FWEB version 1.62 (September 25, 1998)
5
Based on version 0.5 of S. Levy's CWEB [copyright (C) 1987 Princeton University]
7
@x-----------------------------------------------------------------------------
9
@* STACKS for OUTPUT. The output process uses a stack to keep track
10
of what is going on at different ``levels'' as the modules are being
11
written out. Entries on this stack have a number of parts:
13
\yskip\hang |end_field| is the |tok_mem| location where the replacement
14
text of a particular level will end;
16
\hang |byte_field| is the |tok_mem| location from which the next token
17
on a particular level will be read;
19
\hang |name_field| points to the name corresponding to a particular level;
21
\hang |repl_field| points to the replacement text currently being read
22
at a particular level.
24
\hang |mod_field| is the module number, or zero if this is a macro.
26
\hang |global_Language| is the overriding language for the module and its
29
\hang |Language| is the current language for the module. It will differ
30
from |global_Language| if a language command was encountered in the middle
33
\hang |macro_buf| is the current scratch space for the macro processor;
34
|macro_buf_end| is its end.
36
\yskip\noindent The current values of these nine quantities are referred
37
to quite frequently, so they are stored in a separate place (|cur_state|)
38
instead of in the |stack| array. We call the current values |cur_end|,
39
|cur_byte|, |cur_name|, |cur_repl|, |cur_mod|, |cur_global_language|, and
42
The global variable |stack_ptr| tells how many levels of output are
43
currently in progress. The end of all output occurs when the stack is
44
empty, i.e., when |stack_ptr=stack|.
49
eight_bits HUGE *end_field; // Ending location of replacement text.
50
eight_bits HUGE *byte_field; // Present location within replacement text.
51
name_pointer name_field; // |byte_start| index for text being output.
52
text_pointer repl_field; // |tok_start| index for text being output.
53
sixteen_bits mod_field; // Module number, or zero if not a module.
54
PARAMS global_params,params; // Various flags.
55
eight_bits HUGE *macro_buf, HUGE *mp, HUGE *macro_buf_end;
56
// Current macro buffer.
59
typedef output_state HUGE *stack_pointer;
61
@ Here are the synonyms for the current values of the stack.
63
@d cur_end cur_state.end_field // Current ending location in |tok_mem|.
64
@d cur_byte cur_state.byte_field // Location of next output byte in |tok_mem|.
65
@d cur_name cur_state.name_field // Pointer to current name being expanded.
66
@d cur_repl cur_state.repl_field // Pointer to current replacement text.
67
@d cur_mod cur_state.mod_field // Current module number being expanded.
69
@d cur_language cur_state.language // Current language.
70
@d cur_global_language cur_state.global_params.Language
71
// Global language for this level.
74
@d cur_params cur_state.params // Local flags.
75
@d cur_global_params cur_state.global_params // Global flags.
77
/* Current macro buffer params. */
78
@d macrobuf cur_state.macro_buf
79
@d cur_mp cur_state.mp
80
@d macrobuf_end cur_state.macro_buf_end
84
EXTERN output_state cur_state; /* |cur_end|, |cur_byte|, |cur_name|,
85
|cur_repl|, |cur_mod|, |cur_global_language|, and |cur_language|. */
87
EXTERN long stck_size; // Number of simultaneous levels of macro expansion.
88
EXTERN output_state HUGE *stack; // Dynamic array: Info for non-current levels.
89
EXTERN stack_pointer stck_end; // End of |stack|.
90
EXTERN stack_pointer stck_ptr; // First unused loc.\ in the output state stack.