LUA parser example, timing issues?
An LR(1) parser with a pythonic interface
Brought to you by:
rstuart
I'm getting strane behavior from a LUA script I made. I simplified the problematic case to this:
local function test_dissector(payload)
if (true) then
add_le (payload)
add_le (payload)
else
add_le (payload)
end
end
When I try to parse this on my machine, I'm usually getting:
Error: line 6 column 5: Got unexpected 'else' while trying to match function_call_st or prefix_exp in state 51
Except that sometimes, like once every 20 runs, it just succeeds and generates the tree.
Attached the exact scripts I use for my repro.
# uname -a
MINGW64_NT-6.1 2.11.2(0.329/5/3) 2018-11-26 09:22 x86_64 Msys
# python3 --version
Python 3.7.1
# pip3 list | grep lrparsing
lrparsing 1.0.13
# ./aaa.py
parser generation done
Error: line 6 column 5: Got unexpected 'else' while trying to match function_call_st or prefix_exp in state 51
#
Just noticed that using pre-compiled grammar fixes the issue. So a bug might be in
compile_grammar(), not in the actual parsing.