So... let's document dmd
Walter Bright via Digitalmars-d
digitalmars-d at puremagic.com
Wed Apr 6 17:53:36 PDT 2016
On 4/6/2016 1:09 AM, Jacob Carlborg wrote:
> TextMate, Sublime and Atom all use the same syntax to describe the grammar for a
> language. All of them supports plugins (to various degrees), but none of them
> uses plugins to syntax highlight code, as far as I know.
>
> I guess it's easier for most of us, I know you write a lexer in two days :), to
> use the custom syntax to describe the grammar than to create a proper lexer and
> parser.
I doubt any of them could lex C/C++ correctly (trigraphs, macros, backslash line
splicing, wysiwyg string literals).
Even D has some issues - token string literals - that would defeat most grammar
attempts.
A straightforward lexer (i.e. one not heavily optimized for speed) written in a
reasonable high level language does not look all that different from BNF, and
has the advantage of not being borked if something is not quite expressible in
the grammar language.
> Note that a lexer is not enough, these grammars can describe how a
> function (and other constructs) look like.
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.)
More information about the Digitalmars-d
mailing list