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

World: r3wp

[!REBOL3-OLD1]

Pekr
24-Sep-2009
[18155]
I need following to work in terms of parse dialect :-)

keep: :and
BrianH
24-Sep-2009
[18156x3]
Not a weird name, it is the closest equivalent to a logical and that 
you can get in a backtracking system. The only weird part is that 
it is prefix instead of infix. However, if you remember that *all* 
parse operations are prefix (except | ) then it won't seem so weird.
=> needs to be prefix, since in [a => b | c] the => doesn't test 
the a at all:

- The a is matched first, and if it fails it backtracks and advances 
to the next alternate (aka, past the next | )
- If a succeeds then the next rule is processed.

- The next rule is =>, which matches its argument rule and then skips 
the next alternate, whether the rule succeeds or fails
- b is the argument rule of =>
- | c is what => skips
Strangely enough, you can think of the | as being prefix as well: 
it signifies the beginning of an alternative.
Pekr
24-Sep-2009
[18159]
Does AND, in our parse situation, have anything in common with math/logic 
AND? I am not able to see so deep, but I know that parse is in fact 
some deep math ...
BrianH
24-Sep-2009
[18160]
AND is like the shortcut boolean logic and. | is like the shortcut 
boolean logic or.
Pekr
24-Sep-2009
[18161]
And can I explain, by such math layer, why it moves, or not? All 
I am trying to find out is, if we can explain to the user, why "AND 
block! into rule" does not consume block! position :-)
BrianH
24-Sep-2009
[18162]
Because that is how you can check that the current value is a block! 
AND matches into rule.
Pekr
24-Sep-2009
[18163x2]
re: => needs to be prefix, since in [a => b | c] the => doesn't test 
the a at all ... I thought, that underlying C level can decide, if 
something can be prefix or infix = match a and look if next keyword 
is =>. But then it would mean, that we would slow down parse engine? 
Because then we would have to perform such check for each rule applied, 
to check if eventually => follows?
Because that is how you can check that the current value is a block! 
AND matches into rule.

 - remember that one for the docs. There will be many stupid users 
 like me, trying to understand, what the heck AND is doing and why 
 it is doing so = we want to have description theory why it is the 
 way it is :-)
BrianH
24-Sep-2009
[18165x2]
The evaluation method requires that operations be prefix - it's a 
state machine. The only carried-over backtracking state is used to 
implement | alternates. It would double the complexity of PARSE to 
make another infix operation.
I've learned a lot about the implementation of PARSE this week. I'm 
almost to the point of being able to write it myself.
Pekr
24-Sep-2009
[18167x3]
Hmm, interesting. Does not Carl think of 'either in terms of infix?
I like => more and more (especially as I suggested it :-), but Henrik 
suggests, it has different meaning in Math. Is that true? I do remember 
that I often use ==> to express "then", so I just shortened it to 
=>
I was also inspired by one script, and now I dont remember which 
one, which used something like ---> in combination with some indentation, 
but maybe it was just a debug output ...
Ashley
24-Sep-2009
[18170]
I havn't commented much on parse because I tend to only use it in 
its most simple form:

	parse string delimiter


which got me thinking that, if we havn't already, perhaps this major 
use case is deserving of its own "split" function?
Henrik
24-Sep-2009
[18171]
>> ? split
USAGE:
	SPLIT series dlm /into

DESCRIPTION:

 Split a series into pieces; fixed or variable size, fixed number, 
 or at delimiters
Ashley
24-Sep-2009
[18172]
Mezz or native? Not exactly clear how the /into refinement works.
Henrik
24-Sep-2009
[18173x2]
/into is a new refinement for most series. It makes it possible to 
store the result directly in a series without copying. I've been 
watching BrianH jump up and down over this feature a few months ago. 
:-)
split is mezz.
Ashley
24-Sep-2009
[18175]
So how does the "fixed size" bit of split work then?
Henrik
24-Sep-2009
[18176x2]
the 'dlm can be either a char/string for variable size or an integer 
for fixed size.
>> split "1 2 3 4 4" 2   
== ["1 " "2 " "3 " "4 " "4"]

>> split "1 2 3 4 4" " " 
== ["1" "2" "3" "4" "4"]
Ashley
24-Sep-2009
[18178]
Ah thanks. That's a very usefull addition.
Henrik
24-Sep-2009
[18179x2]
ok, there are some bugs in this function. /into does actually not 
work this way. bug reports will be needed here.
it seems that it's bound for a rewrite. perhaps the priority should 
be bumped.
Ashley
24-Sep-2009
[18181]
Being mezz makes that easier at least.
Henrik
24-Sep-2009
[18182]
anyhoo, the point is that the obscurity of splitting using PARSE 
might be removed, so we will be using SPLIT in the future.
sqlab
24-Sep-2009
[18183]
Maybe TOO is too similar to TO,  but it's meaning is appropriate 
for this AND or  &
Pekr
24-Sep-2009
[18184x2]
write parsing CSV like input, there was a proposal to solve it via 
external function or decode-csv aproach, which could internally use 
parse.
for new parse rewrite, there is going to be default /all mode, and 
/ignore mode and even maybe /case, so dunno, if delimiters will be 
provided as with R2 parse ...
Henrik
24-Sep-2009
[18186]
I have a small CSV parse and CSV generator library that we could 
start from.
Steeve
24-Sep-2009
[18187x3]
Henrik, i hope we will not remove the splitting behaving of PARSE 
because actually SPLIT is damn slow
SPLIT has too much useless options and use other mezzanines (COLLECT) 
in his code, it why it's not a good mezznine to my mind.
Actually, i don't like mezzs which return block of data with unlimited 
sizes.

I like mezzs with async behavior, to treat each data set, step by 
step.
Dockimbel
24-Sep-2009
[18190]
I'm reading several times needs for CSV parsing enhancements, are 
they issues with parsing CSV files with R2's parse?
Sunanda
24-Sep-2009
[18191]
On example here -- the specific problem is the same in R2 and R3:
   http://www.curecode.org/rebol3/ticket.rsp?id=1042&cursor=2
BrianH
24-Sep-2009
[18192]
This highlights the actual change that would need to happen to PARSE: 
http://www.curecode.org/rebol3/ticket.rsp?id=1079
Dockimbel
24-Sep-2009
[18193]
Thanks, so it's parse's splitting ability that is causing an issue.
Pekr
25-Sep-2009
[18194x2]
Brian - it seems that Ladislav does not agree to your conclusions 
towards parse internals ... and Carl is all but silent :-)
It reminds me of old ML discussions of gurus, trying to find internal 
REBOL representation, and differing in opinion of how things are 
done under the hood.
BrianH
25-Sep-2009
[18196x2]
Carl revealed the internals, inadvertantly, earlier in that comment 
discussion. It was easy to figure out. Ladislav needs to read closer.
Back in 2000 I was one of those gurus on the mailing list, and my 
argument with Gabriele was the initial documentation for R2's context 
model and behavior. I was glad when Ladislav later fleshed out that 
discovery with more detail in his Bindology papers.
Pekr
25-Sep-2009
[18198]
I do remember guys like Tim Peters, Joel Neely, etc., Well, those 
were the times :-)
BrianH
25-Sep-2009
[18199]
:)
Graham
25-Sep-2009
[18200]
I remember Carl used to be on the mailing list ...
BrianH
25-Sep-2009
[18201]
I remember I used to be on the mailing list. Haven't been for many 
years now.
Pekr
25-Sep-2009
[18202x2]
I have a proposal - I think that we all know, that View engine itself 
needs few enhancements, which would be nice to have for the official 
3.0 release. I would like to create wiki page similar to Parse proposal, 
to which we could contribute our requests. What do you think?
I don't think Carl will work in View engine anytime soon, but having 
those things collected in one place would be surely good.
Graham
25-Sep-2009
[18204]
Sounds good ... and won't hurt