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

World: r3wp

[Parse] Discussion of PARSE dialect

PeterWood
4-Nov-2008
[2704]
gxs is a string of your xml listed above.
Graham
4-Nov-2008
[2705]
I guess it avoids all the other stuff I was doing to force it to 
rebol blocks to allow block parsing :)
Gregg
4-Nov-2008
[2706]
I pasted your code here, which loads the block. I guess the XML parser 
produces the output with those values as words.
Tomc
5-Nov-2008
[2707x2]
foreach item load/markup xml [if not tag? item[ print item]]
not parse and not pretty  but  you get the idea
Graham
5-Nov-2008
[2709]
rebelxml works well for most things  ..not just the ones where the 
namespace is in the tag name
Pekr
5-Nov-2008
[2710]
http://www.rebol.net/r3blogs/0155.html- if you want some improvements 
to parse, now is the time to ask for them ...
BrianH
5-Nov-2008
[2711x3]
We've hammered out some proposals so far, but we are really interested 
in more ideas, especially if we can make them fit.
So far we have been accepting proposals in these categories:
- Recognition: LIT, NOT, OF, TO and THRU extensions
- Modification: CHANGE, INSERT, REMOVE

- Structural and control flow: FAIL (may not be the final name), 
USE, CHECK (still debate here), REVERSE


There is still some debate even within these proposals (name of FAIL 
for example) and some of them might not make it. Some of the old 
PARSE REPs have been definitively rejected or changed, and some are 
still under debate and won't make it in without a lot more thought.
These changes to PARSE are another example of changes to the R3 core 
happening as a side effect of the new GUI work :)
Anton
5-Nov-2008
[2714x2]
Lots of good suggestions. I've just re-read Gabriele's Parse REP 
and the ParseProject DocBase article.
CHECK's meaning is like "continue if ...".
BrianH
5-Nov-2008
[2716x2]
Yup. We've been working on the Parse Project article a lot today. 
The last 2 things from the REP that might make it are the THROW and 
INTO-STRING proposals, though both will need some changes first. 
The rest are covered or rejected.
Peter Wood's RETURN proposal is really interesting. I have been thinking 
about how to make a variant of it work.
Anton
5-Nov-2008
[2718x2]
I'd like to understand Peter Wood's START command a bit better. It's 
not clear to me from the example why it's needed. (or even how the 
example works..)
Peter's example, from the blog:
parse [a b c d] [
    any [
      start (acc: 0)
      |
      set inc integer! (acc: acc + inc)
      |
      end
    ]
  ]
BrianH
5-Nov-2008
[2720]
It isn't needed. It's basically the same as if the paren was included 
on its own, but not in the alternation.
Anton
5-Nov-2008
[2721]
That's what I thought. But Peter must have thought it was useful 
for something.
BrianH
5-Nov-2008
[2722]
Here's a working version of that example:
parse [1 2 3 4] [
	(acc: 0)
	any [set inc integer! (acc: acc + inc)]
]
Anton
5-Nov-2008
[2723]
I thought maybe the start code is only done when one of the other 
alternates is (about to be) matched.
BrianH
5-Nov-2008
[2724]
Perhaps he thought a paren could only follow a rule.
Anton
5-Nov-2008
[2725]
We should wait for Peter's input on that.
BrianH
5-Nov-2008
[2726]
I like the RETURN proposal as this:

	RETURN rule


Match the rule and return a copy of the value from the PARSE function. 
Like COPY then BREAK, but without the temporary variable.
Pekr
5-Nov-2008
[2727]
BrianH: I posted link to Ladislav's Core proposals. There's parse 
section in there too. You can look at r3-alpha parse group .....
BrianH
5-Nov-2008
[2728]
Theye are already covered by the existing proposals.
Anton
5-Nov-2008
[2729x2]
I vaguely remember suggesting PARSE dialect be extended into parens 
with a few commands. Parens are executed as normal rebol dialect 
(not parse dialected in any way). If I remember correctly, it was 
thought better to keep the parens 'pure' rebol. If that is to be 
maintained, then I think Peter's RETURN command ought to be morphed 
into a parse command, as you suggest above, Brian.
-- ie. that's a good idea.
BrianH
5-Nov-2008
[2731x2]
PARSE actually calls DO for those blocks.
blocks -> parens
Anton
5-Nov-2008
[2733]
Right - so doing an extra bind may slow things down.
BrianH
5-Nov-2008
[2734]
More importantly it will override the meaning of the RETURN function 
at a point where you would expect it to work.
PeterWood
5-Nov-2008
[2735]
Clearly my proposal for START is based on my ignorance and inability 
to search the documents properly :-)

It wouldn't hurt as a form of slef-documenting code, though.
BrianH
5-Nov-2008
[2736]
Actually, I think it would hurt (no offence). The word start is a 
common name for parse rules and every keyword we add can't be used 
as a parse rule name. Something to consider when making proposals.
Anton
5-Nov-2008
[2737]
Gabriele's DO command is interesting.

I wonder why it could not become more "functional" and be used after 
the SET command, eg:
	SET result DO integer!
BrianH
5-Nov-2008
[2738]
That DO proposal was the first one to be rejected. It will take some 
serious problems with dialecting to get it included.
Anton
5-Nov-2008
[2739]
Perhaps, Peter, you could post a withdrawl for START on the blog.
Chris
5-Nov-2008
[2740x2]
Re. 'start - could use 'head for the same purpose, it's consistent 
too with the series accessors...
Other side of the coin, if 'end is a keyword, 'start is an intuitive 
companion.
BrianH
5-Nov-2008
[2742]
HEAD would be a better name for a directive to reset the position 
to the beginning of the data. That behavior would be more consistent 
with the series accessors :)
Chris
5-Nov-2008
[2743]
'head?
BrianH
5-Nov-2008
[2744]
Are you checking whether the position is at the beginning of the 
series?
Chris
5-Nov-2008
[2745x2]
Yep.
That's my interpretation of the 'start proposal.
BrianH
5-Nov-2008
[2747]
It was an initialization proposal. Nonetheless, your HEAD? proposal 
sounds interesting. What problem are you solving that would need 
such a directive?
Anton
5-Nov-2008
[2748]
Hmmm... I don't see why it's *necessary*. It doesn't add any functionality 
- it just bulks up the parse dialect with an extra keyword.
BrianH
5-Nov-2008
[2749]
At the beginning of the rule you are already at the head of the series, 
unless the data was already offset. Would you need HEAD? in the middle 
of the rule to determine if anything was matched already?
Chris
5-Nov-2008
[2750]
I was just commenting on word usage per the above examples...
Pekr
5-Nov-2008
[2751]
Anton - but there is some point in time we should start to make rebol 
bigger by adding unnecessary things, or we will never reach 100MB 
executable size and outer world migt not consider us being a rellevant 
alternative :-)
BrianH
5-Nov-2008
[2752]
I don't think this is quite one of those situations, Petr :)
Chris
5-Nov-2008
[2753]
Unless we used looong words : )