For background, I am currently writing tests for my first steps at a
Tcl binding to libmarpa. I am actually far enough that the code is
able to read a SLIF specification, incidentially of SLIF itself.
However with the tests I am running the lexer into a wall and I am
quite unsure what I am doing wrong.
Symbols are 0-7, except 2.
Start symbol is 7.
Rules are
7 -> 5 3
7 -> 6 4
3 -> 0
4 -> 1
With a newly created recognizer the session/sequence of operations is
start-input
expected-terminals -> 5 6 /ok
alternative 5
alternative 6
earleme-complete /ok
expected-terminals -> 0 1 /ok
alternative 0 /ok
earleme-complete /err: Parse exhausted
The exhaustion could be ok, as the machine has no way forward after
this point.
latest-earley-set -> 1
That seems to be ok as well, assuming we count from 0.
Tring to create the tree (actually the bocage) at that earley-set I
get an error back: 'No parse'.
Yet I believe that the recognizer should have a parse tree / bocage at
earley-set 1, of the form
7
/ \
5 3
\
0
So now I am wondeing where my reasoning is wrong.
My best speculation at the moment is that the second earleme-complete
should not throw an error, that the latest-early-set should be 2.
I.e. that earley-set 0 maps to the empty string, set 1 is for the
first symbol set {5,6}, and set 2 should have been made for the
singleton set {0}.
I should say again that the lexer code works fine in a larger context,
a full parser for SLIF specifications.
A difference there seems to be that in that context 'earleme-complete'
never throws an 'Parse exhausted', but a following explicit query
about exhaustion (marpa_r_is_exhausted) can return true.
This might fit with my speculation.
It does not explain the difference in behaviour however :(
Time to sleep, maybe I can see it better tomorrow. Or then work
through the methods for more introspective calls I could make to
understand the engine's state better.
--
Sincerely,
Andreas Kupries <
akup...@shaw.ca>
<
http://core.tcl.tk/akupries/>
Tcl'2016, Nov 14-18, Houston, TX, USA.
http://www.tcl.tk/community/tcl2016/
-------------------------------------------------------------------------------