DMD library available as DUB package

Jacob Carlborg via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Tue Jul 18 05:07:27 PDT 2017


During the dconf hackathon I set out to create a DUB package for DMD to 
be used as a library. This has finally been merged [1] and is available 
here [2]. It contains the lexer and the parser.

A minimal example:

#!/usr/bin/env dub
/++ dub.sdl:
name "dmd_lexer_example"
dependency "dmd" version="~master"
+/

void main()
{
     import ddmd.lexer;
     import ddmd.tokens;
     import std.stdio;

     immutable sourceCode = "void test() {} // foobar";
     scope lexer = new Lexer("test", sourceCode.ptr, 0, 
sourceCode.length, 0, 0);

     while (lexer.nextToken != TOKeof)
         writeln(lexer.token.value);
}

[1] https://github.com/dlang/dmd/pull/6771
[2] http://code.dlang.org/packages/dmd

-- 
/Jacob Carlborg


More information about the Digitalmars-d-announce mailing list