World: r3wp
[Parse] Discussion of PARSE dialect
older newer | first last |
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 [625x2] | is there a better word than if, for grahams example? |
if implies a then, and we have none. | |
Graham 1-Nov-2005 [627x2] | away-rule: [ 'away set .. [ 'from ... | 'every set day word! if ( either day = to-word pick system/locale/days current-date/weekday [ repend away-days [ current-date current-date ] true ][ false ) ) | break ] ( reason: copy "" ) opt ... ] |
oops .. close | |
BrianH 1-Nov-2005 [629x3] | Then is everything after the if clause. Parse already has control flow. |
Here is a rewording of the proposal. Any problems? | |
I would like an IF clause in parse, that would work like this: - Syntax: if (test) - Behavior: The paren is executed like any other paren in parse, but the return value of that paren is checked, treated like the condition argument to the if native. A false or none value would cause the parse to fail as if it had failed to find some syntactic element - otherwise the parse should continue. Failure should trigger any normal backtracking and advancement to the next alternate, just like failure of a syntactic match would at that point. 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. | |
Volker 1-Nov-2005 [632x3] | to me it sounds like "do somewhing", not just continue. |
more like verify or assure. | |
assert , although more like debugging. | |
Graham 1-Nov-2005 [635] | It means I can do this if ( clause ) | break I guess to exit the rule. |
Pekr 1-Nov-2005 [636] | BrianH: then Rambo-it! :-) |
BrianH 1-Nov-2005 [637] | The control flow of parse is more like that of Prolog or Icon than it is like Pascal. "Then" is a Pascal thing. |
Ladislav 1-Nov-2005 [638] | the new wording looks better |
older newer | first last |