<p dir="ltr">Any chance of you turning this into a daemon? Something likt margo or gocode?</p>
<div class="gmail_quote">On 29 Jul 2013 11:05, "qznc" <<a href="mailto:qznc@web.de">qznc@web.de</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Saturday, 27 July 2013 at 22:27:35 UTC, Brian Schott wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
DScanner is a tool for analyzing D source code. It has the following features:<br>
<br>
* Prints out a complete AST of a source file in XML format.<br>
* Syntax checks code and prints warning/error messages<br>
* Prints a listing of modules imported by a source file<br>
* Syntax highlights code in HTML format<br>
* Provides more meaningful "line of code" count than wc<br>
* Counts tokens in a source file<br>
<br>
The lexer/parser/AST are located in the "std/d" directory in the repository. These files should prove useful to anyone else working on D tooling.<br>
<br>
<a href="https://github.com/Hackerpilot/Dscanner" target="_blank">https://github.com/<u></u>Hackerpilot/Dscanner</a><br>
<br>
Aside: the D grammar that I reverse-engineered can be located here: <a href="https://rawgithub.com/Hackerpilot/DGrammar/master/grammar.html" target="_blank">https://rawgithub.com/<u></u>Hackerpilot/DGrammar/master/<u></u>grammar.html</a><br>

</blockquote>
<br>
Dscanner looks like a good starting point for a code formatting tool (like gofmt). However, there seems to be a tradeoff with performance involved. For compilation you want a fast lexer and parser. For formatting you need to preserve comments, though.<br>

<br>
For example, convert this from source to AST to source without losing the comments:<br>
<br>
void /*hello*/ /*world*/ main () { }<br>
</blockquote></div>