
Parsing – REBOL Users Guide - vmorgulis
http://www.rebol.com/docs/core23/rebolcore-15.html
======
QuantumAphid
More than a decade later, Rebol (and its newer offspring Red red-lang.org) are
still in regular use on my team.

A cool thing about Rebol's (and Red's) PEGs are that they can easily parse and
process the diverse datatypes of its parent source.

REBOL Parser in 10 Lines
[http://www.rebol.net/cookbook/recipes/0042.html](http://www.rebol.net/cookbook/recipes/0042.html)

And:

[http://blog.hostilefork.com/why-rebol-red-parse-
cool/](http://blog.hostilefork.com/why-rebol-red-parse-cool/) "But even more
impressively, it can work on the symbolic structure of code itself. While
Rebol and Red are both like Lisp in being homoiconic, when you see something
like PARSE applied on code itself... you know you're looking at something very
cool."

~~~
throwaway7645
Could you please go into agonizing detail on your team's use of REBOL? I've
never been more excited for a language than Red/RedSystem, but hear so little
in the wild on it or its older brother. All the parse examples I've seen have
been pretty basic, but I hear it is powerful.

~~~
oofoe
I can't answer for QuantumAphid, but I have used REBOL (v2) extensively for
graphics post-production utilities for my old studio. It was the only way that
I could provide programming services for all the departments I had to support.

Of course I wrote a number of simple utilities, but I also did several large
and comprehensive applications with complete user interfaces. I could staple
together a fully styled interface with custom widgets in an afternoon compared
with (at best) several days for equivalent functionality with other toolkits.
Most of my large programs communicated with our production management database
using XMLRPC.

The GUIs including things like a full graphical Avid-style editorial timeline,
a multi-panel interface for managing data on the review playback system, one
that mimicked the playback system interface (complete with reflections and
drop shadows) to make the operator feel at home... Even one with a wise
cracking virtual assistant that guided the operator through the task. All of
these were operational and bug free in a fraction of the time that would have
been consumed by Python/wx.

Just as important as simple and flexible GUIs were the built in parsing,
binary and image processing. I could make a shot slates (images with text
noting the shot number and production) quickly and easily because anything you
could show in the GUI could be exported as an image. I did complete stereo
audio processing for Editorial inside REBOL with no external libraries -- it
was simple and fast. When I later had to replicate this utility in Python I
finally threw up my hands and shelled out to sox.

In general, these tools were rock solid, fast, easy and attractive to use.

So it's a great language, and Red seems like it will be a worthy successor.
The learning curve to use it effectively is a bit steep because it has many
differences from ALGOL derived languages. But once you figure it out, you'll
never want to give it up!

~~~
throwaway7645
Awesome! Thanks for the long post. I'm primarily a Python user, but recognize
it as for what it is (reasonably easy to learn and equally limiting scripting
tool). I think Rebol is pretty cool, but have been waiting for the speed that
Red promises.

------
rebolek
Red [1] is language based on Rebol that among other things improves PARSE
dialect [2]

[1] [http://www.github.com/red/red](http://www.github.com/red/red)

[2] [http://www.red-lang.org/2013/11/041-introducing-
parse.html](http://www.red-lang.org/2013/11/041-introducing-parse.html)

------
wcummings
Reminds me of perl6. Why don't more languages support grammars like this?

Fun example:
[https://github.com/perl6/perl6-examples/blob/master/categori...](https://github.com/perl6/perl6-examples/blob/master/categories/interpreters/lisp.pl#L34)

~~~
draegtun
Here's that fun example written in Rebol parse:

    
    
        digits:     charset "1234567890"
        char:       charset [#"a" - #"z" "+/-*"]  ;; chars allowed in a symbol
        not-quot:   complement charset {"}
        esc-string: [{\"} | not-quot]
    
        bool:   ["#t" | "#f"]
        float:  [opt "+-" any digits "." some digits]
        number: [opt "+-" some digits]
        symbol: [some char]
        quot:   [#"'" [sexp | atom]]
        string: [{"} any esc-string {"}]
    
        statement: [sexp | atom | space | newline]
        sexp: ["(" any statement ")"]
        atom: [bool | float | number | quot | symbol | string]
    
        lisp-rule: [some statement]
    

NB. I wrote this "off the cuff" so I don't expect it to be flawless! Also
there are no capture rules provided in my example (unlike perl6 grammars which
provides this automatically).

~~~
yellowapple
It's worth noting that this grammar is a bit more restrictive than the Perl 6
equivalent. In particular, "\d" in Perl includes not only 0 through 9, but
_any_ Unicode character that's classified as a "digit". The Perl 6 grammar
documentation features this in an example of using arbitrary methods in
grammars:
[https://docs.perl6.org/language/grammars.html#Methods_in_Gra...](https://docs.perl6.org/language/grammars.html#Methods_in_Grammar)

~~~
draegtun
I think the Perl 6 example should really use [0-9] instead of \d because it's
unlikely that unicode numerals are allowed (in the Common Lisp spec).

Anyway neither example fully covers the Common Lisp spec for a number atom
(for eg. scientific notation or rationals).

~~~
yellowapple
I don't think covering all of the Common Lisp spec is required to be
Greenspun-compliant ;)

~~~
draegtun
In that case Rebol is already Greenspun-compliant ;-)

    
    
        (print (multiply (add 1 2) 3))
    

... will print an answer of 9

------
jgalt212
The designer of REBOL, not surprisingly, is a pretty interesting and
impressive fellow.

[https://en.wikipedia.org/wiki/Carl_Sassenrath](https://en.wikipedia.org/wiki/Carl_Sassenrath)

