News for hackers. Stuff that matters.
Re:SRL – Simple Regex Language by draegtun on Tuesday August 30, 2016 @04:24AM (#12388330)
Barely touch regexes these days because for last few years I've been using Rebol / Red parse more and more.

Here's a translation of the first SRL example in the parse dialect:

  [
      some [number | letter | symbol]                 
      "@"
      some [number | letter | "-" ]                   
      some ["." copy tld some [number | letter | "-" ]]
      if (parse tld [letter some letter])
  ]
And here's a full matching example:

  number: charset "0123456789"
  letter: charset [#"a" - #"z"]
  symbol: charset "._%+-"
  
  s: {Message me at [email protected]. Business email: [email protected]}
  
  parse s [ 
    any [
        copy local some [number | letter | symbol]
        "@" 
        copy domain [
            some [number | letter | "-" ] 
            some ["." copy tld some [number | letter | "-" ]]
        ]   
        if (parse tld [letter some letter])
        (print ["local:" local "domain:" domain])

        | skip
    ]   
  ]
Some parse links:

* http://blog.hostilefork.com/why-rebol-red-parse-cool/

* https://en.wikibooks.org/wiki/REBOL_Programming/Language_Fea...

* http://www.codeconscious.com/rebol/parse-tutorial.html

* http://www.red-lang.org/2013/11/041-introducing-parse.html

Re:SRL – Simple Regex Language by QuantumAphid on Tuesday August 30, 2016 @10:48AM (#12390629)
Same for me. About a decade ago I started using Rebol for shell-scripts, file management and working with web API's. It's nice to work with a syntax where I can look at an older parse routine and figure out what I was trying to do just by reading it. Only time I use regex is within my code editor.
Re:SRL – Simple Regex Language by GordonS on Tuesday August 30, 2016 @06:41AM (#12388827)
I don't mind regular expressions myself, but this does look quite nice. Any idea if this has been implemented for anything other than Rebol (which I'd never heard of)?
Re:SRL – Simple Regex Language by rgchris on Tuesday August 30, 2016 @01:54PM (#12392287)
There was a Parse-inspired project for JavaScript, but I'm not sure to what extent it was developed. There was also a Parse implementation in Topaz[1] (which itself is implemented in JavaScript) but is as of now unfinished.

It'd be difficult to implement as tightly in another language that doesn't have Rebol's (or a somewhat Lisp-like) free-form code-is-data/data-is-code[2] approach. Rebol and its Parse dialect share the same vocabulary and block structure that amongst other things: makes it easy to insert progress-dependent Rebol snippets within Parse; build Parse blocks dynamically (mid-Parse if needed!); build Rebol code from parsed data; develop complex grammar rules very similar to EBNF[3]. The article linked above[4] (and now linked again below :) does a good job of fleshing out these ideas and why it may remain a unique feature for some time.

[1]: http://reb4.me/tt

[2]: http://rebol.info/rebolsteps.html

[3]: http://codereview.stackexchange.com/q/87716/46291

[4]: http://blog.hostilefork.com/why-rebol-red-parse-cool/

Re:SRL – Simple Regex Language by draegtun on Tuesday August 30, 2016 @07:57AM (#12389195)
There are other Rebol inspired languages that may have the parse dialect but the only one that I know for certain is Red.

http://www.red-lang.org/