lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Wrt Lua PEG, I have a question. The 2007 whitepaper says that test*
(testany, testchar, testset) instructions consume a character of input
on success, and jump to an offset on failure. Through this, the
following would hold up (example uses a testchar):

The pattern:

  testchar 0a -> LABEL1
LABEL2:

would be equivalent with:

  choice LABEL1
  char 0a
  commit LABEL2

With the exception that in the second pattern, there is stack
manipulation, which is inefficient and which the introduction of the
test* instructions optimizes out. That doesn't seem to be the case
anymore, because the test* instruction handling in lpvm.c do not
advance the input pointer.

My questions:
- why is this?
- is this documented anywhere?
- what does a test* instruction optimize now?

Thank you.

KJ