Next: , Previous: , Up: Maintaining the stack   [Contents]

17.4.1 Sizing the stack

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

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.