First of all: this thing really deserves being pushed beyond a mere demonstration piece, IMHO. So that's what I'm trying here (and, on the way, learning; which is my humble benefit in it).
So, the one essential thing I needed to have in order to start moving things around - was tests. I mean REAL tests, not just the pseudo ones that were there.
Well, testing an interactive thing like Debugger requires a bit more than ok and is. So I put together RemoteControl in Grammar::Test::Helper, which is kind of a robot that exercises Tracer/Debugger and logs what they write to STDOUT and STDERR. Then there's another test helper &parseTasks to help with easily running a bunch of tests on all kinds of triggering a parse: (parse, subparse, parsefile) X (invoked on class, invoked on instance)[1].
Of course there are tests for the test-helpers themselves as well.
So these test-helpers plus the actual tests that use them are the first chief contribution in this pr.
They can - and should be - further improved, though.
Anyways, thus being able to "move things around" safely, I think I've considerably consolidated things:
eliminated all plain code duplication so far[2], and separated pure intercepting from what's then done with it: namely DebuggedGrammarHOW isa TracedGrammarHOWisa InterceptedGrammarHOW - now :)
reduced the crucial part that kills perf (find_method) to a minimum (eliminating it is tbd next)
thereby fixed #5, at least with substantially less cheating than as originally proposed (though that's still not entirely right, see above)
prepared a general Publish-Subscribe/Observer pattern (onRegexEnter / onRegexExit) in order to be able to open up for new functionality like eg profiling
oh, and I put some hints re colour output on Windows into README
[1] as I now have learned "on class" vs "on instance" doesn't really matter at all. But well, to be sure - plus there was a (real!) issue re that (#4)...
[2] anyone to actually compare the pure LOC...?
Oh, quite a bunch of things...
First of all: this thing really deserves being pushed beyond a mere demonstration piece, IMHO. So that's what I'm trying here (and, on the way, learning; which is my humble benefit in it).
So, the one essential thing I needed to have in order to start moving things around - was tests. I mean REAL tests, not just the pseudo ones that were there. Well, testing an interactive thing like
Debugger
requires a bit more thanok
andis
. So I put together RemoteControl inGrammar::Test::Helper
, which is kind of a robot that exercises Tracer/Debugger and logs what they write to STDOUT and STDERR. Then there's another test helper &parseTasks to help with easily running a bunch of tests on all kinds of triggering a parse: (parse
,subparse
,parsefile
) X (invoked on class, invoked on instance)[1]. Of course there are tests for the test-helpers themselves as well. So these test-helpers plus the actual tests that use them are the first chief contribution in this pr. They can - and should be - further improved, though.Anyways, thus being able to "move things around" safely, I think I've considerably consolidated things:
DebuggedGrammarHOW
isaTracedGrammarHOW
isaInterceptedGrammarHOW
- now :)find_method
) to a minimum (eliminating it is tbd next)Tracer
andDebugger
, st it is reset whenever a new parse is initiated (done) and can be associated with the right thing (still tbd, see https://github.com/jnthn/grammar-debugger/pull/5#issuecomment-54876455)onRegexEnter
/onRegexExit
) in order to be able to open up for new functionality like eg profiling[1] as I now have learned "on class" vs "on instance" doesn't really matter at all. But well, to be sure - plus there was a (real!) issue re that (#4)... [2] anyone to actually compare the pure LOC...?