digitalmars.D - Subtle bug in ddox vs. ddoc macro handling
- Andrei Alexandrescu (15/15) Sep 16 2016 So, I've spent the better part of this morning tracing what seems to be
- Stefan Koch (3/20) Sep 16 2016 I belive ddox is maintained by soenke ludwig
- Andrei Alexandrescu (5/6) Sep 16 2016 Thx, he's cc'd. Workaround for the time being:
- =?UTF-8?Q?S=c3=b6nke_Ludwig?= (13/13) Sep 16 2016 There is indeed a separate macro engine [1] contained in the ddox repo.
- Walter Bright (3/12) Sep 17 2016 I've factored out the Ddoc macro code into a separate component:
- Andrei Alexandrescu (4/22) Sep 17 2016 Cool. The way the whole establishment should work is that all surface
- Andrei Alexandrescu (6/20) Sep 17 2016 Cool beans, thanks. Do you think we should unify the implementations?
So, I've spent the better part of this morning tracing what seems to be a subtle bug in ddox' macro treatment. I defined these macros: IGNORESECOND = [$1] DOLLARZERO = dzbegin $0 dzend TEST = before $(IGNORESECOND $(DOLLARZERO one, two)) after I inserted $(TEST) in a Phobos module. When processing the module with ddoc, the macro expands to: before [dzbegin one, two dzend] after wherease with ddox it expands to: before [dzbegin one] after i.e. the comma "escapes" the confines of the macro DOLLARZERO. The "right" behavior is ddoc's, for several reasons. Is there a distinct macro engine powering ddox generation? Who is maintaining that? Thanks, Andrei
Sep 16 2016
On Friday, 16 September 2016 at 18:40:03 UTC, Andrei Alexandrescu wrote:So, I've spent the better part of this morning tracing what seems to be a subtle bug in ddox' macro treatment. I defined these macros: IGNORESECOND = [$1] DOLLARZERO = dzbegin $0 dzend TEST = before $(IGNORESECOND $(DOLLARZERO one, two)) after I inserted $(TEST) in a Phobos module. When processing the module with ddoc, the macro expands to: before [dzbegin one, two dzend] after wherease with ddox it expands to: before [dzbegin one] after i.e. the comma "escapes" the confines of the macro DOLLARZERO. The "right" behavior is ddoc's, for several reasons. Is there a distinct macro engine powering ddox generation? Who is maintaining that? Thanks, AndreiI belive ddox is maintained by soenke ludwig
Sep 16 2016
On 09/16/2016 03:11 PM, Stefan Koch wrote:I belive ddox is maintained by soenke ludwigThx, he's cc'd. Workaround for the time being: https://github.com/dlang/dlang.org/pull/1475, could someone please review. Thanks! Andrei
Sep 16 2016
There is indeed a separate macro engine [1] contained in the ddox repo. Neither DDMD, nor libddoc existed at the time and DMD's implementation was written in, from a D POV, very alien C style, with no suitable structure to extract high level information, so instead of porting it, I instead tried to implement a processor from the spec [1]. However, it turned out that the spec is not sufficient at all, so a lot of changes were necessary over time to work out those small differences. I'd like to improve the docs, but I'm still not confident that my implementation's behavior is always equivalent (as this issue shows). I've opened a GitHub ticket now [2] and will have a look at it shortly. [1]: https://github.com/rejectedsoftware/ddox/blob/master/source/ddox/ddoc.d [2]: http://dlang.org/spec/ddoc.html#phases_of_processing [3]: https://github.com/rejectedsoftware/ddox/issues/130
Sep 16 2016
On 9/16/2016 11:53 PM, Sönke Ludwig wrote:There is indeed a separate macro engine [1] contained in the ddox repo. Neither DDMD, nor libddoc existed at the time and DMD's implementation was written in, from a D POV, very alien C style, with no suitable structure to extract high level information, so instead of porting it, I instead tried to implement a processor from the spec [1]. However, it turned out that the spec is not sufficient at all, so a lot of changes were necessary over time to work out those small differences. I'd like to improve the docs, but I'm still not confident that my implementation's behavior is always equivalent (as this issue shows).I've factored out the Ddoc macro code into a separate component: https://digitalmars.com/sargon/textmac.html
Sep 17 2016
On 9/17/16 5:29 AM, Walter Bright wrote:On 9/16/2016 11:53 PM, Sönke Ludwig wrote:Cool. The way the whole establishment should work is that all surface syntax rewrites itself into macros, and expand() is invoked as the last step. -- AndreiThere is indeed a separate macro engine [1] contained in the ddox repo. Neither DDMD, nor libddoc existed at the time and DMD's implementation was written in, from a D POV, very alien C style, with no suitable structure to extract high level information, so instead of porting it, I instead tried to implement a processor from the spec [1]. However, it turned out that the spec is not sufficient at all, so a lot of changes were necessary over time to work out those small differences. I'd like to improve the docs, but I'm still not confident that my implementation's behavior is always equivalent (as this issue shows).I've factored out the Ddoc macro code into a separate component: https://digitalmars.com/sargon/textmac.html
Sep 17 2016
On 9/17/16 2:53 AM, Sönke Ludwig wrote:There is indeed a separate macro engine [1] contained in the ddox repo. Neither DDMD, nor libddoc existed at the time and DMD's implementation was written in, from a D POV, very alien C style, with no suitable structure to extract high level information, so instead of porting it, I instead tried to implement a processor from the spec [1]. However, it turned out that the spec is not sufficient at all, so a lot of changes were necessary over time to work out those small differences. I'd like to improve the docs, but I'm still not confident that my implementation's behavior is always equivalent (as this issue shows). I've opened a GitHub ticket now [2] and will have a look at it shortly. [1]: https://github.com/rejectedsoftware/ddox/blob/master/source/ddox/ddoc.d [2]: http://dlang.org/spec/ddoc.html#phases_of_processing [3]: https://github.com/rejectedsoftware/ddox/issues/130Cool beans, thanks. Do you think we should unify the implementations? Perhaps by moving your code (assuming we get semantic convergence) into dmd so we get the benefit of hyphenation? Say e.g. we want to add markdown input, should we continue with two codebases or unify? Thanks! -- Andrei
Sep 17 2016