On Sunday, 4 January 2015 at 13:07:34 UTC, Daniel Murphy wrote:
I've created a dub package for the D version of DMD's lexer, generated automatically from the C++ source.

github: https://github.com/yebblies/ddmd
dub: http://code.dlang.org/packages/ddmd

There are a few annoying limitations, such that it uses dmd's error printing and allocation functions, and requires configuration through 'global'.

Here is an example program that uses the lexer:


import std.stdio;
import std.file;

import ddmd.tokens;
import ddmd.lexer;


void main()

   string data = "void blah() {} // stuff";
   auto l = new Lexer("myfile", data.ptr, 0, data.length, 0, 0);
       printf("token: %s\n", l.token.toChars());
   while (l.nextToken() != TOKeof);



token: void
token: blah
token: (
token: )
token: {
token: }

(sorry if you get this question too often)

How is DDMD as a whole going? Is it getting closer or are ongoing DMD changes slowing it down too much?

Anyway, great to have the lexer on DUB, not going to use if for now because I expect there to be changes, but I guess it may eventually be useful for writing tools.

Reply via email to