Closed deltaluca closed 12 years ago
1) All that needs changing infact to get it to compile so far (Though i'm struggling at present to put together my parser based on the test/ dir so might be more) was to change it from return null; to return 0; Don't see any reason why we can't do that given it's 'abstract' method anyways.
2) Changing lazy and lazyF so that var value in the tink AST.build macro call is typed Dynamic solved the runtime type error; but did leave my parser in an infinite loop somewhere inside of parsex (producing a back and forth stack overflow with calls to LazyMacro.lazy); removing all lazyF() from my parsers resolved that so far....
Could you post a gist as to how to reproduce the bug? It is most likely fixed, I will test and push the updates.
I seem to be getting different error using github version; the two i've mentioned don't even get reached; I just get 'Base Failure' form parsex :P
My parser is at: https://github.com/deltaluca/nape/blob/parsex-symbolic/symbolic/src/symbolic/Parser.hx
Okay; taking the test() function at bottom of parser; changing the parser being tested to 'valueP()' produces the stack overflow with:
An ActionScript error has occurred:
Error: Error #1023: Stack overflow occurred.
at MethodInfo-322()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:426]
at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
at MethodInfo-334()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:480]
at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
at MethodInfo-311()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:384]
at MethodInfo-322()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:426]
at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
at MethodInfo-322()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:426]
at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
at MethodInfo-334()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:480]
at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
at MethodInfo-311()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:384]
at MethodInfo-322()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:426]
at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
at MethodInfo-322()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:426]
at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
at MethodInfo-334()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:480]
at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
at MethodInfo-311()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:384]
at MethodInfo-322()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:426]
at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
at MethodInfo-322()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:426]
at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
at MethodInfo-334()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:480]
at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
at MethodInfo-311()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:384]
at MethodInfo-322()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:426]
at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
at MethodInfo-322()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:426]
at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
at MethodInfo-334()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:480]
at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
at MethodInfo-311()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:384]
at MethodInfo-322()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:426]
at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
at MethodInfo-322()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:426]
at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
at MethodInfo-334()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:480]
at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
at MethodInfo-311()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:384]
at MethodInfo-322()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:426]
at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
at MethodInfo-322()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:426]
at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
at MethodInfo-334()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:480]
at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
at MethodInfo-311()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:384]
at MethodInfo-322()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:426]
at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
at MethodInfo-322()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:426]
at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
at MethodInfo-334()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:480]
at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
at MethodInfo-311()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:384]
at MethodInfo-322()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:426]
at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
at MethodInfo-322()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:426]
at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
at MethodInfo-334()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:480]
at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
at MethodInfo-311()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:384]
at MethodInfo-322()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:426]
at MethodInfo-354()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:569]
at MethodInfo-322()[/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:426]
Trying to use ParserM I also get a complaint from ParseMonad.hx that dO expects only one argument, swapping it to use _dO instead which seems to the the one it should be calling produces compile time error:
/home/luca/.haxenekoflash/haxelib/tink_macros/0,2,3/tink/macro/tools/AST.hx:111: characters 16-33 : +
<builtin>:1: character 0 : Called from
/home/luca/.haxenekoflash/haxelib/tink_macros/0,2,3/tink/macro/tools/AST.hx:101: lines 101-245 : Called from
/home/luca/.haxenekoflash/haxelib/tink_macros/0,2,3/tink/macro/tools/AST.hx:23: characters 10-26 : Called from
/home/luca/Projects/Parsex/src/com/mindrocks/macros/LazyMacro.hx:32: lines 32-41 : Called from
/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:374: characters 11-117 : Called from
/home/luca/Projects/Parsex/src/com/mindrocks/text/Parser.hx:435: characters 4-30 : Called from
Aborted
:P
Ok I have no time right now to look at it but I think this is tight to the lazy implementation which is optimized for JS with a hack.
tink.macro.tools.AST.build({
var value = null;
function () {
if (value == null) {
value = untyped 1; // not null to prevent live lock if it forms a cycle.
value = $exp;
}
return value;
};
});
should be replaced by using another var 'computationRequested'
tink.macro.tools.AST.build({
var value = null;
var computationRequested = false;
function () {
if (!computationRequested) {
computationRequested = true;
value = $exp;
}
return value;
};
});
Can you test it?
the problem above is in the file LazyMacro.hx
That is certainly a nicer solutino than just making value Dynamic in the build expression :P
But it doesn't change anything else, what on earth is that live-lock even about?
unless you mean that the stack overflow is meant to be caused by lazyF/lazy, in which case either using Dynamic or computatinRequested it still happens
Ok, so maybe I've not understood the issue then.. As I'm not able to test it now here, I can't help much ATM.
Usually it can be cause by a lack of lazyness. Does it works on non Flash targets?
2012/3/28 Luca Deltodesco < reply@reply.github.com
unless you mean that the stack overflow is meant to be caused by lazyF/lazy, in which case either using Dynamic or computatinRequested it still happens
Reply to this email directly or view it on GitHub: https://github.com/sledorze/Parsex/issues/1#issuecomment-4753772
Stphane Le Dorze
http://lambdabrella.blogspot.com/ http://www.linkedin.com/in/stephaneledorze http://twitter.com/stephaneledorzehttps://twitter.com/#!/stephaneledorze/status/74020060125077504
Tel: +33 (0) 6 08 76 70 15
I don't know how to.. execute JS :P
But i compiled to neko, and it all seems to work fine, including no longer having the weird errors from tink when using ParserM.
sigh :P
flash is unfortunately the main target i'm interested i
I was never targeting flash but yeah.. this have to work, I'll look at it when I have free time (if Laurence have not already nailed it down! ;) ).
2012/3/28 Luca Deltodesco < reply@reply.github.com
I don't know how to.. execute JS :P
But i compiled to neko, and it all seems to work fine, including no longer having the weird errors from tink when using ParserM.
sigh :P
Reply to this email directly or view it on GitHub: https://github.com/sledorze/Parsex/issues/1#issuecomment-4754913
Stphane Le Dorze
http://lambdabrella.blogspot.com/ http://www.linkedin.com/in/stephaneledorze http://twitter.com/stephaneledorzehttps://twitter.com/#!/stephaneledorze/status/74020060125077504
Tel: +33 (0) 6 08 76 70 15
Even the magopP parser which i can never get to work at all on flash is working fine on neko.
Ok, would be nice to shrink it down to the smallest possible failing bit of code and put in a Gist these few lines.
2012/3/28 Luca Deltodesco < reply@reply.github.com
Even the magopP parser which i can never get to work at all on flash is working fine on neko.
Reply to this email directly or view it on GitHub: https://github.com/sledorze/Parsex/issues/1#issuecomment-4755232
Stphane Le Dorze
http://lambdabrella.blogspot.com/ http://www.linkedin.com/in/stephaneledorze http://twitter.com/stephaneledorzehttps://twitter.com/#!/stephaneledorze/status/74020060125077504
Tel: +33 (0) 6 08 76 70 15
I'll get one in a short bit.
Here's a way of producing the tink bug; it actually occurs not only in flash, but neko also:
And the stack overflow bug:
https://gist.github.com/2225783
I also had problems, both in neko and flash to do with getting errors like 'value is not a function()' which I could only resolve by adding lazyF(); i don't know if that's a bug or expected in some cases.
Ok, my version is working with BugParser and neko, but there is a flash bug, and I have had to make an edit to tink to initialise a counter properly.
LazyF is required to modify the initialisation order where there are recursive definitions, although Stphane knows more about that than I.
I'll have to push a version of tink and parsex to my account for review.
On Wed, Mar 28, 2012 at 1:49 PM, Luca Deltodesco < reply@reply.github.com
wrote:
Here's a way of producing the tink bug; it actually occurs not only in flash, but neko also:
https://gist.github.com/2225595
Reply to this email directly or view it on GitHub: https://github.com/sledorze/Parsex/issues/1#issuecomment-4756861
Fixed on Git, published on haxelib - can you confim it works?
@sledorze, those are the changes I made locally yeh.
@0b1kn00b, when will that be?
They are up now, but check Stephanes version first.
On Wed, Mar 28, 2012 at 3:07 PM, Luca Deltodesco < reply@reply.github.com
wrote:
@sledorze, those are the changes I made locally yeh.
@0b1kn00b, when will that be?
Reply to this email directly or view it on GitHub: https://github.com/sledorze/Parsex/issues/1#issuecomment-4763887
Okay the tink bug test case works fine for flash now.
the stack overflow one still happens in flash though; your tink + stephanes parsex
not sure to undestand.. anyway, I have to do real work now.. please post failing code (based on official libs versions only) Stephane
2012/3/28 Luca Deltodesco < reply@reply.github.com
Okay the tink bug test case works fine for flash now.
the stack overflow one still happens in flash though; your tink + stephanes parsex
Reply to this email directly or view it on GitHub: https://github.com/sledorze/Parsex/issues/1#issuecomment-4764591
Stphane Le Dorze
http://lambdabrella.blogspot.com/ http://www.linkedin.com/in/stephaneledorze http://twitter.com/stephaneledorzehttps://twitter.com/#!/stephaneledorze/status/74020060125077504
Tel: +33 (0) 6 08 76 70 15
Using official libs versions, then it's the two gists i posted earlier:
https://gist.github.com/2225595 <-- fixed in github tink https://gist.github.com/2225783 <-- still broke
I managed to implement my parser without triggering the remaining bug.
I havn't actually used either lazyF or commit at all... Guessing that means I will have some issues with error checking (not tested with dirty input) and maybe performance?
Am I right in guessing that to memoize the parser, I only need to use memo() on the final parser?
in fact the problem comes with the way macros work; and the fact that you were doing two lazyF (the combinators are lazy by default). This is too bad, but I can't find a good idea to fix it easily.. (I would have loved to have Lazy values in the AST).
lazy and commit are not for performance; lazy is to break cycles in computations whereas commit is to say that a parser may no more backtrack.
memo is just a combinator; it applies on the parser you're applying it on - you may play with left recursive grammars to get an idea of it.
can't/won't fix the remaining issue (the others have been fixed, thanks)
I'm already using my own combinator from parsec chainl1 for left recursive grammars actually :)
ok :)
2012/3/29 Luca Deltodesco < reply@reply.github.com
I'm already using my own combinator from parsec chainl1 for left recursive grammars actually :)
Reply to this email directly or view it on GitHub: https://github.com/sledorze/Parsex/issues/1#issuecomment-4799052
Stphane Le Dorze
http://lambdabrella.blogspot.com/ http://www.linkedin.com/in/stephaneledorze http://twitter.com/stephaneledorzehttps://twitter.com/#!/stephaneledorze/status/74020060125077504
Tel: +33 (0) 6 08 76 70 15
1) InputStream.hx : 120 (null can't be used as basic type Int) 2) Parser.hx : 476 (runtime error, cannot convert 1 to Function). Also happens (but without a proper stack trace) when using lazyF()