r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Parse] Discussion of PARSE dialect

BrianH
30-Sep-2009
[4161]
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
Ladislav
30-Sep-2009
[4182]
as shown above, it is superfluous; the a: [b fail |] rule is exactly 
as simple as a: [stay b]
BrianH
30-Sep-2009
[4183]
All of the new additions are superfluous, Ladislav. They were added 
to make our lives easier, not to enable stuff we couldn't do before.
Maxim
30-Sep-2009
[4184x2]
I'm  looking at this.....    a: [b fail |]  and its totally obscure 
... I don't see it at all, I can study and eventually "understand" 
it, but within a 1000 line parse rule... <eek>. 

the way I see STAY is: [pos: b :pos]
(speaking as a general user... not myself specifically)
BrianH
30-Sep-2009
[4186]
Sorry, that's still AND. STAY is [pos: opt b :pos].
Ladislav
30-Sep-2009
[4187]
well, I do not think, that e.g. NOT is superfluous, since it substantially 
simplifies the expression. This is not true for STAY.
BrianH
30-Sep-2009
[4188]
The fact is that all of these were added to make our lives easier. 
Now I don't think STAY is worth the effort to implement it, but given 
that Carl *already has* implemented it, it it worth removing? This 
is regardless of the merits of AND, which are unquestioned.
Steeve
30-Sep-2009
[4189]
NOT is very important, especially because charset can't be complemented 
in R3 (Actually they can, but it's a monstrous thing to add all the 
possible chars in a bitset, just to skip someones)
BrianH
30-Sep-2009
[4190x2]
I agree that if we were to dump all of the enhancements but one, 
NOT is the one I would choose :)
We could fix charsets too (add a complemented bit), and that would 
help too.
Steeve
30-Sep-2009
[4192x2]
would be useful for FIND
unless Carl implements the find/not refinement
Ladislav
30-Sep-2009
[4194]
I agree that if we were to dump all of the enhancements but one, 
NOT is the one I would choose :)
 - I guess, that it is my favourite too
BrianH
30-Sep-2009
[4195]
Carl *suggested* the find/not option :)
Maxim
30-Sep-2009
[4196]
'NOT  and the 'TO/'THRU multi.  its just soooo much simpler to slice 
and dice text using it, which is a large percentage of what parse 
is used for.


I remember Carl's historical reason that it made us lazy... hehehe... 
his CR.LF stripping example shows that he is quite lazy himself  
;-)
Steeve
30-Sep-2009
[4197]
TO/THRU multi is not so important in text parsing because we can 
use charsets
Ladislav
30-Sep-2009
[4198]
I am just curious, whether Carl intends to implement the full TO/THRU, 
acting on any subrule
Steeve
30-Sep-2009
[4199]
it's working now in a84
Ladislav
30-Sep-2009
[4200]
It is badluck, that recursive rules are not useful in fact, since 
the stack is too small :-(
BrianH
30-Sep-2009
[4201]
There are likely to be limits. I'm a bit shocked that he was able 
to push it as far as he did :)
Maxim
30-Sep-2009
[4202x2]
steeve, it is... you don't have to build a grammar, just find a set 
of words...
I also remember that Carl feared it would lead to people building 
RE-like slow parsers.
Ladislav
30-Sep-2009
[4204]
full TO/THRU is not implemented yet, trust me
BrianH
30-Sep-2009
[4205]
If you say so, Ladislav, then I look forward to what is to come :)
Steeve
30-Sep-2009
[4206x2]
working here

>> parse "abcd" [any [to ["c" | "b"] ?? skip]]
skip: "bcd"
skip: "cd"
== false
what do you mean by "full" implemented ?
Ladislav
30-Sep-2009
[4208x2]
well, but I do not know if Carl intends to implement the full TO/THRU, 
as I said...
what do I mean? the "full"

    a: [thru b]

can be defined as a "shorcut" for

    a: [b | skip a]


you can try, that this works for any rule B as far as you don't need 
to use too deep a recursion. As opposed to that, the THRU keyword 
does not accept any rule B, as documented in Carl''s blog
BrianH
30-Sep-2009
[4210]
Right. I would just be happy if he adds the not modifier, but the 
current capabilities are moree than I was expecting.