So... let's document dmd

Jacob Carlborg via Digitalmars-d digitalmars-d at puremagic.com
Wed Apr 6 23:36:57 PDT 2016


On 2016-04-07 02:53, Walter Bright wrote:

> I doubt any of them could lex C/C++ correctly (trigraphs, macros,
> backslash line splicing, wysiwyg string literals).

No. But it doesn't need to be perfect. There's also nothing that tells 
what's wrong and what's right. For example, in TextMate the identifier 
in a function declaration is syntax highlighted, but in Eclipse it's not 
syntax highlighted.

> Are you talking about an AST?
>
> (Good luck doing an AST for C++ without a real C++ compiler front end!
> Not that hard for D, though.)

Yes. In TextMate one describes a grammar and assigns different scopes to 
the different rules. These scopes are then used by the theme engine to 
syntax highlight the code. The scopes are also used to enable/disable 
different bundle commands. For example, pressing Ctrl+B inside a comment 
could make the selected text bold (replace the text with an HTML or 
Markdown tag) while outside comments something else happens.

TextMate also adds top level declarations like classes, structs and 
functions to a jump-list, for easy navigation.

Note that I'm not defending the editors, I would love if one could use a 
proper front end to do the lexing and parsing. I'm just saying it's not 
as easy as it sounded in the post I originally replied to.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list