python bytecode grammar
Terry Reedy
tjreedy at udel.edu
Sun Jun 12 16:11:59 EDT 2005
"Peter Dembinski" <pdemb at gazeta.pl> wrote in message
news:874qc3inla.fsf at hector.domek...
> "Terry Reedy" <tjreedy at udel.edu> writes:
>> I believe the top-level production is something like
>> BYTECODE := (OPCODE ARGS)*
>
> ROTFL :)
Glad to make your day ;-)
I am aware that since ARGS depends on OPCODE, the above would lead to
context-dependent productions for ARGS. Upon thoroughly perusing
http://docs.python.org/lib/bytecodes.html
18.10.1 Python Byte Code Instructions
I discovered that there is at most one (non-stack) argument in the byte
stream (contrary to the possibly plural implication of "All of the
following opcodes expect arguments"). So the above could be written
context-freely as
BYTECODE := (NO_ARG_CODE | ARG_CODE TWO_BYTE_ARG)*
where the symbolic expansions of NO_ARG_CODE and ARG_CODE, with semantic
explanations, constitute the contents of the doc above.
Terry J. Reedy
More information about the Python-list
mailing list