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

World: r3wp

[Rebol School] Rebol School

Henrik
6-Feb-2009
[1462]
Geomol, you are faster than me, but that's almost the same as I was 
coming up with :-)
Geomol
6-Feb-2009
[1463]
:-) Now, is there any shorter/smarter way to do it?
Henrik
6-Feb-2009
[1464]
it is probably easier in R3.
kib2
6-Feb-2009
[1465x2]
Thanks a lot Geomol (can you explain to me a bit your snippet? I'm 
currently studying the parse dialect)
Henrik: why would it be easier in R3 : does parse gained some additional 
tricks ?
Geomol
6-Feb-2009
[1467]
The second argument to parse can be a string, and then parse split 
up the first argument, or the second argument can be a block of parsing 
rules. out is just my output block.

So the parsing rules go:
1) first any of a sub-block of sub-rules

2) sub-block copy the input string to a point, where two newlines 
are found, the result in the variable: arg

3) the paranthesis is evaluated (as normal REBOL code), and it append 
arg (the part of the string, we just copied) to the variable out
4) the parser then skip any number of newlines (2, 3 or more)

5) when the sub-rules are not valid any longer, the input string 
is copied till the end (and appended to out as before)
Henrik
6-Feb-2009
[1468x2]
kib2: not yet, but there are some more logical string splitting functions 
in R3.
particularly string parsing needs to be improved. the above code 
should be simpler to do.
kib2
6-Feb-2009
[1470]
Geomol: thanks for the explanations. If I understand it well, that 
means that we can add actions during the parsing phase? That seems 
really powerful!
Henrik
6-Feb-2009
[1471]
parse is ridiculously powerful (and equally hard to learn/use) :-)
Geomol
6-Feb-2009
[1472]
yes, paranthesis can hold any normal REBOL code (or actions as you 
call it).
kib2
6-Feb-2009
[1473]
Henrik: you mean things like python's "...".split(delimiter) ?
Henrik
6-Feb-2009
[1474]
yes
Geomol
6-Feb-2009
[1475]
kib2, if you're going to use parse, go read this: http://www.rebol.com/docs/core23/rebolcore-15.html
kib2
6-Feb-2009
[1476x2]
Geomol: nice, I've made a print version of a nice doc I've found 
here http://www.codeconscious.com/rebol/parse-tutorial.html, but 
I don't know if it's up to date.
Henrik: from what I've seen so far, such things are quiet easy with 
parse.
Geomol
6-Feb-2009
[1478]
That should be up to date too.
kib2
6-Feb-2009
[1479]
Geomol: ok, thanks. From what I'm reading, that's how Rebol builds 
all those dialects too.
Geomol
6-Feb-2009
[1480]
I think, parsing in REBOL is really strong. It makes us read about 
any kind of input without too much hazzle (once you've taken the 
time to get a feel for parse).
Henrik
6-Feb-2009
[1481x2]
yes, dialects can be processed with parse, however it's not the only 
method.
what makes parse truly powerful is multiple levels of dialects.
kib2
6-Feb-2009
[1483]
So Rebol does not really need regexps, that's it ?
Geomol
6-Feb-2009
[1484]
What was the definition of a dialect? Something that LOAD can handle?
Henrik
6-Feb-2009
[1485]
Geomol. yes I think so.
kib2
6-Feb-2009
[1486]
Parse seems to me like packrat parsers (pegs)
Henrik
6-Feb-2009
[1487]
I can read parse dialects. I can't read regexp. :-)
kib2
6-Feb-2009
[1488]
Henrik: well, I think that's their purpose : your code becomes very 
readable. But what about the perfs ?
Geomol
6-Feb-2009
[1489]
hehe :-)
kib2
6-Feb-2009
[1490]
Geomol: what do you mean ?! Poor or better than regexps ?
Geomol
6-Feb-2009
[1491]
kib, I think, you'll find performance of parse to be really good, 
and I think, the reason is, that parse is native.
kib2
6-Feb-2009
[1492]
Geomol: you mean parse is C implemented ?
Geomol
6-Feb-2009
[1493]
kib, I would say REBOL parse is a lot better than regexps. Yes, native 
words in REBOL is implemented in C.
Henrik
6-Feb-2009
[1494]
parse is surprisingly fast, yes.
kib2
6-Feb-2009
[1495]
Geomol: cool. And does parse uses Unicode with R3 now ?
Geomol
6-Feb-2009
[1496x2]
I think, Henrik is better to answer that.
R3 parse project: http://www.rebol.net/wiki/Parse_Project
It mention unicode.
Henrik
6-Feb-2009
[1498]
I think it will support unicode, yes.
kib2
6-Feb-2009
[1499]
That's very nice. Is parse inspired from something (another langage 
maybe ?).
shadwolf
6-Feb-2009
[1500]
no
Geomol
6-Feb-2009
[1501x2]
I have some rather large paring rules here:
http://www.fys.ku.dk/~niclasen/nicomdoc/nicomdoc.r
http://www.fys.ku.dk/~niclasen/nicomdoc/ndmath.r
and it's very fast to create a huge document from those rules.
*parsing*
kib2
6-Feb-2009
[1503]
shadwolf: thanks.
shadwolf
6-Feb-2009
[1504]
parse in the way it work is exclusive from rebol
kib2
6-Feb-2009
[1505]
Geomol: funny, I'm currently trying to port one of my Python project 
to Rebol : a markup langage with html/latex output !
shadwolf
6-Feb-2009
[1506]
ofcourse parsing a string with any language is a ground base (one 
of the 1st exercice of coding a studient will learn )
kib2
6-Feb-2009
[1507]
shadwolf: certainly, but it depends on what langage you're coding! 
Rebol seems a good candidate for such tasks. I'm also learning Factor, 
and I can tell you that it's a way harder (but maybe that's because 
it lacks some docs).
Geomol
6-Feb-2009
[1508x2]
kib, after I parse the input to RebXML format, I parse the RebXML 
to HTML with: http://www.fys.ku.dk/~niclasen/nicomdoc/ndrebxml2html.r

So 2 huge sets of rules (3 with math) is into play, and the final 
document is there in a matter of seconds.
kib, so I find parse to be very fast, and this real example is a 
good showcase, I think.
shadwolf
6-Feb-2009
[1510x2]
kib2 yes because rebol concept relies on 2 things in fact objects 
and dialect and as dialects are linked to parse system parse is the 
real thing that makes rebol a different language
I remember when i learn to analyse string data in C using string 
automaton algorythm ...  T___T