gpulost / lepl

Automatically exported from code.google.com/p/lepl
Other
0 stars 0 forks source link

infinite loop in case of block related grammar #20

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Please run the attached program. It causes lepl to go into infinite loop.

This is due to line containing "vwx yz" - indent it by 4 more spaces and it 
will work.

But if the grammar is incorrectly defined, then I would expect an error.

Original issue reported on code.google.com by wrob...@gmail.com on 12 Dec 2011 at 7:56

Attachments:

GoogleCodeExporter commented 9 years ago
thanks.  i agree that shouldn't loop.  unfortunately i am travelling at the 
moment, but i will try look at this when i return.  andrew

Original comment by a.cooke....@gmail.com on 12 Dec 2011 at 8:02

GoogleCodeExporter commented 9 years ago
hi, it just struck me what is happening here.  i can't test it, but i am pretty 
sure that it's because of nested "*" repeats (0 or more).  so the infinite loop 
is that zero matches is being repeated many times.

in other words, to fix, try changing all or some of the "[:]" to be "[1:]".

hope that makes sense,
andrew

Original comment by a.cooke....@gmail.com on 12 Dec 2011 at 10:00

GoogleCodeExporter commented 9 years ago
changing ``block`` definition to

    block = Block(statement[1:])

indeed helps

Original comment by wrob...@gmail.com on 12 Dec 2011 at 11:35

GoogleCodeExporter commented 9 years ago
it'a a known issue that this kind of problem should be detected, but it's a 
hard problem and won't happen soon.  i am closing this as won't fix because the 
particular issue here is resolved (even though a better solution for detecting 
and warning for infinite loops is still needed).

Original comment by acooke....@gmail.com on 1 Jan 2012 at 10:58