World: r3wp
[Parse] Discussion of PARSE dialect
older newer | first last |
BrianH 30-Sep-2009 [4301] | Even in your version. |
Steeve 30-Sep-2009 [4302] | wait... |
BrianH 30-Sep-2009 [4303x2] | The | break is not only the else for the if (), it is also the alternate chosen if #"(" or #")" are not matched. |
That is what THEN gives us: the ability to overload alternates. | |
Steeve 30-Sep-2009 [4305] | oh ok, it's not exiting the loop for such case [()()()()] |
BrianH 30-Sep-2009 [4306] | Right :) |
Steeve 30-Sep-2009 [4307] | Am ok now |
BrianH 30-Sep-2009 [4308] | But we *want* to exit the loop in this case: ")(" |
Steeve 30-Sep-2009 [4309] | yep |
BrianH 30-Sep-2009 [4310] | I find myself liking THEN quite a bit :) |
Steeve 30-Sep-2009 [4311x3] | But we still have a problem with break not being able encapable in a block. We can't construct reusable rules with such logic. |
i mean we can't push the part [if (1 <= -- p) then none | break] in a separated rule | |
we need a parameter for break | |
BrianH 30-Sep-2009 [4314] | It's tricky, true. There was either a proposal or a bug report to make BREAK break out of the closest enclosing ANY or SOME... |
Steeve 30-Sep-2009 [4315x3] | break level |
break 0 | |
break -1 | |
BrianH 30-Sep-2009 [4318] | Counted back, not negative. |
Steeve 30-Sep-2009 [4319x2] | if you prefer |
time for a new proposal Brian | |
Maxim 30-Sep-2009 [4321] | 'ROLLBACK anyone ;-) |
BrianH 30-Sep-2009 [4322] | Done, as n BREAK :) |
Maxim 30-Sep-2009 [4323] | funny I suggested it 2 hours ago, and you guys end up with a path with a use case implementing a simple rule :-) |
BrianH 30-Sep-2009 [4324] | I had to figure out how to make it fit in. Done. Off to dinner. |
Pekr 1-Oct-2009 [4325x6] | guys, what have you created for the simple recursive replacement of paren: [#"(" paren #")"] looks like regexp hell in comparison ... |
Not having proper recursion support is big downside of REBOL. | |
>> parse d: "abc" [change skip 123] >> d == "123bc" | |
Isn't it weird? I would expect a123 | |
hmm, maybe it is correct, just need a bit more of thought. Skip is not skipping "a", it is "matching" "a", hence defining, what should be replaced ... | |
The stack limit is so lame, almost unusable: REBOL level recursion: >> cnt: 0 recursion: does [++ cnt recursion] recursion ** Internal error: stack overflow >> cnt == 4004 Parse level recursion: >> cnt: 0 rule: [(++ cnt) rule] parse "123" [some rule] ** Internal error: internal limit reached: parse >> cnt == 512 | |
Henrik 1-Oct-2009 [4331] | I never bumped into the stack limit in R2 with parse. Is it smaller in R3? |
Pekr 1-Oct-2009 [4332x3] | will try ... |
no, it is exactly the same ... | |
But function example gives me == 14265 .... so - is function recursion stack lower in R3? | |
Henrik 1-Oct-2009 [4335] | I think it varies with the OS platform used. I get 1335 in OSX. |
Graham 1-Oct-2009 [4336] | sounds plenty for parse |
Ladislav 1-Oct-2009 [4337] | Graham: your "plenty" and my "plenty" are not the same, as it looks ;-) |
Henrik 1-Oct-2009 [4338] | But can it be controlled? I figured this is something controlled by the OS. |
Ladislav 1-Oct-2009 [4339] | Pekr: the original rule was a little bit more complicated: paren: [any [#"(" paren #")"]], but still much simpler, than the above hell. Which is nothing compared to a trial to do the same in the case of: bracket: [any [#"(" bracket #")" | #"[" bracket #"]"]] |
Pekr 1-Oct-2009 [4340x2] | Ladislav - your recursive example reads so cleanly, whereas flat variant starts to remind us of regexp :-) Well, it is kinda still nice, that with flat variant stuff like that is possible, but that should not be used as an excuse, that REBOL non ability to properly recurse sucks ... |
but - the topic is probably more deep, because if it would be easy to make rebol tail recursive, it would already happen, no? | |
Ladislav 1-Oct-2009 [4342] | The fact is, that this has nothing to do with tail recursivity: neither of PAREN or BRACKET is tail-recursive. The only problem is, that the stack depth does not look sufficient to use recursive rules for moderately complicated cases. |
Pekr 1-Oct-2009 [4343] | Is it runtime adjustable, or does it need to be tweaked for the compile/build time? |
Ladislav 1-Oct-2009 [4344] | As far as I know, it is not adjustable yet, but Carl may have plans to improve that... |
Gabriele 1-Oct-2009 [4345] | some of you guys has to teach me what makes my code unreadable, otherwise there's no way i'll ever fix it... |
Pekr 1-Oct-2009 [4346x2] | will new parser enahncements help us to get better XML family support? :-) |
I mean - we are not too strong with XML based stuff. Are new enhancements going to eventually simplify XML parsing? But maybe even R2 parser is good enough to have full XML support? | |
Chris 1-Oct-2009 [4348] | How can you simplify XML parsing? What's simple about it? |
Steeve 1-Oct-2009 [4349x2] | As a mirror of the [n BREAK] proposal, i suggest the [n FAIL] proposal. This would let you FAIL from n nested loops. Otherwise, it would be to FAIL out of n nested blocks. |
Then, [(p: 0) some [#"(" (++ p) | #")" if (1 <= -- p) then none | break] if (p = 0)] could be remplaced by: [(p: 0) some [if (p < 0) 2 fail | #"(" (++ p) | #")" (-- p)]] A little more readable ? | |
older newer | first last |