RegEx for a simple Lexer
Brian Schott via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue May 13 13:56:12 PDT 2014
On Tuesday, 13 May 2014 at 19:53:17 UTC, Tim Holzschuh via
Digitalmars-d-learn wrote:
> Hi there,
> I read a book about an introduction to creating programming
> languages (really basic).
>
> The sample code is written in Ruby, but I want to rewrite the
> examples in D.
>
> However, the Lexer uses Ruby's regex features to scan the code.
>
> I'm not very familiar with D's RegEx system (nor with
> another..), so it would be very helpful to receive some tips on
> how to "translate" the ruby RegEx's to D's implementation.
You may find the following useful:
http://hackerpilot.github.io/experimental/std_lexer/phobos/lexer.html
The source of the lexer generator is located here:
https://github.com/Hackerpilot/Dscanner/blob/master/std/lexer.d
D lexer:
https://github.com/Hackerpilot/Dscanner/blob/master/std/d/lexer.d
There's also a parser and AST library for D in that same project.
The lexer generator may not be as simple as what you're using
right now, but it is very fast.
More information about the Digitalmars-d-learn
mailing list