Comments (8)
s/Lookup/Lookahead/
Original comment by [email protected]
on 15 Mar 2009 at 5:50
from lepl.
Hmmm. The above stalls because Lookahead() doesn't consume anything. Whether
or not
that is considered a bug or not, it's not the error I am seeing in my code.
Original comment by [email protected]
on 15 Mar 2009 at 6:49
from lepl.
def test_problem_from_regexp(self):
item = Delayed()
item += item[:]
expr = item & Drop(Eos())
parser = expr.string_parser()
parser('abc')
This is what I am hitting in the regexp code.
Original comment by [email protected]
on 15 Mar 2009 at 6:58
from lepl.
Ah, OK, now it is clearer. The second case is similar to the first, in that
there is
a repeated match that can be empty. This is not a left-recursion issue, it's
just an
error (although one we can perhaps try to detect somehow?).
What was confusing me was that I thought the LMemo (left recursion memoizer)
would
deal with this issue (even if it is not exactly what it is intended for). But
what
happens is that after the left recursion "maxes out" an empty match is
returned. In
a normal left-recursion case the stack can then unwind and do some matching.
But in
this case no matching is done on the rewind, so the matcher ends up "where it
started" with an empty match. And then it repeats.
Note that the "stack" does not expand. When left recursion "explodes" (without
the
LMemo guard) memory is consumed in pending matchers (I hesitate to say that
stack is
consumed because it's not the program stack, its just the stored state
necessary for
the trampoline).
So this is a won't-fix for now.
Original comment by [email protected]
on 15 Mar 2009 at 8:45
from lepl.
If it makes things any clearer, this does get caught by LMemo:
item = Delayed()
item += item[1:]
expr = item & Drop(Eos())
Original comment by [email protected]
on 15 Mar 2009 at 8:46
from lepl.
Original comment by [email protected]
on 15 Mar 2009 at 8:49
- Changed state: WontFix
from lepl.
I'm going back through old comments and noticed this one was starred, which
worried
me, so I thought I would add some clarification:
In general, if LEPL "freezes up" (uses lots of CPU time but doesn't do
anything) then
it is either a bug in my code (LEPL) or a bug in your code (the grammar)
In this case, I thought it was a bug in LEPL. It turned out to be a bug in the
grammar. If a grammar has an unlimited repeat of something that doesn't
consume any
data from the input then it will continue to repeat that matcher "for ever".
In that
case LEPL is doing exactly what it was asked to do - repeat "nothing" for as
many
times as possible.
So if LEPL freezes, check that the grammar doesn't do that (checking can be
quite
difficult, as even quite simple looking grammars can be doing something complex
"under the hood").
Having said all that, if you still have a problem, please consider raising a bug
report or just posting a question on the mailing list. LEPL is growing rapidly
and
most certainly contains many bugs. So you may well have found a completely
different
problem.
Also, I will consider whether making LMemo the default would "fix" this issue.
If
so, I may do that so that "out of the box" LEPL doesn't fail on what could be a
quite
common mistake.
Original comment by [email protected]
on 24 Apr 2009 at 1:28
from lepl.
Oh! *I* starred it. Duh.
Original comment by [email protected]
on 24 Apr 2009 at 1:31
from lepl.
Related Issues (20)
- Regexp Inverted Ranges Unreliable HOT 1
- LEPL-2.3.2 installed with easy_install gives "ImportError: No module named regexp" error HOT 1
- Error Handling and Tracing HOT 1
- Better graph support HOT 1
- Offside Rule HOT 1
- '*' Operator Fails (Multiple Arguments?) HOT 2
- Cloning loses matchers HOT 2
- Incorrect loop detection HOT 2
- Undo Actions
- lepl.functions.String bug HOT 7
- Regexp / Line Aware Improvements HOT 11
- Join function not in __all__ list HOT 1
- Node should implement __ne__ as well as __eq__ or use == rather than != in __eq__ HOT 1
- Can't print empty lepl.List objects. HOT 3
- antlr grammar for lepl HOT 1
- infinite loop in case of block related grammar HOT 4
- Incorrect example in offside rule documentation HOT 1
- cannot mix strings and tokens HOT 5
- cannot parse from a file HOT 4
- lepl.String() does not match empty-string: "" HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lepl.