World: r3wp
[Parse] Discussion of PARSE dialect
older newer | first last |
Maxim 30-Sep-2009 [4132x2] | I posted on the blog about REMOVE. much prefer matching a rule. |
since we can easily do [11 skip] to simulate an index. | |
BrianH 30-Sep-2009 [4134x2] | STAY is a more efficient shortcut for OPT AND. |
Maxim, Steeve, I also prefer REMOVE 1 (my original proposal from November) and CHANGE 1. REMOVE 2 is too fiddly to satisfy the bug-reduction purpose of the CHANGE and REMOVE proposals. | |
Maxim 30-Sep-2009 [4136] | I think carl also prefers it, especially since he wrote as a pre rule, so it needs no explicit blocks on simple rues. :-) |
Steeve 30-Sep-2009 [4137] | Maxim, Did you miss the more recent note where Carl announces that your preference has been implemented in a84 ? |
BrianH 30-Sep-2009 [4138] | About that bug: CureCode it. I'm serious, post it ASAP. |
Steeve 30-Sep-2009 [4139] | Which bug ? |
BrianH 30-Sep-2009 [4140] | remove copy |
Maxim 30-Sep-2009 [4141] | yep... I read it just after posting :-) |
Steeve 30-Sep-2009 [4142] | Brian, you said: STAY is of use when combined with CHANGE or INSERT, when you want the parse position to be set to the position before the insert not after, and when the modification is optional, or otherwise doesn't need to be specially checked. you mean something like: parse [...][ STAY rule remove something] but it's the same thing that: parse [...] [remove something] i don't see your point, give an example please. |
BrianH 30-Sep-2009 [4143x2] | PARSE bugs, particularly new ones, are all urgent priority. This is what we're working on now. |
REMOVE doesn't advance, so STAY isn't needed. That's why I didn't mention REMOVE. | |
Maxim 30-Sep-2009 [4145] | steeve, remove is the odd case cause it returns the original position anyways, insert moves cursor past insert |
BrianH 30-Sep-2009 [4146] | CHANGE or INSERT, or rules containing productions. |
Maxim 30-Sep-2009 [4147] | I would stay A LOT with remark , stay its just a shorthand for pos: [rule] :pos but its handy :-) |
BrianH 30-Sep-2009 [4148] | No, that's AND. STAY is pos: opt [rule] :pos |
Steeve 30-Sep-2009 [4149x2] | Brian, try it with INSERT if you want, it's the same useless thing. >> parse a: "123" [STAY "456" insert "0"] a == "0123" Exactly the same thing that: >> parse a: "123" [insert "0"] a == "0123" |
STAY has no use | |
BrianH 30-Sep-2009 [4151] | You are still putting the matching rule as the stay argument, not the modifying rule. |
Steeve 30-Sep-2009 [4152x3] | hmmm.... |
i give it a try | |
oh I see... >> parse "123" [insert "0" ??] end!: "123" == false >> parse "123" [stay insert "0" ??] end!: "0123" == false | |
BrianH 30-Sep-2009 [4155] | Right now, since we don't have CHANGE, the opt aspect of STAY doesn't matter with INSERT. To have use you have to use it with rulees with productions in them. |
Steeve 30-Sep-2009 [4156] | i see a little better now |
BrianH 30-Sep-2009 [4157x2] | STAY is equivalent to OPT AND or AND OPT. |
Just like AND is the (much less annoying) equivalent of NOT NOT, in theory. | |
Steeve 30-Sep-2009 [4159] | Brian, i posted the bug, you can rewrite it now :-) |
BrianH 30-Sep-2009 [4160x2] | Cool, thanks :) |
Done. | |
Ladislav 30-Sep-2009 [4162] | the a: [stay b] rule can be rewritten as a: [b fail |] generally, I am of the opinion, that it is superfluous |
Maxim 30-Sep-2009 [4163] | many of the parse rules are shorthands for already doable things (except 'NOT and to/thru multi) |
Ladislav 30-Sep-2009 [4164] | moreover, the AND rule is usually what is desired, not the STAY rule, which is just a bug. I do not know any really meaningful use case for STAY; the above INSERT surely isn't one |
Maxim 30-Sep-2009 [4165] | remark could be rewriten using stay, and it would be much simpler to build/read. |
BrianH 30-Sep-2009 [4166] | That's why I put STAY so low on the priority list. Maxim, you are still confusing STAY and AND. |
Maxim 30-Sep-2009 [4167] | nope. |
Ladislav 30-Sep-2009 [4168] | you do not know shorthand for NOT? It may be as follows: a: [not b] is equivalent to a: [b then fail | none] |
Maxim 30-Sep-2009 [4169x4] | nope remark does what I call persistent parsing. it only moves ahead, once all INNER rules have recursively flushed themselves out. |
with inner parsing rules modifying the input and potentially triggering new parse matches. | |
cause inner rules generate parse-able content, which was not part of the original input. | |
true functional unfolding :-) | |
Ladislav 30-Sep-2009 [4173x2] | the Rebol programming wikibook contains a bunch of such idioms |
and THRU multi is even simpler: a: [thru b] is equivalent to a: [b | skip a] | |
Maxim 30-Sep-2009 [4175x2] | yep... all hard to understand and code in real life. which is why I say that the new keywords, just make it easier to parse stuff. They aren't hacks or tricks anymore, they are supported directly by the parse dialect. its like the stack handling... its just going to be MUCH simpler so use push, than tinker with your own stack. |
or rather 'USE ... sorry. | |
BrianH 30-Sep-2009 [4177] | I'm not saying STAY isn't useful, just that it is lower priority than AND because it's use is more limited. |
Maxim 30-Sep-2009 [4178] | you see the thru multi you show... is excessively hard to "see", even I look at it and have to wrap my brain against it, and its really not "obvious" |
BrianH 30-Sep-2009 [4179] | I like having STAY though, since I am one of the advanced parse users that would find use for it, like Maxim and Carl :) |
Steeve 30-Sep-2009 [4180x2] | we will see... |
A | |
older newer | first last |