Re: D syntax highlight support by Chroma in Hugo

2019-05-23 Thread Vladimir Panteleev via Digitalmars-d-announce

On Wednesday, 22 May 2019 at 01:36:46 UTC, Shigeki Karita wrote:
Recently, I sent a PR [1] in Chroma (syntax highlighter) to 
support D. I think my implementation is not perfect. I made 
this announcement to ask some experts for help and to ask Dlang 
blogger to use this.


Thank you for working on this.

Did you have a practical reason to work on this considering that 
Hugo supports Pygments, and Pygments has decent support for D 
already?


Here are the test files I used when working on D syntax 
highlighting in other projects, perhaps they can be useful:


https://github.com/colorer/Colorer-schemes/blob/master/hrc/test/other/d-sample.d

https://github.com/Emacs-D-Mode-Maintainers/Emacs-D-Mode/tree/master/tests



Re: D syntax highlight support by Chroma in Hugo

2019-05-22 Thread Dennis via Digitalmars-d-announce

On Wednesday, 22 May 2019 at 01:36:46 UTC, Shigeki Karita wrote:
Recently, I sent a PR [1] in Chroma (syntax highlighter) to 
support D.


Thanks for doing that!

I think my implementation is not perfect. I made this 
announcement to ask some experts for help and to ask Dlang 
blogger to use this.


Some observations:
- Multi-line comments starting with /+ are nested. You can't 
express this with pure regular expressions however, it requires a 
context-free grammar. Maybe Go has some regex extensions that 
allow it to parse context-free constructs however, I don't know.
- Integer literals can end with L, u, U, Lu, LU, uL, UL. Your 
regex doesn't allow u or U and does allow lower case l.
- "TODO support delimited strings" that will be hard, as 
delimited strings are not even context-free, let alone regular. 
I've never seen them used, so I don't think it's bad if they 
can't be highlighted properly.

- octal literals are not longer supported in D.
- In character literals you support \u but no \U or octal numbers
- string, wstring and dstring are not actually keywords, they are 
aliases that are automatically imported. I do think it makes 
sense to highlight them as keywords however, given how they are 
used like basic types.