DMD library available as DUB package

Meta via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Tue Jul 18 07:07:02 PDT 2017


On Tuesday, 18 July 2017 at 12:07:27 UTC, Jacob Carlborg wrote:
> 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

Nice, I was not aware that DMD as a library was so close to being 
a reality.


More information about the Digitalmars-d-announce mailing list