~ubuntu-branches/ubuntu/karmic/fweb/karmic

« back to all changes in this revision

Viewing changes to Web/stacks.hweb

  • Committer: Bazaar Package Importer
  • Author(s): Yann Dirson
  • Date: 2002-01-04 23:20:22 UTC
  • Revision ID: james.westby@ubuntu.com-20020104232022-330ad4iyzpvb5bm4
Tags: upstream-1.62
ImportĀ upstreamĀ versionĀ 1.62

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
@z --- stacks.hweb ---
 
2
 
 
3
FWEB version 1.62 (September 25, 1998)
 
4
 
 
5
Based on version 0.5 of S. Levy's CWEB [copyright (C) 1987 Princeton University]
 
6
 
 
7
@x-----------------------------------------------------------------------------
 
8
 
 
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:
 
12
 
 
13
\yskip\hang |end_field| is the |tok_mem| location where the replacement
 
14
text of a particular level will end;
 
15
 
 
16
\hang |byte_field| is the |tok_mem| location from which the next token
 
17
on a particular level will be read;
 
18
 
 
19
\hang |name_field| points to the name corresponding to a particular level;
 
20
 
 
21
\hang |repl_field| points to the replacement text currently being read
 
22
at a particular level.
 
23
 
 
24
\hang |mod_field| is the module number, or zero if this is a macro.
 
25
 
 
26
\hang |global_Language| is the overriding language for the module and its
 
27
extensions. 
 
28
 
 
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
 
31
of the module.
 
32
 
 
33
\hang |macro_buf| is the current scratch space for the macro processor;
 
34
|macro_buf_end| is its end.
 
35
 
 
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
 
40
|cur_language|.
 
41
 
 
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|.
 
45
 
 
46
@<Typed...@>=
 
47
 
 
48
typedef struct {
 
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.
 
57
} output_state;
 
58
 
 
59
typedef output_state HUGE *stack_pointer;
 
60
 
 
61
@ Here are the synonyms for the current values of the stack.
 
62
 
 
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.
 
68
 
 
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.
 
72
 
 
73
/* Current flags. */
 
74
@d cur_params cur_state.params //  Local flags.
 
75
@d cur_global_params cur_state.global_params //  Global flags.
 
76
 
 
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
 
81
 
 
82
@<Global...@>=
 
83
 
 
84
EXTERN output_state cur_state; /* |cur_end|, |cur_byte|, |cur_name|,
 
85
        |cur_repl|, |cur_mod|, |cur_global_language|, and |cur_language|. */
 
86
 
 
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.