/* Copyright (c) 1979 Regents of the University of California */
* pi - Pascal interpreter code translator
* Charles Haley, Bill Joy UCB
* Version 1.1 February 1978
* pxp - Pascal execution profiler
* Version 1.1 February 1978
* TREE SPACE DECLARATIONS
* The variable space is the
* absolute base of the tree segments.
* (exactly the same as ttab[0].tr_low)
* Spacep is maintained to point at the
* beginning of the next tree slot to
* be allocated for use by the grammar.
* Spacep is used "extern" by the semantic
* The variable tract is maintained to point
* at the tree segment out of which we are
* allocating (the active segment).
* TREENMAX is the maximum width
* in words that any tree node
* due to the way in which the parser uses
* Inittree allocates the first tree slot
* and sets up the first segment descriptor.
* A lot of this work is actually done statically
ttab
[0].tr_high
= &space
[ITREE
];
* Tree builds the nodes in the
* parse tree. It is rarely called
* directly, rather calls are made
* to tree[12345] which supplies the
* first argument to save space in
* the code. Tree also guarantees
* that spacep points to the beginning
* of the next slot it will return,
* a property required by the parser
* which was always true before we
* segmented the tree space.
if (p
+TREENMAX
>= tract
->tr_high
)
* save a great number of calls
* Tralloc preallocates enough
* space in the tree to allow
* the grammar to use the variable
* spacep, as it did before the
if (spacep
+ howmuch
>= tract
->tr_high
) {
cp
= malloc(i
* sizeof ( int ));
yerror("Ran out of memory (tralloc)");
if (tract
>= &ttab
[MAXTREE
]) {
yerror("Ran out of tree tables");
tract
->tr_high
= tract
->tr_low
+i
;
* Free up the tree segments
* If there is scanner lookahead,
* i.e. if yylacnt != 0 or there is bottled output, then we
* cannot free the tree space.
* This happens only when errors
* occur and the forward move extends
if (yylacnt
!= 0 || bottled
!= NIL
)
while (tract
->tr_low
> spacep
|| tract
->tr_high
<= spacep
) {
* Copystr copies a token from
* the "token" buffer into the
i
= (strlen(token
) + sizeof ( int )) & ~( ( sizeof ( int ) ) - 1 );
tralloc(i
/ sizeof ( int ));