Next: Initializing locations in the stack, Previous: Maintaining the stack, Up: Maintaining the stack [Contents][Index]
If an implementation applies Libmarpa’s step instructions literally, using a physical stack, it must make sure the stack is large enough. Specifically, the application must do the following
MARPA_STEP_TOKEN
steps,
ensure that location
marpa_v_result(v)
exists.
MARPA_STEP_NULLING_SYMBOL
steps,
ensure that location
marpa_v_result(v)
exists.
MARPA_STEP_RULE
steps,
ensure that stack locations from
marpa_v_arg_0(v)
to
marpa_v_arg_n(v)
exist.
Three aspects of these requirements deserve special mention.
First,
note that the requirement for a
MARPA_STEP_RULE
is that the application
size the stack to include the arguments to be
read.
Because stack writes may be optimized away,
an application,
when reading,
cannot assume
that the stack was
sized appropriately by a prior write.
The first access to a new stack location may be
a read.
Second,
note that there is no explicit requirement that
the application size the stack to include the
location for the result of the
MARPA_STEP_RULE
step.
An application is allowed to assume that
result will go into one of the locations
that were read.
Third, special note should be made of the requirement that location 0 exist. By convention, the parse result resides in location 0 of the stack. Because of potential optimizations, an application cannot assume that it will receive a Libmarpa step instruction that either reads from or writes to location 0.