World: r3wp
[Parse] Discussion of PARSE dialect
older newer | first last |
Volker 31-Oct-2005 [576] | the general way: rule: [ ( dummy-rule: [] if not ok? [ dummy-rule: [end skip] ) dummy-rule ] |
Graham 31-Oct-2005 [577] | oh ... looks ugly. |
Volker 31-Oct-2005 [578] | It is. |
Graham 31-Oct-2005 [579] | Ok, we need a parse enhancement here ! |
Ladislav 1-Nov-2005 [580x2] | BrianH proposed and enhancement I agree with, but I am afraid it sill isn't in RAMBO |
still | |
Graham 1-Nov-2005 [582] | which enhancement was this? |
BrianH 1-Nov-2005 [583] | Sorry, I've been overwhelmed with school beauracracy and other concerns. I haven't had time to compose my thoughts. |
Ladislav 1-Nov-2005 [584] | I hope you will have an opportunity to read it in RAMBO soon ;-) |
Graham 1-Nov-2005 [585] | what's the low down? |
Ladislav 1-Nov-2005 [586x2] | an IF PARSE keyword working with parens as follows: IF (evaluate expression) |
would it solve your need? | |
BrianH 1-Nov-2005 [588] | The real trick here is that they have to fix a parse bug that has been there since the beginning: Parse doesn't backtrack past parens. |
Ladislav 1-Nov-2005 [589] | didn't notice that , an example? |
Graham 1-Nov-2005 [590x2] | I think it would .. but I can also get by by rewriting the parse rule. It would end up much longer though. |
at the moment, I just fudge it by adding a far distant date. | |
Ladislav 1-Nov-2005 [592] | Fudge, the Minister of Magic and Wizardry? |
Graham 1-Nov-2005 [593] | Cornelius |
Ladislav 1-Nov-2005 [594] | :-) |
BrianH 1-Nov-2005 [595] | Damn. I gave feedback about this years ago, checked over and over again in new revisions, and then finally gave up. But when I was trying to come up with an example of the problem for you Ladislav, it turns out that they must have fixed the doesn't-backtrack-through-parens problem sometime during the View 1.3 development cycle. I guess that shows me :) |
Ladislav 1-Nov-2005 [596] | G looks like fudged "C" |
BrianH 1-Nov-2005 [597] | Works on string and block parsing too. They didn't even have block parsing when I first noticed that problem. |
Ladislav 1-Nov-2005 [598x2] | and your old example was? |
(just to check with 1.2.48) | |
BrianH 1-Nov-2005 [600x4] | parse "abc" ["a" (print "a") "c" | "a" "b" "c"] It used to fail, return false, because the paren shortcircuited the backtracking, so it wouldn't return to the position before the "a", it would return to the position the parser was at when the paren started. |
It was so long ago, I don't even remember if View was in its first beta yet. | |
It was certainly before the parse break keyword was added. | |
I've been refactoring my parse rules ever since, just because I was so frustrated I gave up on a fix. | |
Graham 1-Nov-2005 [604] | since the function header is parsed by block parsing, perhaps you are exaggerating ...! |
BrianH 1-Nov-2005 [605] | It wasn't always so. This was at least 5 years ago. |
Ladislav 1-Nov-2005 [606] | View 1.2.48 works OK |
BrianH 1-Nov-2005 [607] | See, all I need is a GREAT DEAL of patience :) |
Graham 1-Nov-2005 [608] | we're all patient othewise we wouldn't be here... |
Ladislav 1-Nov-2005 [609] | It looks like it has been repaired around the time you finally gave up ;-) |
BrianH 1-Nov-2005 [610x3] | I should have known that would do it :) |
Ladislav, while you're here, tell me what you think of this draft of the RAMBO request: | |
I would like an IF clause in parse, that would work like this: - Syntax: if (test) - Behavior: The paren would be executed like any other paren in parse, but the return value of that paren would be checked. If the return value is one that would count as false for the IF native function (false or none), then the parse would fail at that point as if parse had failed to find some syntactic element. At that point, any normal backtracking and advancement to the next alternate would be performed, if any. This clause would allow parse flow to be directed by semantic criteria as well as syntatic, allowing parse to handle a greater range of grammars. An if clause would be sufficient to make parse into a predicated parser, similar in capabilities to ANTLR. | |
Ladislav 1-Nov-2005 [613x2] | perfectly understandable for me and I support this, but I am afraid, that there are many that wouldn't understand it. Anyway, if it is meant for Carl, it may suffice |
(otherwise a somewhat elementary formulation might be desirable) | |
BrianH 1-Nov-2005 [615] | It's a RAMBO entry, not documentation. Still, is there anything you find unclear there, awkward or incomplete? Am I missing anything? |
Ladislav 1-Nov-2005 [616] | don't think so |
BrianH 1-Nov-2005 [617] | Aside from a meaningful example that would demonstrate the importance of this proposal? That I know is missing... |
Ladislav 1-Nov-2005 [618] | yes, an example is desirable |
Volker 1-Nov-2005 [619x3] | The result of the next paren tells if 'if counts as success. a value of false or none triggers a fail. |
(sorry for english.) | |
as success -> as match | |
Graham 1-Nov-2005 [622] | parse [... ] [ if ( some-test ) | if ( another test ) ] |
BrianH 1-Nov-2005 [623] | Yup, you got it. You don't need to specify a block afterwards because the parse dialect has built-in control flow. |
Graham 1-Nov-2005 [624] | at present we can only match on datatypes and literal ( non integer ) values. |
Volker 1-Nov-2005 [625] | is there a better word than if, for grahams example? |
older newer | first last |