Added support for D Programming Language #68

Merged
merged 4 commits into from Apr 9, 2012

Projects

None yet

2 participants

@raleksandar
Contributor

No description provided.

@isagalaev
Owner

Thank you! I wish all contribution were so thorough :-). I'll look at it soon!

@raleksandar
Contributor

I'm glad I can help :)

There are some issues thou, which I've noted in d.js but I think those are really edge cases. And some of D lexing rules are impossible to implement in highlight.js (or I'm unaware of a way to do so, but I've just briefly looked at highlight.js code and I am planning to read it more thoroughly).

Also I had collisions with MEL and Rust in test.html (D taking over MEL and Rust beating D), which I've fixed by tweaking relevance factors, but it might need some more work.. (although I like auto-detection feature I really think that explicitly stating which language to use is correct approach).

@isagalaev
Owner

Highlight.js is not meant as a full-blown parser so there's only so much it can do, it's true.

I'm looking at a clash with Rust right now and will fix it. Rust is a new addition too, so things like this are only expected. And yes, you're right that no heuristics can be 100% reliable.

@isagalaev isagalaev merged commit a246b6f into isagalaev:master Apr 9, 2012
@isagalaev
Owner

Merged. You might want to look at this commit: 3ef21d1
Highlight.js supports self-referencing modes from the start (it wouldn't be possible to define Lisp parsing without it, for example) though I now realize I forgot to update dev docs with the 'self' keyword which is a recent addition.

I also fixed Rust eagerness in the D fragment and removed a few of now unneeded relevance attributes from D.

Thanks again, Alexandar!

@raleksandar
Contributor

There is 'self'? Great! :)

I know I've looked at few grammars searching for a way to do nesting but don't know how I didn't think of Lisp.. (I've looked at Delphi for example, as (* *) comments should be nesting, if I'm not wrong, and they aren't in definition file)

@raleksandar
Contributor

One more thing, comment at line 21 in d.js should now be removed, as nesting is not limited anymore..

@isagalaev
Owner

As far as I know, Delphi's (* *) can't be nested. I was coding primarily in Delphi some years back, may be something changed since then. Anyway, 'self' is just a syntactic sugar. Before it you could just add self references imperatively:

D_COMMENT = { ... };
D_COMMENT.contains = [D_COMMENT];

(Removed the comment about nesting, thanks)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment