Query Context at Source File and Offset in DMD

Jacob Carlborg doob at me.com
Sun Apr 6 01:56:55 PDT 2014


On 2014-04-05 23:22, "Nordlöw" wrote:

> The only way I see of solving this for now is to add a global copy of
> the Module::srcfile accessible to make this information accessible
> within the lexer. Does anybody have a better idea?

The Lexer's constructor takes a Module as the first parameter [1]. A 
Module has the original argument name [2], I assume that's the filename. 
Just store the module/filename as an instance variable in the lexer and 
access it where you need it.

[1] 
https://github.com/D-Programming-Language/dmd/blob/master/src/lexer.c#L245

[2] 
https://github.com/D-Programming-Language/dmd/blob/master/src/module.h#L76

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list