MarpaX::Simple::Lexer dies with "exhausted"

瀏覽次數:4 次
跳到第一則未讀訊息

Peter Stuifzand

未讀,
2012年4月7日 清晨7:29:122012/4/7
收件者:marpa-...@googlegroups.com
Hi,

I'm not sure why this testcase dies with the message "exhausted".
I created a simple testcase on gist.

My guess is that it $skips++ past the end of the buffer in this part and should call end_input. Can anyone confirm?


--
Peter Stuifzand
http://peterstuifzand.nl

Ruslan Zakirov

未讀,
2012年4月7日 下午3:58:422012/4/7
收件者:marpa-...@googlegroups.com
Hi,

I can reproduce, fixed and pushed. Please test.

Note that there are more changes in the repo then just this fix.

Fix is not complete as it leaves buffer with last token(s) and I'm not
sure yet how deal here.

In most cases it would be ok to skip last token in the buffer and
return. In this situation you
can continue parsing input as buffer is stored in lexer. This is
helpful if you have input with
repeated blocks you parse one by one.

If parser is ambiguos then several tokens may start in the same
position, end in different
positions and result in successful exhaustion. In this case you have
several "correct" parse
trees that end in different positions.

Most probably I will implement cutting buffer with the shortest match.

--
Best regards, Ruslan.

Peter Stuifzand

未讀,
2012年4月8日 清晨5:35:322012/4/8
收件者:marpa-...@googlegroups.com
Thanks for the fix. It works.

I also added another simple case that doesn't work. In a .t file. See the pull request on GitHub.

--
Peter Stuifzand | peterstuifzand.nl | @pstuifzand
回覆所有人
回覆作者
轉寄
0 則新訊息