Attributes (lexical)

rumbu rumbu at rumbu.ro
Thu Nov 25 12:16:50 UTC 2021


On Thursday, 25 November 2021 at 11:25:49 UTC, Ola Fosheim 
Grøstad wrote:
> On Thursday, 25 November 2021 at 10:41:05 UTC, Rumbu wrote:
>> I am not asking this questions out of thin air, I am trying to 
>> write a conforming lexer and this is one of the ambiguities.
>
> I think it is easier to just look at the lexer in the dmd 
> source. The D language does not really have a proper spec, it 
> is more like an effort to document the implementation.

I try to base my reasoning on specification, dmd is not always a 
good source of information, the lexer is polluted by old features 
or right now by the ImportC feature, trying to lex D an C in the 
same time.

DMD skips the new line if the file was not specified, that's why 
the "filename" is unexpected on a new line:
https://github.com/dlang/dmd/blob/d374003a572fe0c64da4aa4dcc55d894c648514b/src/dmd/lexer.d#L2838

libdparse completely ignores the contents after #line skipping 
everything until EOL, even a EOF/NUL marker which should end the 
lexing:
https://github.com/dlang-community/libdparse/blob/7112880dae3f25553d96dae53a445c16261de7f9/src/dparse/lexer.d#L1100



More information about the Digitalmars-d-learn mailing list